-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettingsdialog.hpp
172 lines (159 loc) · 3.83 KB
/
settingsdialog.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#ifndef SETTINGSDIALOG_H
#define SETTINGSDIALOG_H
#define DEBUG_SETTINGS false
#include <QDialog>
#include <QLineEdit>
#include <QGridLayout>
#include <QGroupBox>
#include <QDialogButtonBox>
#include <QCheckBox>
#include <QSpinBox>
#include <QPushButton>
#include <QLabel>
#include <QSlider>
#include <QCloseEvent>
#include <QMessageBox>
#include <QRegExpValidator>
#if DEBUG_SETTINGS
#include <QDebug>
#endif
class SettingsDialog : public QWidget {
Q_OBJECT
public:
SettingsDialog(QWidget *parent = nullptr,
Qt::WindowFlags f = Qt::Window);
void sendPowerOff();
public slots:
void loadSettings();
void saveSettings();
void onOkClicked();
void onCancelClicked();
void onIpChanged(QString ip)
{
m_needsToSave = true;
if (m_ipRegex.exactMatch(ip)) {
m_ipField->setStyleSheet("");
emit changedIp(ip);
#if DEBUG_SETTINGS
qDebug() << "Changed IP to" << ip;
#endif
} else {
m_ipField->setStyleSheet("color: red");
}
};
void onPortChanged(QString port)
{
m_needsToSave = true;
if (m_portRegex.exactMatch(port)) {
m_portField->setStyleSheet("");
emit changedPort(port.toInt());
#if DEBUG_SETTINGS
qDebug() << "Changed port to" << port;
#endif
} else {
m_portField->setStyleSheet("color: red;");
}
};
void onMoveAdjChanged(int val)
{
m_needsToSave = true;
float adjustment = (float)val / 100;
emit changedMoveAdjustment(adjustment);
#if DEBUG_SETTINGS
qDebug() << "Changed move adjustment to" << adjustment;
#endif
};
void onMoveAdjWeightChanged(int val)
{
m_needsToSave = true;
float weight = (float)val / 100;
emit changedMoveAdjWeight(weight);
#if DEBUG_SETTINGS
qDebug() << "Changed move adjustment weight to"
#endif
};
void onZoomAdjChanged(int val)
{
m_needsToSave = true;
float adjustment = (float)val / 100;
emit changedZoomAdjustment(adjustment);
#if DEBUG_SETTINGS
qDebug() << "Changed move adjustment to" << adjustment;
#endif
};
void onZoomAdjWeightChanged(int val)
{
m_needsToSave = true;
float weight = (float)val / 100;
emit changedZoomAdjWeight(weight);
#if DEBUG_SETTINGS
qDebug() << "Changed zoom adjustment weight to" << weight;
#endif
};
void onDegPerZoomChanged(int val)
{
m_needsToSave = true;
emit changedDegPerZoom(val);
#if DEBUG_SETTINGS
qDebug() << "Changed scroll degrees per zoom to" << val;
#endif
};
void onZoomArcSpanChanged(int val)
{
m_needsToSave = true;
emit changedZoomArcSpan(val);
#if DEBUG_SETTINGS
qDebug() << "Changed zoom indicator degrees to" << val;
#endif
};
void onAutoPowerChanged() { m_needsToSave = true; };
void onPresetRowsChanged(int val)
{
m_needsToSave = true;
emit changedPresetRows(val);
#if DEBUG_SETTINGS
qDebug() << "Changed preset rows to" << val;
#endif
};
void onPresetColumnsChanged(int val)
{
m_needsToSave = true;
emit changedPresetColumns(val);
#if DEBUG_SETTINGS
qDebug() << "Changed preset columns to" << val;
#endif
};
signals:
void changedIp(QString ip);
void changedPort(int port);
void changedMoveAdjustment(float adjustment);
void changedMoveAdjWeight(float weight);
void changedZoomAdjustment(float adjustment);
void changedZoomAdjWeight(float weight);
void changedDegPerZoom(int degPerZoom);
void changedZoomArcSpan(int zoomArcSpan);
void autoPowerOn();
void autoPowerOff();
void changedPresetRows(int rows);
void changedPresetColumns(int columns);
protected:
void closeEvent(QCloseEvent *event) override;
private:
bool m_isInitialLoad = true;
bool m_needsToSave = false;
QRegExp m_ipRegex;
QRegExp m_portRegex;
QLineEdit *m_ipField;
QLineEdit *m_portField;
QSlider *m_moveAdjSlider;
QSlider *m_moveAdjWeightSlider;
QSlider *m_zoomAdjSlider;
QSlider *m_zoomAdjWeightSlider;
QSlider *m_degPerZoomSlider;
QSlider *m_zoomArcSpanSlider;
QCheckBox *m_autoPowerOn;
QCheckBox *m_autoPowerOff;
QSpinBox *m_presetRowsBox;
QSpinBox *m_presetColumnsBox;
};
#endif // SETTINGSDIALOG_H