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
extrasettingswidget.cpp
Go to the documentation of this file.
1 #include "extrasettingswidget.h"
3 #include "kb.h"
4 #include "mainwindow.h"
5 #include "ckbsettings.h"
6 
7 // KbLight
8 static int lastSharedDimming = -2;
9 
11  QDialog(parent),
12  ui(new Ui::ExtraSettingsWidget)
13 {
14  ui->setupUi(this);
15  CkbSettings settings("Program");
16 
17  // Read frame rate from settings
18  int rate = settings.value("framerate").toInt();
19  if(rate <= 0 || rate > 60)
20  rate = 30;
21  ui->fpsBox->setValue(rate);
22  Kb::frameRate(rate);
23  ui->fpsWarnLabel->setVisible(rate > 30);
24 
25  // Read global brightness setting (default = on, 100% brightness)
26  int dimming = settings.value("GlobalBrightness").toInt();
27  if(dimming < -1 || dimming > KbLight::MAX_DIM)
28  dimming = 0;
29  lastSharedDimming = dimming;
30  KbLight::shareDimming(dimming);
31  // Set checkbox value (-1 = don't share)
32  ui->brightnessBox->setChecked(dimming == -1);
33 
34  // Read dither
35  bool dither = settings.value("Dither").toBool();
36  Kb::dither(dither);
37  ui->ditherBox->setChecked(dither);
38 
39 #ifdef Q_OS_MACX
40  // Read OSX settings
41  bool noAccel = settings.value("DisableMouseAccel").toBool();
42  Kb::mouseAccel(!noAccel);
43  ui->mAccelBox->setChecked(noAccel);
44  bool noScrollAccel = settings.value("DisableScrollAccel").toBool();
45  int scrollSpeed = settings.value("ScrollSpeed", 3).toInt();
46  ui->sAccelBox->setChecked(noScrollAccel);
47  ui->sSpeedBox->setValue(scrollSpeed);
48  Kb::scrollSpeed(noScrollAccel ? scrollSpeed : 0);
49  if(!noScrollAccel)
50  ui->sSpeedWidget->hide();
51 #else
52  // Hide all OSX options on Linux
53  ui->osxLabel->hide();
54  ui->osxLine->hide();
55  ui->mAccelBox->hide();
56  ui->sAccelBox->hide();
57  ui->sSpeedWidget->hide();
58 #endif
59 
60  // Read tray icon setting
61  ui->trayBox->setChecked(settings.value("SuppressTrayIcon").toBool());
62 
63  // Update animation info
64  ui->animPathLabel->setText(AnimScript::path());
66 
68  bool macroDelay = settings.value("MacroDelay").toBool();
69  Kb::macroDelay(macroDelay);
70  ui->delayBox->setChecked(macroDelay);
71 }
72 
74  delete ui;
75 }
76 
78  CkbSettings::set("Program/SuppressTrayIcon", checked);
80 }
81 
83  KbLight::shareDimming(checked ? -1 : 0);
84  pollUpdates();
85 }
86 
89  int count = AnimScript::count();
90  if(count == 0)
91  ui->animCountLabel->setText("No animations found");
92  else if(count == 1)
93  ui->animCountLabel->setText("1 animation found");
94  else
95  ui->animCountLabel->setText(QString("%1 animations found").arg(count));
96 }
97 
99  // Set FPS
100  CkbSettings settings("Program");
101  settings.setValue("framerate", arg1);
102  Kb::frameRate(arg1);
103  // Show warning label if FPS is above 30
104  if(arg1 > 30)
105  ui->fpsWarnLabel->show();
106  else
107  ui->fpsWarnLabel->hide();
108 }
109 
111  CkbSettings::set("Program/Dither", checked);
112  Kb::dither(checked);
113 }
114 
116  // Check for changes to shared brightness setting
117  int dimming = KbLight::shareDimming();
118  if(dimming != lastSharedDimming && !CkbSettings::isBusy()){
119  CkbSettings::set("Program/GlobalBrightness", dimming);
120  lastSharedDimming = dimming;
121  }
122 }
123 
125  CkbSettings::set("Program/DisableMouseAccel", checked);
126  Kb::mouseAccel(!checked);
127 }
128 
130  CkbSettings::set("Program/DisableScrollAccel", checked);
131  Kb::scrollSpeed(checked ? ui->sSpeedBox->value() : 0);
132  if(checked)
133  ui->sSpeedWidget->show();
134  else
135  ui->sSpeedWidget->hide();
136 }
137 
139  CkbSettings::set("Program/ScrollSpeed", arg1);
140  Kb::scrollSpeed(ui->sAccelBox->isChecked() ? arg1 : 0);
141 }
142 
144  CkbSettings::set("Program/MacroDelay", checked);
145  Kb::macroDelay(checked);
146 }
static bool mouseAccel()
Definition: kb.h:39
void setValue(const QString &key, const QVariant &value)
static int count()
Definition: animscript.h:54
static void set(const QString &key, const QVariant &value)
static int frameRate()
Definition: kb.h:27
void on_sSpeedBox_valueChanged(int arg1)
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
static bool macroDelay()
Definition: kb.h:36
static QString path()
Definition: animscript.cpp:29
void on_mAccelBox_clicked(bool checked)
void toggleTrayIcon(bool visible)
Definition: mainwindow.cpp:150
static const int MAX_DIM
Definition: kblight.h:38
static int scrollSpeed()
Definition: kb.h:42
void setupUi(QDialog *ExtraSettingsWidget)
void on_delayBox_clicked(bool checked)
void on_ditherBox_clicked(bool checked)
void on_brightnessBox_clicked(bool checked)
static int shareDimming()
Definition: kblight.cpp:78
void on_sAccelBox_clicked(bool checked)
static bool dither()
Definition: kb.h:33
static MainWindow * mainWindow
Definition: mainwindow.h:35
void on_fpsBox_valueChanged(int arg1)
static int lastSharedDimming
static void scan()
Definition: animscript.cpp:37
ExtraSettingsWidget(QWidget *parent=0)
void on_trayBox_clicked(bool checked)
Ui::ExtraSettingsWidget * ui
static bool isBusy()
Definition: ckbsettings.cpp:42