ckb-next
v0.2.8 at branch master
ckb-next driver for corsair devices
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
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
"
2
#include "
ui_extrasettingswidget.h
"
3
#include "
kb.h
"
4
#include "
mainwindow.h
"
5
#include "
ckbsettings.h
"
6
7
// KbLight
8
static
int
lastSharedDimming
= -2;
9
10
ExtraSettingsWidget::ExtraSettingsWidget
(
QWidget
*parent) :
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
());
65
on_animScanButton_clicked
();
66
68
bool
macroDelay = settings.
value
(
"MacroDelay"
).toBool();
69
Kb::macroDelay
(macroDelay);
70
ui
->
delayBox
->setChecked(macroDelay);
71
}
72
73
ExtraSettingsWidget::~ExtraSettingsWidget
(){
74
delete
ui
;
75
}
76
77
void
ExtraSettingsWidget::on_trayBox_clicked
(
bool
checked){
78
CkbSettings::set
(
"Program/SuppressTrayIcon"
, checked);
79
MainWindow::mainWindow
->
toggleTrayIcon
(!checked);
80
}
81
82
void
ExtraSettingsWidget::on_brightnessBox_clicked
(
bool
checked){
83
KbLight::shareDimming
(checked ? -1 : 0);
84
pollUpdates
();
85
}
86
87
void
ExtraSettingsWidget::on_animScanButton_clicked
(){
88
AnimScript::scan
();
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
98
void
ExtraSettingsWidget::on_fpsBox_valueChanged
(
int
arg1){
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
110
void
ExtraSettingsWidget::on_ditherBox_clicked
(
bool
checked){
111
CkbSettings::set
(
"Program/Dither"
, checked);
112
Kb::dither
(checked);
113
}
114
115
void
ExtraSettingsWidget::pollUpdates
(){
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
124
void
ExtraSettingsWidget::on_mAccelBox_clicked
(
bool
checked){
125
CkbSettings::set
(
"Program/DisableMouseAccel"
, checked);
126
Kb::mouseAccel
(!checked);
127
}
128
129
void
ExtraSettingsWidget::on_sAccelBox_clicked
(
bool
checked){
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
138
void
ExtraSettingsWidget::on_sSpeedBox_valueChanged
(
int
arg1){
139
CkbSettings::set
(
"Program/ScrollSpeed"
, arg1);
140
Kb::scrollSpeed
(
ui
->
sAccelBox
->isChecked() ? arg1 : 0);
141
}
142
143
void
ExtraSettingsWidget::on_delayBox_clicked
(
bool
checked) {
144
CkbSettings::set
(
"Program/MacroDelay"
, checked);
145
Kb::macroDelay
(checked);
146
}
Ui_ExtraSettingsWidget::mAccelBox
QCheckBox * mAccelBox
Definition:
ui_extrasettingswidget.h:70
Ui_ExtraSettingsWidget::sSpeedWidget
QWidget * sSpeedWidget
Definition:
ui_extrasettingswidget.h:71
Ui_ExtraSettingsWidget::animCountLabel
QLabel * animCountLabel
Definition:
ui_extrasettingswidget.h:57
Kb::mouseAccel
static bool mouseAccel()
Definition:
kb.h:39
CkbSettings::setValue
void setValue(const QString &key, const QVariant &value)
Definition:
ckbsettings.cpp:131
AnimScript::count
static int count()
Definition:
animscript.h:54
CkbSettings::set
static void set(const QString &key, const QVariant &value)
Definition:
ckbsettings.cpp:166
Ui_ExtraSettingsWidget::ditherBox
QCheckBox * ditherBox
Definition:
ui_extrasettingswidget.h:66
ckbsettings.h
QDialog
Kb::frameRate
static int frameRate()
Definition:
kb.h:27
ExtraSettingsWidget::on_sSpeedBox_valueChanged
void on_sSpeedBox_valueChanged(int arg1)
Definition:
extrasettingswidget.cpp:138
ui_extrasettingswidget.h
Ui_ExtraSettingsWidget::sSpeedBox
QSpinBox * sSpeedBox
Definition:
ui_extrasettingswidget.h:74
QWidget
CkbSettings::value
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
Definition:
ckbsettings.cpp:126
Kb::macroDelay
static bool macroDelay()
Definition:
kb.h:36
AnimScript::path
static QString path()
Definition:
animscript.cpp:29
ExtraSettingsWidget::on_mAccelBox_clicked
void on_mAccelBox_clicked(bool checked)
Definition:
extrasettingswidget.cpp:124
ExtraSettingsWidget::~ExtraSettingsWidget
~ExtraSettingsWidget()
Definition:
extrasettingswidget.cpp:73
MainWindow::toggleTrayIcon
void toggleTrayIcon(bool visible)
Definition:
mainwindow.cpp:150
Ui_ExtraSettingsWidget::brightnessBox
QCheckBox * brightnessBox
Definition:
ui_extrasettingswidget.h:59
Ui_ExtraSettingsWidget::sAccelBox
QCheckBox * sAccelBox
Definition:
ui_extrasettingswidget.h:48
KbLight::MAX_DIM
static const int MAX_DIM
Definition:
kblight.h:38
Kb::scrollSpeed
static int scrollSpeed()
Definition:
kb.h:42
Ui_ExtraSettingsWidget::setupUi
void setupUi(QDialog *ExtraSettingsWidget)
Definition:
ui_extrasettingswidget.h:78
ExtraSettingsWidget::on_delayBox_clicked
void on_delayBox_clicked(bool checked)
Definition:
extrasettingswidget.cpp:143
Ui_ExtraSettingsWidget::animPathLabel
QLabel * animPathLabel
Definition:
ui_extrasettingswidget.h:56
ExtraSettingsWidget::on_ditherBox_clicked
void on_ditherBox_clicked(bool checked)
Definition:
extrasettingswidget.cpp:110
ExtraSettingsWidget::on_brightnessBox_clicked
void on_brightnessBox_clicked(bool checked)
Definition:
extrasettingswidget.cpp:82
KbLight::shareDimming
static int shareDimming()
Definition:
kblight.cpp:78
mainwindow.h
Ui_ExtraSettingsWidget::fpsBox
QSpinBox * fpsBox
Definition:
ui_extrasettingswidget.h:42
ExtraSettingsWidget::on_sAccelBox_clicked
void on_sAccelBox_clicked(bool checked)
Definition:
extrasettingswidget.cpp:129
kb.h
Kb::dither
static bool dither()
Definition:
kb.h:33
MainWindow::mainWindow
static MainWindow * mainWindow
Definition:
mainwindow.h:35
ExtraSettingsWidget::pollUpdates
void pollUpdates()
Definition:
extrasettingswidget.cpp:115
ExtraSettingsWidget::on_fpsBox_valueChanged
void on_fpsBox_valueChanged(int arg1)
Definition:
extrasettingswidget.cpp:98
lastSharedDimming
static int lastSharedDimming
Definition:
extrasettingswidget.cpp:8
AnimScript::scan
static void scan()
Definition:
animscript.cpp:37
Ui_ExtraSettingsWidget::delayBox
QCheckBox * delayBox
Definition:
ui_extrasettingswidget.h:67
ExtraSettingsWidget::ExtraSettingsWidget
ExtraSettingsWidget(QWidget *parent=0)
Definition:
extrasettingswidget.cpp:10
ExtraSettingsWidget::on_animScanButton_clicked
void on_animScanButton_clicked()
Definition:
extrasettingswidget.cpp:87
CkbSettings
Definition:
ckbsettings.h:11
Ui_ExtraSettingsWidget::osxLine
QFrame * osxLine
Definition:
ui_extrasettingswidget.h:69
ExtraSettingsWidget::on_trayBox_clicked
void on_trayBox_clicked(bool checked)
Definition:
extrasettingswidget.cpp:77
ExtraSettingsWidget
Definition:
extrasettingswidget.h:10
Ui_ExtraSettingsWidget::fpsWarnLabel
QLabel * fpsWarnLabel
Definition:
ui_extrasettingswidget.h:39
ExtraSettingsWidget::ui
Ui::ExtraSettingsWidget * ui
Definition:
extrasettingswidget.h:33
extrasettingswidget.h
Ui_ExtraSettingsWidget::osxLabel
QLabel * osxLabel
Definition:
ui_extrasettingswidget.h:68
Ui_ExtraSettingsWidget::trayBox
QCheckBox * trayBox
Definition:
ui_extrasettingswidget.h:60
CkbSettings::isBusy
static bool isBusy()
Definition:
ckbsettings.cpp:42
src
ckb
extrasettingswidget.cpp
Generated on Sat Jan 20 2018 16:59:28 for ckb-next by
1.8.6