ckb-next  v0.2.8 at branch master
ckb-next driver for corsair devices
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
KbPerf Class Reference

#include <src/ckb/kbperf.h>

+ Inheritance diagram for KbPerf:
+ Collaboration diagram for KbPerf:

Public Types

enum  height {
  LOW = 1, LOWMED, MEDIUM, MEDHIGH,
  HIGH
}
 
enum  indicator {
  NUM, CAPS, SCROLL, HW_IMAX = SCROLL,
  MODE, MACRO, LIGHT, LOCK,
  MUTE
}
 
enum  i_hw { NONE = -1, NORMAL, ON, OFF }
 

Signals

void didLoad ()
 
void settingsUpdated ()
 

Public Member Functions

 KbPerf (KbMode *parent)
 
 KbPerf (KbMode *parent, const KbPerf &other)
 
const KbPerfoperator= (const KbPerf &rhs)
 
void load (CkbSettings &settings)
 
void save (CkbSettings &settings)
 
bool needsSave () const
 
height liftHeight () const
 
void liftHeight (height newHeight)
 
bool angleSnap () const
 
void angleSnap (bool newAngleSnap)
 
QPoint dpi (int index) const
 
void dpi (int index, const QPoint &newValue)
 
QPoint sniperDpi () const
 
void sniperDpi (const QPoint &newValue)
 
void dpi (int index, int newValue)
 
void sniperDpi (int newValue)
 
int baseDpiIdx () const
 
void baseDpiIdx (int newIdx)
 
void dpiUp ()
 
void dpiDown ()
 
void dpiCycleUp ()
 
void dpiCycleDown ()
 
bool dpiEnabled (int index) const
 
void dpiEnabled (int index, bool newEnabled)
 
quint64 pushDpi (const QPoint &newDpi)
 
quint64 pushDpi (int newDpi)
 
quint64 pushSniper ()
 
void popDpi (quint64 pushIdx)
 
float iOpacity () const
 
void iOpacity (float newIOpacity)
 
bool dpiIndicator () const
 
void dpiIndicator (bool newDpiIndicator)
 
QColor dpiColor (int index) const
 
void dpiColor (int index, const QColor &newColor)
 
void getIndicator (indicator index, QColor &color1, QColor &color2, QColor &color3, bool &software_enable, i_hw &hardware_enable)
 
void setIndicator (indicator index, const QColor &color1, const QColor &color2, const QColor &color3=QColor(), bool software_enable=true, i_hw hardware_enable=NORMAL)
 
void update (QFile &cmd, int notifyNumber, bool force, bool saveCustomDpi)
 
void setNeedsUpdate ()
 
void applyIndicators (int modeIndex, const bool indicatorState[HW_I_COUNT])
 

Static Public Attributes

static const int DPI_COUNT = 6
 
static const int SNIPER = 0
 
static const int DPI_MIN = 100
 
static const int DPI_MAX = 12000
 
static const int OTHER = DPI_COUNT
 
static const int I_COUNT = (int)MUTE + 1
 
static const int HW_I_COUNT = (int)HW_IMAX + 1
 

Private Member Functions

KbModemodeParent () const
 
KbBindbind () const
 
KbLightlight () const
 
void lightIndicator (const char *name, QRgb rgba)
 
void _curDpi (const QPoint &newDpi)
 

Private Attributes

int dpiX [DPI_COUNT]
 
int dpiY [DPI_COUNT]
 
int dpiCurX
 
int dpiCurY
 
int dpiBaseIdx
 
QColor dpiClr [DPI_COUNT+1]
 
bool dpiOn [DPI_COUNT]
 
QMap< quint64, QPoint > pushedDpis
 
uint runningPushIdx
 
float _iOpacity
 
QColor iColor [I_COUNT][2]
 
QColor light100Color
 
QColor muteNAColor
 
bool iEnable [I_COUNT]
 
i_hw hwIType [HW_I_COUNT]
 
bool _dpiIndicator
 
height _liftHeight
 
bool _angleSnap
 
bool _needsUpdate
 
bool _needsSave
 

Detailed Description

Definition at line 15 of file kbperf.h.

Member Enumeration Documentation

Enumerator
LOW 
LOWMED 
MEDIUM 
MEDHIGH 
HIGH 

Definition at line 31 of file kbperf.h.

31  {
32  LOW = 1,
33  LOWMED,
34  MEDIUM,
35  MEDHIGH,
36  HIGH
37  };
Enumerator
NONE 
NORMAL 
ON 
OFF 

Definition at line 101 of file kbperf.h.

101  {
102  NONE = -1, // For non-hardware indicators
103  NORMAL,
104  ON,
105  OFF
106  };
Enumerator
NUM 
CAPS 
SCROLL 
HW_IMAX 
MODE 
MACRO 
LIGHT 
LOCK 
MUTE 

Definition at line 88 of file kbperf.h.

88  {
89  // Hardware
90  NUM,
91  CAPS,
93  // Software
94  MODE,
95  MACRO,
96  LIGHT,
97  LOCK,
98  MUTE
99  };

Constructor & Destructor Documentation

KbPerf::KbPerf ( KbMode parent)
explicit

Definition at line 13 of file kbperf.cpp.

References CAPS, DPI_COUNT, dpiBaseIdx, dpiClr, dpiCurX, dpiCurY, dpiOn, dpiX, dpiY, HW_I_COUNT, hwIType, I_COUNT, iColor, iEnable, LIGHT, light100Color, LOCK, MACRO, MODE, MUTE, muteNAColor, NORMAL, NUM, and SCROLL.

13  :
14  QObject(parent), runningPushIdx(1),
15  _iOpacity(1.f), _dpiIndicator(true), _liftHeight(MEDIUM), _angleSnap(false),
16  _needsUpdate(true), _needsSave(true) {
17  // Default DPI settings
18  dpiX[0] = dpiY[0] = 400;
19  dpiX[1] = dpiY[1] = 450;
20  dpiX[2] = dpiY[2] = 800;
21  dpiX[3] = dpiY[3] = 1500;
22  dpiX[4] = dpiY[4] = 3000;
23  dpiX[5] = dpiY[5] = 6000;
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);
31  for(int i = 0; i < DPI_COUNT; i++)
32  dpiOn[i] = true;
33  dpiBaseIdx = 3;
36  // Default indicators
37  iColor[NUM][0] = iColor[CAPS][0] = iColor[SCROLL][0] = QColor(0, 255, 0); // Lock lights: on = green, off = black
38  iColor[NUM][1] = iColor[CAPS][1] = iColor[SCROLL][1] = QColor(0, 0, 0);
39  iColor[MACRO][0] = QColor(255, 0, 0); // Macro: on = red, off = black
40  iColor[LOCK][0] = QColor(255, 255, 255); // Win lock: on = white, off = black
41  iColor[MODE][0] = iColor[MUTE][0] = QColor(255, 255, 255, 0); // Mode, mute: on = transparent, off = black
42  iColor[MODE][1] = iColor[MACRO][1] = iColor[LOCK][1] = iColor[MUTE][1] = muteNAColor = QColor(0, 0, 0);
43  iColor[LIGHT][0] = QColor(255, 0, 0); // Brightness: red, yellow, white
44  iColor[LIGHT][1] = QColor(255, 255, 0);
45  light100Color = QColor(255, 255, 255);
46  for(int i = 0; i < HW_I_COUNT; i++){
47  // Set all lock lights to HW mode
48  iEnable[i] = false;
49  hwIType[i] = NORMAL;
50  }
51  for(int i = HW_I_COUNT; i < I_COUNT; i++){
52  // Turn all other indicators on
53  iEnable[i] = true;
54  }
55 }
static const int HW_I_COUNT
Definition: kbperf.h:107
bool _needsUpdate
Definition: kbperf.h:166
int dpiBaseIdx
Definition: kbperf.h:142
int dpiCurY
Definition: kbperf.h:138
QColor light100Color
Definition: kbperf.h:157
uint runningPushIdx
Definition: kbperf.h:149
bool iEnable[I_COUNT]
Definition: kbperf.h:158
bool dpiOn[DPI_COUNT]
Definition: kbperf.h:144
i_hw hwIType[HW_I_COUNT]
Definition: kbperf.h:159
float _iOpacity
Definition: kbperf.h:155
height _liftHeight
Definition: kbperf.h:163
bool _needsSave
Definition: kbperf.h:166
static const int DPI_COUNT
Definition: kbperf.h:46
QColor muteNAColor
Definition: kbperf.h:157
bool _angleSnap
Definition: kbperf.h:164
int dpiY[DPI_COUNT]
Definition: kbperf.h:136
int dpiCurX
Definition: kbperf.h:138
QColor dpiClr[DPI_COUNT+1]
Definition: kbperf.h:143
QColor iColor[I_COUNT][2]
Definition: kbperf.h:156
int dpiX[DPI_COUNT]
Definition: kbperf.h:135
bool _dpiIndicator
Definition: kbperf.h:160
static const int I_COUNT
Definition: kbperf.h:107
KbPerf::KbPerf ( KbMode parent,
const KbPerf other 
)

Definition at line 57 of file kbperf.cpp.

References _curDpi(), dpi(), DPI_COUNT, dpiBaseIdx, dpiClr, dpiOn, dpiX, dpiY, hwIType, I_COUNT, iColor, and iEnable.

57  :
58  QObject(parent), dpiCurX(other.dpiCurX), dpiCurY(other.dpiCurY), dpiBaseIdx(other.dpiBaseIdx), runningPushIdx(1),
61  _needsUpdate(true), _needsSave(true) {
62  memcpy(dpiX, other.dpiX, sizeof(dpiX));
63  memcpy(dpiY, other.dpiY, sizeof(dpiY));
64  for(int i = 0; i < DPI_COUNT + 1; i++)
65  dpiClr[i] = other.dpiClr[i];
66  memcpy(dpiOn, other.dpiOn, sizeof(dpiOn));
67  for(int i = 0; i < I_COUNT; i++){
68  iColor[i][0] = other.iColor[i][0];
69  iColor[i][1] = other.iColor[i][1];
70  }
71  memcpy(iEnable, other.iEnable, sizeof(iEnable));
72  memcpy(hwIType, other.hwIType, sizeof(hwIType));
73  // Don't copy pushed DPI states. If the other mode has any, restore the original DPI
75 }
bool _needsUpdate
Definition: kbperf.h:166
void _curDpi(const QPoint &newDpi)
Definition: kbperf.cpp:259
int dpiBaseIdx
Definition: kbperf.h:142
int dpiCurY
Definition: kbperf.h:138
QColor light100Color
Definition: kbperf.h:157
uint runningPushIdx
Definition: kbperf.h:149
bool iEnable[I_COUNT]
Definition: kbperf.h:158
bool dpiOn[DPI_COUNT]
Definition: kbperf.h:144
i_hw hwIType[HW_I_COUNT]
Definition: kbperf.h:159
float _iOpacity
Definition: kbperf.h:155
height _liftHeight
Definition: kbperf.h:163
QPoint dpi(int index) const
Definition: kbperf.h:50
bool _needsSave
Definition: kbperf.h:166
static const int DPI_COUNT
Definition: kbperf.h:46
QColor muteNAColor
Definition: kbperf.h:157
bool _angleSnap
Definition: kbperf.h:164
int dpiY[DPI_COUNT]
Definition: kbperf.h:136
int dpiCurX
Definition: kbperf.h:138
QColor dpiClr[DPI_COUNT+1]
Definition: kbperf.h:143
QColor iColor[I_COUNT][2]
Definition: kbperf.h:156
int dpiX[DPI_COUNT]
Definition: kbperf.h:135
bool _dpiIndicator
Definition: kbperf.h:160
static const int I_COUNT
Definition: kbperf.h:107

+ Here is the call graph for this function:

Member Function Documentation

void KbPerf::_curDpi ( const QPoint &  newDpi)
private

Definition at line 259 of file kbperf.cpp.

References _needsSave, _needsUpdate, dpiCurX, and dpiCurY.

Referenced by baseDpiIdx(), dpi(), KbPerf(), load(), operator=(), popDpi(), and pushDpi().

259  {
260  dpiCurX = newDpi.x();
261  dpiCurY = newDpi.y();
262  _needsUpdate = _needsSave = true;
263 }
bool _needsUpdate
Definition: kbperf.h:166
int dpiCurY
Definition: kbperf.h:138
bool _needsSave
Definition: kbperf.h:166
int dpiCurX
Definition: kbperf.h:138

+ Here is the caller graph for this function:

bool KbPerf::angleSnap ( ) const
inline

Definition at line 42 of file kbperf.h.

References _angleSnap.

Referenced by MPerfWidget::on_aSnapBox_clicked(), Kb::readNotify(), and MPerfWidget::setPerf().

42 { return _angleSnap; }
bool _angleSnap
Definition: kbperf.h:164

+ Here is the caller graph for this function:

void KbPerf::angleSnap ( bool  newAngleSnap)

Definition at line 380 of file kbperf.cpp.

References _angleSnap, _needsSave, and _needsUpdate.

380  {
381  _angleSnap = newAngleSnap;
382  _needsUpdate = _needsSave = true;
383 }
bool _needsUpdate
Definition: kbperf.h:166
bool _needsSave
Definition: kbperf.h:166
bool _angleSnap
Definition: kbperf.h:164
void KbPerf::applyIndicators ( int  modeIndex,
const bool  indicatorState[HW_I_COUNT] 
)

Definition at line 439 of file kbperf.cpp.

References _dpiIndicator, _iOpacity, baseDpiIdx(), bind(), CAPS, dpiClr, getMuteState(), Kb::HWMODE_MAX, iColor, iEnable, LIGHT, light(), light100Color, lightIndicator(), LOCK, MACRO, MODE, MUTE, MUTED, muteNAColor, NUM, OTHER, KbLight::resetIndicators(), SCROLL, and UNMUTED.

Referenced by Kb::frameUpdate().

439  {
440  light()->resetIndicators();
441  if(_iOpacity <= 0.f)
442  return;
443  if(_dpiIndicator){
444  // Set DPI indicator according to index
445  int index = baseDpiIdx();
446  if(index == -1 || index > OTHER)
447  index = OTHER;
448  lightIndicator("dpi", dpiClr[index].rgba());
449  }
450  // KB indicators
451  if(iEnable[MODE]){
452  for(int i = 0; i < Kb::HWMODE_MAX; i++){
453  char name[4];
454  snprintf(name, sizeof(name), "m%d", i + 1);
455  if(modeIndex == i)
456  lightIndicator(name, iColor[MODE][0].rgba());
457  else
458  lightIndicator(name, iColor[MODE][1].rgba());
459  }
460  }
461  if(iEnable[MACRO])
462  lightIndicator("mr", iColor[MUTE][1].rgba());
463  if(iEnable[LIGHT]){
464  switch(light()->dimming()){
465  case 0: // 100%
466  lightIndicator("light", light100Color.rgba());
467  break;
468  case 1: // 67%
469  lightIndicator("light", iColor[LIGHT][1].rgba());
470  break;
471  case 2: // 33%
472  case 3: // light off
473  lightIndicator("light", iColor[LIGHT][0].rgba());
474  break;
475  }
476  }
477  if(iEnable[LOCK]){
478  if(bind()->winLock())
479  lightIndicator("lock", iColor[LOCK][0].rgba());
480  else
481  lightIndicator("lock", iColor[LOCK][1].rgba());
482  }
483  if(iEnable[MUTE]){
484  switch(getMuteState()){
485  case MUTED:
486  lightIndicator("mute", iColor[MUTE][0].rgba());
487  break;
488  case UNMUTED:
489  lightIndicator("mute", iColor[MUTE][1].rgba());
490  break;
491  default:
492  lightIndicator("mute", muteNAColor.rgba());
493  break;
494  }
495  }
496  // Lock lights
497  if(iEnable[NUM])
498  lightIndicator("numlock", indicatorState[0] ? iColor[NUM][0].rgba() : iColor[NUM][1].rgba());
499  if(iEnable[CAPS])
500  lightIndicator("caps", indicatorState[1] ? iColor[CAPS][0].rgba() : iColor[CAPS][1].rgba());
501  if(iEnable[SCROLL])
502  lightIndicator("scroll", indicatorState[2] ? iColor[SCROLL][0].rgba() : iColor[SCROLL][1].rgba());
503 }
KbBind * bind() const
Definition: kbperf.cpp:98
QColor light100Color
Definition: kbperf.h:157
bool iEnable[I_COUNT]
Definition: kbperf.h:158
float _iOpacity
Definition: kbperf.h:155
void resetIndicators()
Definition: kblight.cpp:254
static const int HWMODE_MAX
Definition: kb.h:50
QColor muteNAColor
Definition: kbperf.h:157
muteState getMuteState()
Definition: media.h:21
int baseDpiIdx() const
Definition: kbperf.h:61
QColor dpiClr[DPI_COUNT+1]
Definition: kbperf.h:143
QColor iColor[I_COUNT][2]
Definition: kbperf.h:156
Definition: media.h:22
void lightIndicator(const char *name, QRgb rgba)
Definition: kbperf.cpp:432
KbLight * light() const
Definition: kbperf.cpp:102
static const int OTHER
Definition: kbperf.h:84
bool _dpiIndicator
Definition: kbperf.h:160

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int KbPerf::baseDpiIdx ( ) const
inline

Definition at line 61 of file kbperf.h.

References dpiBaseIdx.

Referenced by applyIndicators(), dpiCycleDown(), dpiCycleUp(), dpiDown(), dpiUp(), KeyAction::keyEvent(), and Kb::readNotify().

61 { return dpiBaseIdx; }
int dpiBaseIdx
Definition: kbperf.h:142

+ Here is the caller graph for this function:

void KbPerf::baseDpiIdx ( int  newIdx)

Definition at line 265 of file kbperf.cpp.

References _curDpi(), _needsSave, _needsUpdate, dpi(), dpiBaseIdx, and pushedDpis.

265  {
266  if (pushedDpis.isEmpty() && dpiBaseIdx == newIdx)
267  return;
268  pushedDpis.clear();
269  dpiBaseIdx = newIdx;
271  _needsUpdate = _needsSave = true;
272 }
bool _needsUpdate
Definition: kbperf.h:166
void _curDpi(const QPoint &newDpi)
Definition: kbperf.cpp:259
int dpiBaseIdx
Definition: kbperf.h:142
QMap< quint64, QPoint > pushedDpis
Definition: kbperf.h:148
QPoint dpi(int index) const
Definition: kbperf.h:50
bool _needsSave
Definition: kbperf.h:166

+ Here is the call graph for this function:

KbBind * KbPerf::bind ( ) const
private

Definition at line 98 of file kbperf.cpp.

References KbMode::bind(), and modeParent().

Referenced by applyIndicators().

98  {
99  return modeParent()->bind();
100 }
KbBind * bind()
Definition: kbmode.h:61
KbMode * modeParent() const
Definition: kbperf.h:127

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void KbPerf::didLoad ( )
signal

Definition at line 134 of file moc_kbperf.cpp.

Referenced by load().

135 {
136  QMetaObject::activate(this, &staticMetaObject, 0, Q_NULLPTR);
137 }

+ Here is the caller graph for this function:

QPoint KbPerf::dpi ( int  index) const
inline

Definition at line 50 of file kbperf.h.

References DPI_COUNT, dpiX, and dpiY.

Referenced by baseDpiIdx(), MPerfWidget::boxXChanged(), MPerfWidget::boxYChanged(), KbPerf(), load(), operator=(), popDpi(), Kb::readNotify(), RebindWidget::setBind(), MPerfWidget::setPerf(), MPerfWidget::sliderXMoved(), MPerfWidget::sliderYMoved(), and sniperDpi().

50 { if(index < 0 || index >= DPI_COUNT) return QPoint(); return QPoint(dpiX[index], dpiY[index]); }
static const int DPI_COUNT
Definition: kbperf.h:46
int dpiY[DPI_COUNT]
Definition: kbperf.h:136
int dpiX[DPI_COUNT]
Definition: kbperf.h:135

+ Here is the caller graph for this function:

void KbPerf::dpi ( int  index,
const QPoint &  newValue 
)

Definition at line 247 of file kbperf.cpp.

References _curDpi(), _needsSave, _needsUpdate, DPI_COUNT, dpiBaseIdx, dpiX, dpiY, and pushedDpis.

247  {
248  if(index < 0 || index >= DPI_COUNT)
249  return;
250  dpiX[index] = newValue.x();
251  dpiY[index] = newValue.y();
252  // Update current DPI if needed
253  if(dpiBaseIdx == index && pushedDpis.isEmpty()) {
254  _curDpi(QPoint(dpiX[index], dpiY[index]));
255  }
256  _needsUpdate = _needsSave = true;
257 }
bool _needsUpdate
Definition: kbperf.h:166
void _curDpi(const QPoint &newDpi)
Definition: kbperf.cpp:259
int dpiBaseIdx
Definition: kbperf.h:142
QMap< quint64, QPoint > pushedDpis
Definition: kbperf.h:148
bool _needsSave
Definition: kbperf.h:166
static const int DPI_COUNT
Definition: kbperf.h:46
int dpiY[DPI_COUNT]
Definition: kbperf.h:136
int dpiX[DPI_COUNT]
Definition: kbperf.h:135

+ Here is the call graph for this function:

void KbPerf::dpi ( int  index,
int  newValue 
)
inline

Definition at line 55 of file kbperf.h.

References dpi().

Referenced by dpi().

55 { dpi(index, QPoint(newValue, newValue)); }
QPoint dpi(int index) const
Definition: kbperf.h:50

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

QColor KbPerf::dpiColor ( int  index) const
inline

Definition at line 85 of file kbperf.h.

References dpiClr.

Referenced by MPerfWidget::colorChanged(), Kb::readNotify(), MPerfWidget::setPerf(), and update().

85 { return dpiClr[index]; }
QColor dpiClr[DPI_COUNT+1]
Definition: kbperf.h:143

+ Here is the caller graph for this function:

void KbPerf::dpiColor ( int  index,
const QColor &  newColor 
)
inline

Definition at line 86 of file kbperf.h.

References _needsSave, _needsUpdate, and dpiClr.

86 { dpiClr[index] = newColor; _needsUpdate = _needsSave = true; }
bool _needsUpdate
Definition: kbperf.h:166
bool _needsSave
Definition: kbperf.h:166
QColor dpiClr[DPI_COUNT+1]
Definition: kbperf.h:143
void KbPerf::dpiCycleDown ( )

Definition at line 329 of file kbperf.cpp.

References baseDpiIdx(), DPI_COUNT, dpiOn, and SNIPER.

Referenced by KeyAction::keyEvent().

329  {
330  int idx = baseDpiIdx();
331  do {
332  idx--;
333  if(idx <= SNIPER)
334  idx = DPI_COUNT - 1;
335  if(idx == baseDpiIdx())
336  return;
337  } while(!dpiOn[idx]);
338  baseDpiIdx(idx);
339 }
bool dpiOn[DPI_COUNT]
Definition: kbperf.h:144
static const int DPI_COUNT
Definition: kbperf.h:46
int baseDpiIdx() const
Definition: kbperf.h:61
static const int SNIPER
Definition: kbperf.h:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void KbPerf::dpiCycleUp ( )

Definition at line 317 of file kbperf.cpp.

References baseDpiIdx(), DPI_COUNT, dpiOn, and SNIPER.

Referenced by KeyAction::keyEvent().

317  {
318  int idx = baseDpiIdx();
319  do {
320  idx++;
321  if(idx >= DPI_COUNT)
322  idx = SNIPER + 1;
323  if(idx == baseDpiIdx())
324  return;
325  } while(!dpiOn[idx]);
326  baseDpiIdx(idx);
327 }
bool dpiOn[DPI_COUNT]
Definition: kbperf.h:144
static const int DPI_COUNT
Definition: kbperf.h:46
int baseDpiIdx() const
Definition: kbperf.h:61
static const int SNIPER
Definition: kbperf.h:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void KbPerf::dpiDown ( )

Definition at line 306 of file kbperf.cpp.

References baseDpiIdx(), dpiOn, and SNIPER.

Referenced by KeyAction::keyEvent().

306  {
307  int idx = baseDpiIdx();
308  do {
309  idx--;
310  if(idx <= SNIPER)
311  return;
312  } while(!dpiOn[idx]);
313  baseDpiIdx(idx);
314 }
bool dpiOn[DPI_COUNT]
Definition: kbperf.h:144
int baseDpiIdx() const
Definition: kbperf.h:61
static const int SNIPER
Definition: kbperf.h:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool KbPerf::dpiEnabled ( int  index) const
inline

Definition at line 68 of file kbperf.h.

References dpiOn.

Referenced by MPerfWidget::enableChanged(), Kb::readNotify(), and MPerfWidget::setPerf().

68 { return dpiOn[index]; }
bool dpiOn[DPI_COUNT]
Definition: kbperf.h:144

+ Here is the caller graph for this function:

void KbPerf::dpiEnabled ( int  index,
bool  newEnabled 
)
inline

Definition at line 69 of file kbperf.h.

References _needsSave, _needsUpdate, and dpiOn.

69 { if(index <= 0) return; dpiOn[index] = newEnabled; _needsUpdate = _needsSave = true; }
bool _needsUpdate
Definition: kbperf.h:166
bool dpiOn[DPI_COUNT]
Definition: kbperf.h:144
bool _needsSave
Definition: kbperf.h:166
bool KbPerf::dpiIndicator ( ) const
inline

Definition at line 82 of file kbperf.h.

References _dpiIndicator.

Referenced by MPerfWidget::on_indicBox_clicked(), and MPerfWidget::setPerf().

82 { return _dpiIndicator; }
bool _dpiIndicator
Definition: kbperf.h:160

+ Here is the caller graph for this function:

void KbPerf::dpiIndicator ( bool  newDpiIndicator)
inline

Definition at line 83 of file kbperf.h.

References _dpiIndicator, and _needsSave.

83 { _dpiIndicator = newDpiIndicator; _needsSave = true; }
bool _needsSave
Definition: kbperf.h:166
bool _dpiIndicator
Definition: kbperf.h:160
void KbPerf::dpiUp ( )

Definition at line 295 of file kbperf.cpp.

References baseDpiIdx(), DPI_COUNT, and dpiOn.

Referenced by KeyAction::keyEvent().

295  {
296  // Scroll past disabled DPIs and choose the next one up
297  int idx = baseDpiIdx();
298  do {
299  idx++;
300  if(idx >= DPI_COUNT)
301  return;
302  } while(!dpiOn[idx]);
303  baseDpiIdx(idx);
304 }
bool dpiOn[DPI_COUNT]
Definition: kbperf.h:144
static const int DPI_COUNT
Definition: kbperf.h:46
int baseDpiIdx() const
Definition: kbperf.h:61

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void KbPerf::getIndicator ( indicator  index,
QColor &  color1,
QColor &  color2,
QColor &  color3,
bool &  software_enable,
i_hw hardware_enable 
)

Definition at line 341 of file kbperf.cpp.

References HW_IMAX, hwIType, I_COUNT, iColor, iEnable, LIGHT, light100Color, MUTE, muteNAColor, and NONE.

Referenced by KPerfWidget::setPerf().

341  {
342  if(index < 0 || index >= I_COUNT)
343  return;
344  color1 = iColor[index][0];
345  color2 = iColor[index][1];
346  if(index == LIGHT)
347  color3 = light100Color;
348  else if(index == MUTE)
349  color3 = muteNAColor;
350  else
351  color3 = QColor();
352  software_enable = iEnable[index];
353  hardware_enable = (index <= HW_IMAX ? hwIType[index] : NONE);
354 }
QColor light100Color
Definition: kbperf.h:157
bool iEnable[I_COUNT]
Definition: kbperf.h:158
i_hw hwIType[HW_I_COUNT]
Definition: kbperf.h:159
QColor muteNAColor
Definition: kbperf.h:157
QColor iColor[I_COUNT][2]
Definition: kbperf.h:156
static const int I_COUNT
Definition: kbperf.h:107

+ Here is the caller graph for this function:

float KbPerf::iOpacity ( ) const
inline

Definition at line 79 of file kbperf.h.

References _iOpacity.

Referenced by KPerfWidget::on_intensityBox_valueChanged(), MPerfWidget::on_spinBox_valueChanged(), KPerfWidget::setPerf(), and MPerfWidget::setPerf().

79 { return _iOpacity; }
float _iOpacity
Definition: kbperf.h:155

+ Here is the caller graph for this function:

void KbPerf::iOpacity ( float  newIOpacity)
inline

Definition at line 80 of file kbperf.h.

References _iOpacity, and _needsSave.

80 { _iOpacity = newIOpacity; _needsSave = true; }
float _iOpacity
Definition: kbperf.h:155
bool _needsSave
Definition: kbperf.h:166
height KbPerf::liftHeight ( ) const
inline

Definition at line 38 of file kbperf.h.

References _liftHeight.

Referenced by MPerfWidget::on_lHeightBox_activated(), Kb::readNotify(), and MPerfWidget::setPerf().

38 { return _liftHeight; }
height _liftHeight
Definition: kbperf.h:163

+ Here is the caller graph for this function:

void KbPerf::liftHeight ( height  newHeight)

Definition at line 373 of file kbperf.cpp.

References _liftHeight, _needsSave, _needsUpdate, and HIGH.

373  {
374  if(newHeight < LOW || newHeight > HIGH)
375  return;
376  _liftHeight = newHeight;
377  _needsUpdate = _needsSave = true;
378 }
bool _needsUpdate
Definition: kbperf.h:166
height _liftHeight
Definition: kbperf.h:163
bool _needsSave
Definition: kbperf.h:166
KbLight * KbPerf::light ( ) const
private

Definition at line 102 of file kbperf.cpp.

References KbMode::light(), and modeParent().

Referenced by applyIndicators(), and lightIndicator().

102  {
103  return modeParent()->light();
104 }
KbLight * light()
Definition: kbmode.h:60
KbMode * modeParent() const
Definition: kbperf.h:127

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void KbPerf::lightIndicator ( const char *  name,
QRgb  rgba 
)
private

Definition at line 432 of file kbperf.cpp.

References _iOpacity, light(), and KbLight::setIndicator().

Referenced by applyIndicators().

432  {
433  int a = round(qAlpha(rgba) * _iOpacity);
434  if(a <= 0)
435  return;
436  light()->setIndicator(name, qRgba(qRed(rgba), qGreen(rgba), qBlue(rgba), a));
437 }
float _iOpacity
Definition: kbperf.h:155
void setIndicator(const char *name, QRgb argb)
Definition: kblight.cpp:259
KbLight * light() const
Definition: kbperf.cpp:102

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void KbPerf::load ( CkbSettings settings)

Definition at line 106 of file kbperf.cpp.

References _angleSnap, _curDpi(), _dpiIndicator, _iOpacity, _liftHeight, _needsSave, CkbSettings::contains(), CkbSettings::containsGroup(), didLoad(), dpi(), DPI_COUNT, dpiBaseIdx, dpiClr, dpiOn, dpiX, dpiY, HIGH, HW_IMAX, hwIType, I_COUNT, iColor, iEnable, LIGHT, light100Color, LOCK, MACRO, MEDIUM, MODE, MUTE, muteNAColor, NORMAL, OTHER, pushedDpis, runningPushIdx, and CkbSettings::value().

Referenced by KbMode::KbMode().

106  {
107  pushedDpis.clear();
108  runningPushIdx = 1;
109  _needsSave = false;
110  bool readIndicators = true;
111  if(!settings.containsGroup("Performance/Indicators")){
112  // Read old indicator settings from the lighting group, if present
113  // (ckb <= v0.2.0)
114  SGroup group(settings, "Lighting");
115  if(settings.contains("InactiveIndicators")){
116  bool inOk = false;
117  int inactive = settings.value("InactiveIndicators").toInt(&inOk);
118  if(!inOk || inactive > 2)
119  inactive = 2;
120  if(inactive == 1)
121  _iOpacity = 0.75f;
122  else if(inactive == 0)
123  _iOpacity = 0.5f;
124  else if(inactive < 0){
125  // Indicators disabled
126  iEnable[MODE] = iEnable[MACRO] = iEnable[LIGHT] = iEnable[LOCK] = iEnable[MUTE] = false;
127  }
128  bool showMute = (settings.value("ShowMute").toInt(&inOk) != 0);
129  if(inOk && !showMute)
130  iEnable[MUTE] = false;
131  readIndicators = false;
132  }
133  }
134  SGroup group(settings, "Performance");
135  // Read DPI settings
136  {
137  SGroup group(settings, "DPI");
138  for(int i = 0; i < DPI_COUNT; i++){
139  QString iStr = QString::number(i);
140  QPoint value = settings.value(iStr).toPoint();
141  if(value.isNull())
142  continue;
143  dpiX[i] = value.x(); dpiY[i] = value.y();
144  QColor color = settings.value(iStr + "RGB").toString();
145  if(color.isValid())
146  dpiClr[i] = color;
147  if(i != 0)
148  dpiOn[i] = !settings.value(iStr + "Disabled").toBool();
149  }
150  QColor color = settings.value("6RGB").toString();
151  if(color.isValid())
152  dpiClr[OTHER] = color;
153  if (settings.contains("CurIdx")) {
154  dpiBaseIdx = settings.value("CurIdx").toInt();
155  } else {
156  // If there isn't a setting for current DPI stage, pick the first
157  // enabled one. Failing that just pick stage 1.
158  dpiBaseIdx = 1;
159  for (int i = 1; i < DPI_COUNT; i++) {
160  if (dpiOn[i]) {
161  dpiBaseIdx = i;
162  break;
163  }
164  }
165  }
167  }
168  // Read misc. mouse settings
169  _liftHeight = (height)settings.value("LiftHeight").toInt();
170  if(_liftHeight < LOW || _liftHeight > HIGH)
172  _angleSnap = settings.value("AngleSnap").toBool();
173  if(settings.contains("NoIndicator")){
174  // ckb <= v0.2.0
175  _dpiIndicator = !settings.value("NoIndicator").toBool();
176  } else {
177  _dpiIndicator = settings.value("Indicators/DPI", true).toBool();
178  }
179  // Read indicator settings
180  if(readIndicators){
181  SGroup group(settings, "Indicators");
182  _iOpacity = settings.value("Opacity", 100).toInt() / 100.f;
183  for(int i = 0; i < I_COUNT; i++){
184  SGroup group(settings, QString::number(i));
185  QColor color = settings.value("RGB0").toString();
186  if(color.isValid())
187  iColor[i][0] = color;
188  color = settings.value("RGB1").toString();
189  if(color.isValid())
190  iColor[i][1] = color;
191  if(i == LIGHT){
192  color = settings.value("RGB2").toString();
193  if(color.isValid())
194  light100Color = color;
195  } else if(i == MUTE){
196  color = settings.value("RGB2").toString();
197  if(color.isValid())
198  muteNAColor = color;
199  }
200  if(i <= HW_IMAX){
201  iEnable[i] = settings.value("Enable", false).toBool();
202  hwIType[i] = (i_hw)settings.value("Hardware", (int)NORMAL).toInt();
203  } else {
204  iEnable[i] = settings.value("Enable", true).toBool();
205  }
206  }
207  }
208  emit didLoad();
209 }
void _curDpi(const QPoint &newDpi)
Definition: kbperf.cpp:259
int dpiBaseIdx
Definition: kbperf.h:142
QColor light100Color
Definition: kbperf.h:157
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
uint runningPushIdx
Definition: kbperf.h:149
bool iEnable[I_COUNT]
Definition: kbperf.h:158
bool contains(const QString &key) const
bool dpiOn[DPI_COUNT]
Definition: kbperf.h:144
i_hw hwIType[HW_I_COUNT]
Definition: kbperf.h:159
QMap< quint64, QPoint > pushedDpis
Definition: kbperf.h:148
float _iOpacity
Definition: kbperf.h:155
height _liftHeight
Definition: kbperf.h:163
bool containsGroup(const QString &group)
height
Definition: kbperf.h:31
void didLoad()
Definition: moc_kbperf.cpp:134
QPoint dpi(int index) const
Definition: kbperf.h:50
bool _needsSave
Definition: kbperf.h:166
static const int DPI_COUNT
Definition: kbperf.h:46
QColor muteNAColor
Definition: kbperf.h:157
bool _angleSnap
Definition: kbperf.h:164
int dpiY[DPI_COUNT]
Definition: kbperf.h:136
QColor dpiClr[DPI_COUNT+1]
Definition: kbperf.h:143
QColor iColor[I_COUNT][2]
Definition: kbperf.h:156
i_hw
Definition: kbperf.h:101
int dpiX[DPI_COUNT]
Definition: kbperf.h:135
static const int OTHER
Definition: kbperf.h:84
bool _dpiIndicator
Definition: kbperf.h:160
static const int I_COUNT
Definition: kbperf.h:107

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

KbMode* KbPerf::modeParent ( ) const
inlineprivate

Definition at line 127 of file kbperf.h.

Referenced by bind(), and light().

127 { return (KbMode*)parent(); }
Definition: kbmode.h:36

+ Here is the caller graph for this function:

bool KbPerf::needsSave ( ) const
inline

Definition at line 28 of file kbperf.h.

References _needsSave.

Referenced by KbMode::needsSave().

28 { return _needsSave; }
bool _needsSave
Definition: kbperf.h:166

+ Here is the caller graph for this function:

const KbPerf & KbPerf::operator= ( const KbPerf rhs)

Definition at line 77 of file kbperf.cpp.

References _angleSnap, _curDpi(), _dpiIndicator, _iOpacity, _liftHeight, _needsSave, _needsUpdate, dpi(), DPI_COUNT, dpiBaseIdx, dpiClr, dpiCurX, dpiCurY, dpiOn, dpiX, dpiY, hwIType, I_COUNT, iColor, iEnable, light100Color, muteNAColor, and runningPushIdx.

77  {
78  dpiCurX = other.dpiCurX; dpiCurY = other.dpiCurY; dpiBaseIdx = other.dpiBaseIdx; runningPushIdx = 1;
79  _iOpacity = other._iOpacity; light100Color = other.light100Color; muteNAColor = other.muteNAColor; _dpiIndicator = other._dpiIndicator;
80  _liftHeight = other._liftHeight; _angleSnap = other._angleSnap;
81  _needsUpdate = true; _needsSave = true;
82  memcpy(dpiX, other.dpiX, sizeof(dpiX));
83  memcpy(dpiY, other.dpiY, sizeof(dpiY));
84  for(int i = 0; i < DPI_COUNT + 1; i++)
85  dpiClr[i] = other.dpiClr[i];
86  memcpy(dpiOn, other.dpiOn, sizeof(dpiOn));
87  for(int i = 0; i < I_COUNT; i++){
88  iColor[i][0] = other.iColor[i][0];
89  iColor[i][1] = other.iColor[i][1];
90  }
91  memcpy(iEnable, other.iEnable, sizeof(iEnable));
92  memcpy(hwIType, other.hwIType, sizeof(hwIType));
93  // Don't copy pushed DPI states. If the other mode has any, restore the original DPI
95  return other;
96 }
bool _needsUpdate
Definition: kbperf.h:166
void _curDpi(const QPoint &newDpi)
Definition: kbperf.cpp:259
int dpiBaseIdx
Definition: kbperf.h:142
int dpiCurY
Definition: kbperf.h:138
QColor light100Color
Definition: kbperf.h:157
uint runningPushIdx
Definition: kbperf.h:149
bool iEnable[I_COUNT]
Definition: kbperf.h:158
bool dpiOn[DPI_COUNT]
Definition: kbperf.h:144
i_hw hwIType[HW_I_COUNT]
Definition: kbperf.h:159
float _iOpacity
Definition: kbperf.h:155
height _liftHeight
Definition: kbperf.h:163
QPoint dpi(int index) const
Definition: kbperf.h:50
bool _needsSave
Definition: kbperf.h:166
static const int DPI_COUNT
Definition: kbperf.h:46
QColor muteNAColor
Definition: kbperf.h:157
bool _angleSnap
Definition: kbperf.h:164
int dpiY[DPI_COUNT]
Definition: kbperf.h:136
int dpiCurX
Definition: kbperf.h:138
QColor dpiClr[DPI_COUNT+1]
Definition: kbperf.h:143
QColor iColor[I_COUNT][2]
Definition: kbperf.h:156
int dpiX[DPI_COUNT]
Definition: kbperf.h:135
bool _dpiIndicator
Definition: kbperf.h:160
static const int I_COUNT
Definition: kbperf.h:107

+ Here is the call graph for this function:

void KbPerf::popDpi ( quint64  pushIdx)

Definition at line 281 of file kbperf.cpp.

References _curDpi(), _needsSave, _needsUpdate, dpi(), dpiBaseIdx, map_last, and pushedDpis.

Referenced by KeyAction::keyEvent().

281  {
282  if(!pushedDpis.contains(pushIdx)) {
283  return;
284  }
285  pushedDpis.remove(pushIdx);
286  if (pushedDpis.isEmpty()) {
288  } else {
289  // Set the DPI to the last-pushed value still on the stack
291  }
292  _needsUpdate = _needsSave = true;
293 }
bool _needsUpdate
Definition: kbperf.h:166
void _curDpi(const QPoint &newDpi)
Definition: kbperf.cpp:259
int dpiBaseIdx
Definition: kbperf.h:142
#define map_last(map)
Definition: kbperf.cpp:8
QMap< quint64, QPoint > pushedDpis
Definition: kbperf.h:148
QPoint dpi(int index) const
Definition: kbperf.h:50
bool _needsSave
Definition: kbperf.h:166

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

quint64 KbPerf::pushDpi ( const QPoint &  newDpi)

Definition at line 274 of file kbperf.cpp.

References _curDpi(), pushedDpis, and runningPushIdx.

Referenced by KeyAction::keyEvent(), and pushSniper().

274  {
275  quint64 index = runningPushIdx++;
276  pushedDpis[index] = newDpi;
277  _curDpi(newDpi);
278  return index;
279 }
void _curDpi(const QPoint &newDpi)
Definition: kbperf.cpp:259
uint runningPushIdx
Definition: kbperf.h:149
QMap< quint64, QPoint > pushedDpis
Definition: kbperf.h:148

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

quint64 KbPerf::pushDpi ( int  newDpi)
inline

Definition at line 74 of file kbperf.h.

References pushDpi().

Referenced by pushDpi().

74 { return pushDpi(QPoint(newDpi, newDpi)); }
quint64 pushDpi(const QPoint &newDpi)
Definition: kbperf.cpp:274

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

quint64 KbPerf::pushSniper ( )
inline

Definition at line 75 of file kbperf.h.

References pushDpi(), and sniperDpi().

Referenced by KeyAction::keyEvent().

75 { return pushDpi(sniperDpi()); }
QPoint sniperDpi() const
Definition: kbperf.h:52
quint64 pushDpi(const QPoint &newDpi)
Definition: kbperf.cpp:274

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void KbPerf::save ( CkbSettings settings)

Definition at line 211 of file kbperf.cpp.

References _angleSnap, _dpiIndicator, _liftHeight, _needsSave, DPI_COUNT, dpiBaseIdx, dpiClr, dpiOn, dpiX, dpiY, HW_IMAX, hwIType, I_COUNT, iColor, iEnable, LIGHT, light100Color, MUTE, muteNAColor, OTHER, and CkbSettings::setValue().

Referenced by KbMode::save().

211  {
212  _needsSave = false;
213  SGroup group(settings, "Performance");
214  {
215  SGroup group(settings, "DPI");
216  for(int i = 0; i < DPI_COUNT; i++){
217  QString iStr = QString::number(i);
218  settings.setValue(iStr, QPoint(dpiX[i], dpiY[i]));
219  settings.setValue(iStr + "RGB", dpiClr[i].name(QColor::HexArgb));
220  if(i != 0)
221  settings.setValue(iStr + "Disabled", !dpiOn[i]);
222  }
223  settings.setValue("6RGB", dpiClr[OTHER].name(QColor::HexArgb));
224  // Ignore pushed modes when saving current DPI.
225  settings.setValue("CurIdx", dpiBaseIdx);
226  }
227  settings.setValue("LiftHeight", _liftHeight);
228  settings.setValue("AngleSnap", _angleSnap);
229  {
230  SGroup group(settings, "Indicators");
231  settings.setValue("DPI", _dpiIndicator);
232  for(int i = 0; i < I_COUNT; i++){
233  SGroup group(settings, QString::number(i));
234  settings.setValue("RGB0", iColor[i][0].name(QColor::HexArgb));
235  settings.setValue("RGB1", iColor[i][1].name(QColor::HexArgb));
236  if(i == LIGHT)
237  settings.setValue("RGB2", light100Color.name(QColor::HexArgb));
238  else if(i == MUTE)
239  settings.setValue("RGB2", muteNAColor.name(QColor::HexArgb));
240  settings.setValue("Enable", iEnable[i]);
241  if(i <= HW_IMAX)
242  settings.setValue("Hardware", (int)hwIType[i]);
243  }
244  }
245 }
void setValue(const QString &key, const QVariant &value)
int dpiBaseIdx
Definition: kbperf.h:142
QColor light100Color
Definition: kbperf.h:157
bool iEnable[I_COUNT]
Definition: kbperf.h:158
bool dpiOn[DPI_COUNT]
Definition: kbperf.h:144
i_hw hwIType[HW_I_COUNT]
Definition: kbperf.h:159
height _liftHeight
Definition: kbperf.h:163
bool _needsSave
Definition: kbperf.h:166
static const int DPI_COUNT
Definition: kbperf.h:46
QColor muteNAColor
Definition: kbperf.h:157
bool _angleSnap
Definition: kbperf.h:164
int dpiY[DPI_COUNT]
Definition: kbperf.h:136
QColor dpiClr[DPI_COUNT+1]
Definition: kbperf.h:143
QColor iColor[I_COUNT][2]
Definition: kbperf.h:156
int dpiX[DPI_COUNT]
Definition: kbperf.h:135
static const int OTHER
Definition: kbperf.h:84
bool _dpiIndicator
Definition: kbperf.h:160
static const int I_COUNT
Definition: kbperf.h:107

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void KbPerf::setIndicator ( indicator  index,
const QColor &  color1,
const QColor &  color2,
const QColor &  color3 = QColor(),
bool  software_enable = true,
i_hw  hardware_enable = NORMAL 
)

Definition at line 356 of file kbperf.cpp.

References _needsSave, _needsUpdate, HW_IMAX, hwIType, I_COUNT, iColor, iEnable, LIGHT, light100Color, MUTE, muteNAColor, NONE, and NORMAL.

Referenced by KPerfWidget::uiUpdated().

356  {
357  if(index < 0 || index >= I_COUNT)
358  return;
359  iColor[index][0] = color1;
360  iColor[index][1] = color2;
361  if(index == LIGHT)
362  light100Color = color3;
363  else if(index == MUTE)
364  muteNAColor = color3;
365  iEnable[index] = software_enable;
366  if(hardware_enable == NONE)
367  hardware_enable = NORMAL;
368  if(index <= HW_IMAX)
369  hwIType[index] = hardware_enable;
370  _needsUpdate = _needsSave = true;
371 }
bool _needsUpdate
Definition: kbperf.h:166
QColor light100Color
Definition: kbperf.h:157
bool iEnable[I_COUNT]
Definition: kbperf.h:158
i_hw hwIType[HW_I_COUNT]
Definition: kbperf.h:159
bool _needsSave
Definition: kbperf.h:166
QColor muteNAColor
Definition: kbperf.h:157
QColor iColor[I_COUNT][2]
Definition: kbperf.h:156
static const int I_COUNT
Definition: kbperf.h:107

+ Here is the caller graph for this function:

void KbPerf::setNeedsUpdate ( )
inline

Definition at line 116 of file kbperf.h.

References _needsUpdate.

Referenced by KbMode::setNeedsUpdate().

116 { _needsUpdate = true; }
bool _needsUpdate
Definition: kbperf.h:166

+ Here is the caller graph for this function:

void KbPerf::settingsUpdated ( )
signal

Definition at line 140 of file moc_kbperf.cpp.

Referenced by update().

141 {
142  QMetaObject::activate(this, &staticMetaObject, 1, Q_NULLPTR);
143 }

+ Here is the caller graph for this function:

QPoint KbPerf::sniperDpi ( ) const
inline

Definition at line 52 of file kbperf.h.

References dpi(), and SNIPER.

Referenced by pushSniper().

52 { return dpi(SNIPER); }
QPoint dpi(int index) const
Definition: kbperf.h:50
static const int SNIPER
Definition: kbperf.h:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void KbPerf::sniperDpi ( const QPoint &  newValue)
inline

Definition at line 53 of file kbperf.h.

References dpi(), and SNIPER.

53 { dpi(SNIPER, newValue); }
QPoint dpi(int index) const
Definition: kbperf.h:50
static const int SNIPER
Definition: kbperf.h:46

+ Here is the call graph for this function:

void KbPerf::sniperDpi ( int  newValue)
inline

Definition at line 56 of file kbperf.h.

References sniperDpi().

Referenced by sniperDpi().

56 { sniperDpi(QPoint(newValue, newValue)); }
QPoint sniperDpi() const
Definition: kbperf.h:52

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void KbPerf::update ( QFile &  cmd,
int  notifyNumber,
bool  force,
bool  saveCustomDpi 
)

Definition at line 385 of file kbperf.cpp.

References _angleSnap, _liftHeight, _needsUpdate, DPI_COUNT, dpiBaseIdx, dpiColor(), dpiCurX, dpiCurY, dpiOn, dpiX, dpiY, HW_I_COUNT, hwIType, OFF, ON, pushedDpis, and settingsUpdated().

Referenced by Kb::frameUpdate(), and Kb::hwSave().

385  {
386  if(!force && !_needsUpdate)
387  return;
388  emit settingsUpdated();
389  _needsUpdate = false;
390  // Save DPI stage 0 (sniper)
391  // If the mouse is set to a custom DPI, save it in stage 0
392  int stage = pushedDpis.isEmpty() ? dpiBaseIdx : 0;
393  if(!pushedDpis.isEmpty() && saveCustomDpi) {
394  cmd.write(QString("dpi 0:%1,%2").arg(dpiCurX).arg(dpiCurY).toLatin1());
395  } else {
396  // Otherwise, save stage 0 normally
397  cmd.write(QString("dpi 0:%1,%2").arg(dpiX[0]).arg(dpiY[0]).toLatin1());
398  }
399  // Save stages 1 - 5
400  for(int i = 1; i < DPI_COUNT; i++){
401  if(!dpiOn[i] && stage != i)
402  cmd.write(QString(" %1:off").arg(i).toLatin1());
403  else
404  cmd.write(QString(" %1:%2,%3").arg(i).arg(dpiX[i]).arg(dpiY[i]).toLatin1());
405  }
406  // Save stage selection, lift height, and angle snap
407  cmd.write(QString(" dpisel %1 lift %2 snap %3").arg(stage).arg(_liftHeight).arg(_angleSnap ? "on" : "off").toLatin1());
408  // Save DPI colors
409  cmd.write(" rgb");
410  for(int i = 0; i < DPI_COUNT; i++){
411  QColor color = dpiColor(i);
412  cmd.write(" dpi");
413  char output[9];
414  snprintf(output, sizeof(output), "%1d:%02x%02x%02x", i, color.red(), color.green(), color.blue());
415  cmd.write(output);
416  }
417  // Enable indicator notifications
418  cmd.write(QString("\n@%1 inotify all").arg(notifyNumber).toLatin1());
419  // Set indicator state
420  const char* iNames[HW_I_COUNT] = { "num", "caps", "scroll" };
421  for(int i = 0; i < HW_I_COUNT; i++){
422  if(hwIType[i] == ON)
423  cmd.write(" ion ");
424  else if(hwIType[i] == OFF)
425  cmd.write(" ioff ");
426  else
427  cmd.write(" iauto ");
428  cmd.write(iNames[i]);
429  }
430 }
static const int HW_I_COUNT
Definition: kbperf.h:107
bool _needsUpdate
Definition: kbperf.h:166
int dpiBaseIdx
Definition: kbperf.h:142
int dpiCurY
Definition: kbperf.h:138
cmd
Definition: command.h:7
QColor dpiColor(int index) const
Definition: kbperf.h:85
bool dpiOn[DPI_COUNT]
Definition: kbperf.h:144
i_hw hwIType[HW_I_COUNT]
Definition: kbperf.h:159
QMap< quint64, QPoint > pushedDpis
Definition: kbperf.h:148
height _liftHeight
Definition: kbperf.h:163
static const int DPI_COUNT
Definition: kbperf.h:46
bool _angleSnap
Definition: kbperf.h:164
int dpiY[DPI_COUNT]
Definition: kbperf.h:136
int dpiCurX
Definition: kbperf.h:138
void settingsUpdated()
Definition: moc_kbperf.cpp:140
int dpiX[DPI_COUNT]
Definition: kbperf.h:135

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

bool KbPerf::_angleSnap
private

Definition at line 164 of file kbperf.h.

Referenced by angleSnap(), load(), operator=(), save(), and update().

bool KbPerf::_dpiIndicator
private

Definition at line 160 of file kbperf.h.

Referenced by applyIndicators(), dpiIndicator(), load(), operator=(), and save().

float KbPerf::_iOpacity
private

Definition at line 155 of file kbperf.h.

Referenced by applyIndicators(), iOpacity(), lightIndicator(), load(), and operator=().

height KbPerf::_liftHeight
private

Definition at line 163 of file kbperf.h.

Referenced by liftHeight(), load(), operator=(), save(), and update().

bool KbPerf::_needsSave
private
bool KbPerf::_needsUpdate
private
const int KbPerf::DPI_COUNT = 6
static
const int KbPerf::DPI_MAX = 12000
static

Definition at line 47 of file kbperf.h.

const int KbPerf::DPI_MIN = 100
static

Definition at line 47 of file kbperf.h.

Referenced by dpiExp(), and dpiLog().

int KbPerf::dpiBaseIdx
private

Definition at line 142 of file kbperf.h.

Referenced by baseDpiIdx(), dpi(), KbPerf(), load(), operator=(), popDpi(), save(), and update().

QColor KbPerf::dpiClr[DPI_COUNT+1]
private

Definition at line 143 of file kbperf.h.

Referenced by applyIndicators(), dpiColor(), KbPerf(), load(), operator=(), and save().

int KbPerf::dpiCurX
private

Definition at line 138 of file kbperf.h.

Referenced by _curDpi(), KbPerf(), operator=(), and update().

int KbPerf::dpiCurY
private

Definition at line 138 of file kbperf.h.

Referenced by _curDpi(), KbPerf(), operator=(), and update().

bool KbPerf::dpiOn[DPI_COUNT]
private
int KbPerf::dpiX[DPI_COUNT]
private

Definition at line 135 of file kbperf.h.

Referenced by dpi(), KbPerf(), load(), operator=(), save(), and update().

int KbPerf::dpiY[DPI_COUNT]
private

Definition at line 136 of file kbperf.h.

Referenced by dpi(), KbPerf(), load(), operator=(), save(), and update().

const int KbPerf::HW_I_COUNT = (int)HW_IMAX + 1
static

Definition at line 107 of file kbperf.h.

Referenced by KbPerf(), and update().

i_hw KbPerf::hwIType[HW_I_COUNT]
private

Definition at line 159 of file kbperf.h.

Referenced by getIndicator(), KbPerf(), load(), operator=(), save(), setIndicator(), and update().

const int KbPerf::I_COUNT = (int)MUTE + 1
static

Definition at line 107 of file kbperf.h.

Referenced by getIndicator(), KbPerf(), load(), operator=(), save(), and setIndicator().

QColor KbPerf::iColor[I_COUNT][2]
private

Definition at line 156 of file kbperf.h.

Referenced by applyIndicators(), getIndicator(), KbPerf(), load(), operator=(), save(), and setIndicator().

bool KbPerf::iEnable[I_COUNT]
private

Definition at line 158 of file kbperf.h.

Referenced by applyIndicators(), getIndicator(), KbPerf(), load(), operator=(), save(), and setIndicator().

QColor KbPerf::light100Color
private

Definition at line 157 of file kbperf.h.

Referenced by applyIndicators(), getIndicator(), KbPerf(), load(), operator=(), save(), and setIndicator().

QColor KbPerf::muteNAColor
private

Definition at line 157 of file kbperf.h.

Referenced by applyIndicators(), getIndicator(), KbPerf(), load(), operator=(), save(), and setIndicator().

const int KbPerf::OTHER = DPI_COUNT
static

Definition at line 84 of file kbperf.h.

Referenced by applyIndicators(), MPerfWidget::colorChanged(), load(), save(), and MPerfWidget::setPerf().

QMap<quint64, QPoint> KbPerf::pushedDpis
private

Definition at line 148 of file kbperf.h.

Referenced by baseDpiIdx(), dpi(), load(), popDpi(), pushDpi(), and update().

uint KbPerf::runningPushIdx
private

Definition at line 149 of file kbperf.h.

Referenced by load(), operator=(), and pushDpi().

const int KbPerf::SNIPER = 0
static

Definition at line 46 of file kbperf.h.

Referenced by dpiCycleDown(), dpiCycleUp(), dpiDown(), and sniperDpi().


The documentation for this class was generated from the following files: