7 #if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
8 #define map_last(map) ((map).last())
10 #define map_last(map) ((map).value((map).keys().last()))
14 QObject(parent), runningPushIdx(1),
15 _iOpacity(1.f), _dpiIndicator(true), _liftHeight(MEDIUM), _angleSnap(false),
16 _needsUpdate(true), _needsSave(true) {
24 dpiClr[0] = QColor(255, 0, 0);
25 dpiClr[1] = QColor(255, 192, 0);
26 dpiClr[2] = QColor(255, 255, 0);
27 dpiClr[3] = QColor(0, 255, 0);
28 dpiClr[4] = QColor(0, 255, 255);
29 dpiClr[5] = QColor(255, 255, 255);
30 dpiClr[6] = QColor(192, 192, 192);
51 for(
int i = HW_I_COUNT; i <
I_COUNT; i++){
58 QObject(parent), dpiCurX(other.dpiCurX), dpiCurY(other.dpiCurY), dpiBaseIdx(other.dpiBaseIdx), runningPushIdx(1),
59 _iOpacity(other._iOpacity), light100Color(other.light100Color), muteNAColor(other.muteNAColor), _dpiIndicator(other._dpiIndicator),
60 _liftHeight(other._liftHeight), _angleSnap(other._angleSnap),
61 _needsUpdate(true), _needsSave(true) {
67 for(
int i = 0; i <
I_COUNT; i++){
87 for(
int i = 0; i <
I_COUNT; i++){
110 bool readIndicators =
true;
114 SGroup group(settings,
"Lighting");
115 if(settings.
contains(
"InactiveIndicators")){
117 int inactive = settings.
value(
"InactiveIndicators").toInt(&inOk);
118 if(!inOk || inactive > 2)
122 else if(inactive == 0)
124 else if(inactive < 0){
128 bool showMute = (settings.
value(
"ShowMute").toInt(&inOk) != 0);
129 if(inOk && !showMute)
131 readIndicators =
false;
134 SGroup group(settings,
"Performance");
137 SGroup group(settings,
"DPI");
139 QString iStr = QString::number(i);
140 QPoint value = settings.
value(iStr).toPoint();
143 dpiX[i] = value.x();
dpiY[i] = value.y();
144 QColor color = settings.
value(iStr +
"RGB").toString();
148 dpiOn[i] = !settings.
value(iStr +
"Disabled").toBool();
150 QColor color = settings.
value(
"6RGB").toString();
170 if(_liftHeight < LOW || _liftHeight >
HIGH)
173 if(settings.
contains(
"NoIndicator")){
181 SGroup group(settings,
"Indicators");
183 for(
int i = 0; i <
I_COUNT; i++){
184 SGroup group(settings, QString::number(i));
185 QColor color = settings.
value(
"RGB0").toString();
188 color = settings.
value(
"RGB1").toString();
192 color = settings.
value(
"RGB2").toString();
195 }
else if(i ==
MUTE){
196 color = settings.
value(
"RGB2").toString();
213 SGroup group(settings,
"Performance");
215 SGroup group(settings,
"DPI");
217 QString iStr = QString::number(i);
230 SGroup group(settings,
"Indicators");
232 for(
int i = 0; i <
I_COUNT; i++){
233 SGroup group(settings, QString::number(i));
250 dpiX[index] = newValue.x();
251 dpiY[index] = newValue.y();
302 }
while(!
dpiOn[idx]);
312 }
while(!
dpiOn[idx]);
325 }
while(!
dpiOn[idx]);
337 }
while(!
dpiOn[idx]);
342 if(index < 0 || index >=
I_COUNT)
344 color1 =
iColor[index][0];
345 color2 =
iColor[index][1];
348 else if(index ==
MUTE)
352 software_enable =
iEnable[index];
357 if(index < 0 || index >=
I_COUNT)
359 iColor[index][0] = color1;
360 iColor[index][1] = color2;
363 else if(index ==
MUTE)
365 iEnable[index] = software_enable;
366 if(hardware_enable ==
NONE)
369 hwIType[index] = hardware_enable;
374 if(newHeight < LOW || newHeight >
HIGH)
394 cmd.write(QString(
"dpi 0:%1,%2").arg(
dpiCurX).arg(
dpiCurY).toLatin1());
397 cmd.write(QString(
"dpi 0:%1,%2").arg(
dpiX[0]).arg(
dpiY[0]).toLatin1());
401 if(!
dpiOn[i] && stage != i)
402 cmd.write(QString(
" %1:off").arg(i).toLatin1());
404 cmd.write(QString(
" %1:%2,%3").arg(i).arg(
dpiX[i]).arg(
dpiY[i]).toLatin1());
407 cmd.write(QString(
" dpisel %1 lift %2 snap %3").arg(stage).arg(
_liftHeight).arg(
_angleSnap ?
"on" :
"off").toLatin1());
414 snprintf(output,
sizeof(output),
"%1d:%02x%02x%02x", i, color.red(), color.green(), color.blue());
418 cmd.write(QString(
"\n@%1 inotify all").arg(notifyNumber).toLatin1());
420 const char* iNames[
HW_I_COUNT] = {
"num",
"caps",
"scroll" };
427 cmd.write(
" iauto ");
428 cmd.write(iNames[i]);
446 if(index == -1 || index >
OTHER)
454 snprintf(name,
sizeof(name),
"m%d", i + 1);
464 switch(
light()->dimming()){
478 if(
bind()->winLock())
static const int HW_I_COUNT
void setValue(const QString &key, const QVariant &value)
void _curDpi(const QPoint &newDpi)
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
QColor dpiColor(int index) const
bool contains(const QString &key) const
QMap< quint64, QPoint > pushedDpis
height liftHeight() const
void popDpi(quint64 pushIdx)
KbMode * modeParent() const
quint64 pushDpi(const QPoint &newDpi)
bool containsGroup(const QString &group)
QPoint dpi(int index) const
static const int HWMODE_MAX
static const int DPI_COUNT
void setIndicator(indicator index, const QColor &color1, const QColor &color2, const QColor &color3=QColor(), bool software_enable=true, i_hw hardware_enable=NORMAL)
void getIndicator(indicator index, QColor &color1, QColor &color2, QColor &color3, bool &software_enable, i_hw &hardware_enable)
void update(QFile &cmd, int notifyNumber, bool force, bool saveCustomDpi)
void setIndicator(const char *name, QRgb argb)
QColor dpiClr[DPI_COUNT+1]
QColor iColor[I_COUNT][2]
const KbPerf & operator=(const KbPerf &rhs)
void lightIndicator(const char *name, QRgb rgba)
void applyIndicators(int modeIndex, const bool indicatorState[HW_I_COUNT])
void save(CkbSettings &settings)
void load(CkbSettings &settings)