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), dpiCurIdx(other.dpiCurIdx), dpiLastIdx(other.dpiLastIdx), 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++){
88 for(
int i = 0; i <
I_COUNT; i++){
112 bool readIndicators =
true;
116 SGroup group(settings,
"Lighting");
117 if(settings.
contains(
"InactiveIndicators")){
119 int inactive = settings.
value(
"InactiveIndicators").toInt(&inOk);
120 if(!inOk || inactive > 2)
124 else if(inactive == 0)
126 else if(inactive < 0){
130 bool showMute = (settings.
value(
"ShowMute").toInt(&inOk) != 0);
131 if(inOk && !showMute)
133 readIndicators =
false;
136 SGroup group(settings,
"Performance");
139 SGroup group(settings,
"DPI");
141 QString iStr = QString::number(i);
142 QPoint value = settings.
value(iStr).toPoint();
145 dpiX[i] = value.x();
dpiY[i] = value.y();
146 QColor color = settings.
value(iStr +
"RGB").toString();
150 dpiOn[i] = !settings.
value(iStr +
"Disabled").toBool();
152 QColor color = settings.
value(
"6RGB").toString();
160 QPoint value = settings.
value(
"Current").toPoint();
166 if(_liftHeight < LOW || _liftHeight >
HIGH)
169 if(settings.
contains(
"NoIndicator")){
177 SGroup group(settings,
"Indicators");
179 for(
int i = 0; i <
I_COUNT; i++){
180 SGroup group(settings, QString::number(i));
181 QColor color = settings.
value(
"RGB0").toString();
184 color = settings.
value(
"RGB1").toString();
188 color = settings.
value(
"RGB2").toString();
191 }
else if(i ==
MUTE){
192 color = settings.
value(
"RGB2").toString();
209 SGroup group(settings,
"Performance");
211 SGroup group(settings,
"DPI");
213 QString iStr = QString::number(i);
227 settings.
setValue(
"Current", QPoint(curX, curY));
232 SGroup group(settings,
"Indicators");
234 for(
int i = 0; i <
I_COUNT; i++){
235 SGroup group(settings, QString::number(i));
252 dpiX[index] = newValue.x();
253 dpiY[index] = newValue.y();
297 if(pushIdx == 0 || !
pushedDpis.contains(pushIdx))
315 }
while(!
dpiOn[idx]);
325 }
while(!
dpiOn[idx]);
330 if(index < 0 || index >=
I_COUNT)
332 color1 =
iColor[index][0];
333 color2 =
iColor[index][1];
336 else if(index ==
MUTE)
340 software_enable =
iEnable[index];
345 if(index < 0 || index >=
I_COUNT)
347 iColor[index][0] = color1;
348 iColor[index][1] = color2;
351 else if(index ==
MUTE)
353 iEnable[index] = software_enable;
354 if(hardware_enable ==
NONE)
357 hwIType[index] = hardware_enable;
362 if(newHeight < LOW || newHeight >
HIGH)
373 void KbPerf::update(QFile& cmd,
int notifyNumber,
bool force,
bool saveCustomDpi){
379 cmd.write(QString(
"dpi 0:%1,%2").arg(
dpiX[0]).arg(
dpiY[0]).toLatin1());
382 if(stage < 0 && saveCustomDpi){
384 cmd.write(QString(
" 1:%1,%2").arg(
dpiCurX).arg(
dpiCurY).toLatin1());
387 if(!
dpiOn[1] && stage != 1)
390 cmd.write(QString(
" 1:%1,%2").arg(
dpiX[1]).arg(
dpiY[1]).toLatin1());
394 if(!
dpiOn[i] && stage != i)
395 cmd.write(QString(
" %1:off").arg(i).toLatin1());
397 cmd.write(QString(
" %1:%2,%3").arg(i).arg(
dpiX[i]).arg(
dpiY[i]).toLatin1());
400 cmd.write(QString(
" dpisel %1 lift %2 snap %3").arg(stage).arg(
_liftHeight).arg(
_angleSnap ?
"on" :
"off").toLatin1());
407 snprintf(output,
sizeof(output),
"%1d:%02x%02x%02x", i, color.red(), color.green(), color.blue());
411 cmd.write(QString(
"\n@%1 inotify all").arg(notifyNumber).toLatin1());
413 const char* iNames[
HW_I_COUNT] = {
"num",
"caps",
"scroll" };
420 cmd.write(
" iauto ");
421 cmd.write(iNames[i]);
439 if(index == -1 || index >
OTHER)
447 snprintf(name,
sizeof(name),
"m%d", i + 1);
457 switch(
light()->dimming()){
471 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
void update(QFile &cmd, int notifyNumber, bool force=false, bool saveCustomDpi=true)
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 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)