-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmainwindow.cpp
338 lines (274 loc) · 14.4 KB
/
mainwindow.cpp
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QGridLayout>
#include <QGroupBox>
#include <QScrollArea>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
//this->setStyleSheet("background: #eeeeee;");
grabKeyboard();
QWidget *centralwidget = new QWidget();
QGridLayout *layout_ = new QGridLayout{};
QScrollArea *scrollA = new QScrollArea(centralwidget);
scrollA->setObjectName(QString::fromUtf8("scrollA"));
scrollA->setWidgetResizable(true);
QWidget *scrollA_contents = new QWidget();
scrollA_contents->setObjectName(QString::fromUtf8("scrollA_contents"));
QGridLayout *layout_scroll_area = new QGridLayout(scrollA_contents);
layout_scroll_area->setObjectName(QString::fromUtf8("layout_scroll_area"));
/*
* Custom Widgets
*/
QGroupBox *groupB_custom_widgets = new QGroupBox(scrollA_contents);
groupB_custom_widgets->setTitle("Custom Widgets");
groupB_custom_widgets->setObjectName(QString::fromUtf8("groupB_custom_widgets"));
QGridLayout *layout_custom_widgets = new QGridLayout{};
QLabel *labelSwipeWidget = new QLabel("Swipe Widget");
swipeWidget->setFixedSize(QSize(200,50));
layout_custom_widgets->addWidget(labelSwipeWidget, 0, 0, 1, 1);
layout_custom_widgets->addWidget(swipeWidget, 0, 1, 1, 1);
groupB_custom_widgets->setLayout(layout_custom_widgets);
/*
* Custom Text Edits
*/
QGroupBox *groupB_custom_text_edits = new QGroupBox(scrollA_contents);
groupB_custom_text_edits->setTitle("Custom Text Edits");
groupB_custom_text_edits->setObjectName(QString::fromUtf8("groupB_custom_text_edits"));
QGridLayout *layout_custom_text = new QGridLayout{};
QLabel *labelCustomTextEdit = new QLabel("Custom Text Edit");
QLabel *labelBorderedTextEdit = new QLabel("Bordered Text Edit");
QLabel *labelBorderedTextLineEdit = new QLabel("Bordered Text Line Edit");
customTextEdit->setText("This is CustomTextEdit");
customTextEdit->setToolTip("Dynamic update");
customLineEdit->setText("This is CustomLineEdit");
customLineEdit->setToolTip("Dynamic update");
borderedTextEdit->setText("This is BorderedTextEdit");
borderedTextLineEdit->setText("This is BorderedTextLineEdit");
//layout_custom_text->addWidget(labelCustomTextEdit, 0, 0, 1, 1);
//layout_custom_text->addWidget(customTextEdit, 0, 1, 1, 1);
//layout_custom_text->addWidget(labelBorderedTextEdit, 1, 0, 1, 1);
//layout_custom_text->addWidget(borderedTextEdit, 1, 1, 1, 1);
//layout_custom_text->addWidget(labelBorderedTextLineEdit, 2, 0, 1, 1);
//layout_custom_text->addWidget(borderedTextLineEdit, 2, 1, 1, 1);
groupB_custom_text_edits->setLayout(layout_custom_text);
/*
* Custom Toggles
*/
QGroupBox *groupB_custom_toggles = new QGroupBox(scrollA_contents);
groupB_custom_toggles->setTitle("Custom Toggles");
groupB_custom_toggles->setObjectName(QString::fromUtf8("groupB_custom_toggles"));
QGridLayout *layout_custom_toggles = new QGridLayout{};
delayedToggleSwitchIOS->setChecked(false);
delayedToggleSwitchAndroid->setChecked(false);
QLabel *labelToggleSwitchIOS = new QLabel("Toggle Switch (IOS)");
QLabel *labelDelayedToggleSwitchIOS = new QLabel("Delayed Toggle Switch (IOS)");
QLabel *labelToggleSwitchAndroid = new QLabel("Toggle Switch (Android)");
QLabel *labelDelayedToggleSwitchAndroid = new QLabel("Delayed Toggle Switch (Android)");
QLabel *labelToggleSwitch = new QLabel("Toggle Switch");
layout_custom_toggles->addWidget(labelToggleSwitchIOS, 0, 0, 1, 1);
layout_custom_toggles->addWidget(toggleSwitchIOS, 0, 1, 1, 1);
layout_custom_toggles->addWidget(labelDelayedToggleSwitchIOS, 1, 0, 1, 1);
layout_custom_toggles->addWidget(delayedToggleSwitchIOS, 1, 1, 1, 1);
layout_custom_toggles->addWidget(labelToggleSwitchAndroid, 2, 0, 1, 1);
layout_custom_toggles->addWidget(toggleSwitchAndroid, 2, 1, 1, 1);
layout_custom_toggles->addWidget(labelDelayedToggleSwitchAndroid, 3, 0, 1, 1);
layout_custom_toggles->addWidget(delayedToggleSwitchAndroid, 3, 1, 1, 1);
layout_custom_toggles->addWidget(labelToggleSwitch, 4, 0, 1, 1);
layout_custom_toggles->addWidget(toggleSwitch, 4, 1, 1, 1);
groupB_custom_toggles->setLayout(layout_custom_toggles);
/*
* Custom Indicators
*/
QGroupBox *groupB_custom_indicators = new QGroupBox(scrollA_contents);
groupB_custom_indicators->setTitle("Custom Indicators");
groupB_custom_indicators->setObjectName(QString::fromUtf8("groupB_custom_indicators"));
QGridLayout *layout_custom_indicators = new QGridLayout{};
classicLedIndicator->setFixedSize(QSize(30,30));
realisticLedIndicator->setFixedSize(QSize(30,30));
classicLedIndicator->setGlow(true);
realisticLedIndicator->setGlow(true);
classicLedIndicator->startColorAnimation(QColor(255,0,0), QColor(255,255,255));
realisticLedIndicator->startColorAnimation(QColor(255,0,0), QColor(255,255,255));
QLabel *labelClassicLedIndicator = new QLabel("Classic Led Indicator");
QLabel *labelRealisticLedIndicator = new QLabel("Realistic Led Indicator");
layout_custom_indicators->addWidget(labelClassicLedIndicator, 0, 0, 1, 1);
layout_custom_indicators->addWidget(classicLedIndicator, 0, 1, 1, 1);
layout_custom_indicators->addWidget(labelRealisticLedIndicator, 1, 0, 1, 1);
layout_custom_indicators->addWidget(realisticLedIndicator, 1, 1, 1, 1);
groupB_custom_indicators->setLayout(layout_custom_indicators);
/*
* Custom Labels
*/
QGroupBox *groupB_custom_labels = new QGroupBox(scrollA_contents);
groupB_custom_labels->setTitle("Custom Labels");
groupB_custom_labels->setObjectName(QString::fromUtf8("groupB_custom_labels"));
QGridLayout *layout_custom_labels = new QGridLayout{};
highlightLabel->setText("This is HighlightLabel");
dynamicTooltipLabel->setText("This is CustomLabel");
dynamicTooltipLabel->setToolTip("Dynamic update");
QLabel *labelHighlightLabel = new QLabel("Highlight Label");
QLabel *labelDynamicTooltipLabel = new QLabel("Dynamic Tooltip Label");
layout_custom_labels->addWidget(labelHighlightLabel, 0, 0, 1, 1);
layout_custom_labels->addWidget(highlightLabel, 0, 1, 1, 1);
layout_custom_labels->addWidget(labelDynamicTooltipLabel, 1, 0, 1, 1);
layout_custom_labels->addWidget(dynamicTooltipLabel, 1, 1, 1, 1);
groupB_custom_labels->setLayout(layout_custom_labels);
/*
* Custom Buttons
*/
QGroupBox *groupB_custom_buttons = new QGroupBox(scrollA_contents);
groupB_custom_buttons->setTitle("Custom Buttons");
groupB_custom_buttons->setObjectName(QString::fromUtf8("groupB_custom_buttons"));
QGridLayout *layout_custom_buttons = new QGridLayout{};
connectionButton->setFixedSize(QSize(50,50));
fireButton->setFixedSize(QSize(150,150));
panelButton->setFixedSize(QSize(100,50));
backNavigationButton->setFixedSize(QSize(170,44));
nextNavigationButton->setFixedSize(QSize(170,44));
QLabel *labelActivationButton = new QLabel("Activation Button");
QLabel *labelBadgeButton = new QLabel("Badge Button");
QLabel *labelConnectionButton = new QLabel("Connection Button");
QLabel *labelFireButton = new QLabel("Fire Button");
QLabel *labelPanelButton = new QLabel("Panel Button");
QLabel *labelFlatButton = new QLabel("Flat Button");
QLabel *labelBackNavigationButton = new QLabel("Back Button");
QLabel *labelNextNavigationButton = new QLabel("Next Button");
layout_custom_buttons->addWidget(labelActivationButton, 0, 0, 1, 1);
layout_custom_buttons->addWidget(activationButton, 0, 1, 1, 1);
layout_custom_buttons->addWidget(labelBadgeButton, 1, 0, 1, 1); // Bug in bg color after mouse click release
layout_custom_buttons->addWidget(badgeButton, 1, 1, 1, 1); // Bug in bg color after mouse click release
layout_custom_buttons->addWidget(labelConnectionButton, 2, 0, 1, 1);
layout_custom_buttons->addWidget(connectionButton, 2, 1, 1, 1);
layout_custom_buttons->addWidget(labelFireButton, 3, 0, 1, 1);
layout_custom_buttons->addWidget(fireButton, 3, 1, 1, 1);
layout_custom_buttons->addWidget(labelPanelButton, 4, 0, 1, 1);
layout_custom_buttons->addWidget(panelButton, 4, 1, 1, 1);
layout_custom_buttons->addWidget(labelFlatButton, 5, 0, 1, 1);
layout_custom_buttons->addWidget(flatButton, 5, 1, 1, 1);
layout_custom_buttons->addWidget(labelBackNavigationButton, 6, 0, 1, 1);
layout_custom_buttons->addWidget(backNavigationButton, 6, 1, 1, 1);
layout_custom_buttons->addWidget(labelNextNavigationButton, 7, 0, 1, 1);
layout_custom_buttons->addWidget(nextNavigationButton, 7, 1, 1, 1);
groupB_custom_buttons->setLayout(layout_custom_buttons);
/*
* Custom Loading Bars
*/
QGroupBox *groupB_custom_loading_bars = new QGroupBox(scrollA_contents);
groupB_custom_loading_bars->setTitle("Custom LoadingBars");
groupB_custom_loading_bars->setObjectName(QString::fromUtf8("groupB_custom_loading_bars"));
QGridLayout *layout_custom_loading_bars = new QGridLayout{};
QLabel *labelProgressBar = new QLabel("Progress Bar");
QLabel *labelCircularProgressBar = new QLabel("Circular Progress Bar");
layout_custom_loading_bars->addWidget(labelProgressBar, 0, 0, 1, 1);
layout_custom_loading_bars->addWidget(progressBar, 0, 1, 1, 1);
layout_custom_loading_bars->addWidget(labelCircularProgressBar, 1, 0, 1, 1);
layout_custom_loading_bars->addWidget(circularProgressBar, 1, 1, 1, 1);
this->progressBar->startAnimation(0, 1, 5000, -1);
this->circularProgressBar->startAnimation(0, 1, 5000, -1);
groupB_custom_loading_bars->setLayout(layout_custom_loading_bars);
layout_scroll_area->addWidget(groupB_custom_widgets, 0, 0, 1, 1);
layout_scroll_area->addWidget(groupB_custom_text_edits, 0, 1, 1, 1);
layout_scroll_area->addWidget(groupB_custom_toggles, 1, 0, 2, 1);
layout_scroll_area->addWidget(groupB_custom_indicators, 1, 1, 1, 1);
layout_scroll_area->addWidget(groupB_custom_labels, 2, 1, 1, 1);
layout_scroll_area->addWidget(groupB_custom_buttons, 3, 0, 1, 1);
layout_scroll_area->addWidget(groupB_custom_loading_bars, 3, 1, 1, 1);
scrollA->setWidget(scrollA_contents);
layout_->addWidget(scrollA);
centralwidget->setLayout(layout_);
this->setCentralWidget(centralwidget);
QObject::connect(badgeButton, SIGNAL(clicked()), this, SLOT(clickedBadgeButton()));
QObject::connect(connectionButton, SIGNAL(clicked()), this, SLOT(clickedConnectionButton()));
QObject::connect(swipeWidget, SIGNAL(locked()), this, SLOT(lockedSwipedButton()));
QObject::connect(swipeWidget, SIGNAL(unlocked()), this, SLOT(unlockedSwipedButton()));
QObject::connect(fireButton, SIGNAL(fire()), this, SLOT(fireFireButton()));
QObject::connect(panelButton, SIGNAL(clicked()), this, SLOT(clickedPanelButton()));
QObject::connect(flatButton, SIGNAL(clicked()), this, SLOT(clickedFlatButton()));
QObject::connect(toggleSwitchIOS, SIGNAL(toggled(bool)), this, SLOT(toggledSwitchIOS(bool)));
QObject::connect(delayedToggleSwitchIOS, SIGNAL(toggled(bool)), this, SLOT(toggledDelayedSwitchIOS(bool)));
QObject::connect(toggleSwitchAndroid, SIGNAL(toggled(bool)), this, SLOT(toggledSwitchAndroid(bool)));
QObject::connect(delayedToggleSwitchAndroid, SIGNAL(toggled(bool)), this, SLOT(toggledDelayedSwitchAndroid(bool)));
QObject::connect(toggleSwitch, SIGNAL(toggled(bool)), this, SLOT(toggledSwitch(bool)));
QObject::connect(nextNavigationButton, SIGNAL(toggled(bool)), this, SLOT(toggledButton(bool)));
QObject::connect(timer, SIGNAL(timeout()), this, SLOT(timeoutTimer()));
timer->setParent(this);
timer->setInterval(1000);
timer->start();
}
void MainWindow::keyPressEvent(QKeyEvent *event_){
if (event_->key() == Qt::Key_Shift)
this->fireButton->startAnimation();
};
void MainWindow::keyReleaseEvent(QKeyEvent *event_){
if (event_->key() == Qt::Key_Shift)
this->fireButton->stopAnimation();
};
void MainWindow::clickedBadgeButton() noexcept{
this->badgeButton->increaseNotifyNumber();
}
void MainWindow::clickedConnectionButton() noexcept{
if (this->connectionButton->getState() == enumConnectionButtonStates::Default){
this->connectionButton->setState(enumConnectionButtonStates::Connecting);
}
else if (this->connectionButton->getState() == enumConnectionButtonStates::Connecting){
this->connectionButton->setState(enumConnectionButtonStates::Connected);
}
else if (this->connectionButton->getState() == enumConnectionButtonStates::Connected){
this->connectionButton->setState(enumConnectionButtonStates::Disconnected);
}
else if (this->connectionButton->getState() == enumConnectionButtonStates::Disconnected){
this->connectionButton->setState(enumConnectionButtonStates::Default);
}
}
void MainWindow::lockedSwipedButton() noexcept{
qInfo("Locked!");
};
void MainWindow::unlockedSwipedButton() noexcept{
qInfo("Unlocked!");
};
void MainWindow::fireFireButton() noexcept{
qInfo("Fire!");
};
void MainWindow::clickedPanelButton() noexcept{
qInfo("Clicked!");
};
void MainWindow::clickedFlatButton() noexcept{
qInfo("Clicked!");
};
void MainWindow::toggledSwitchIOS(bool toggled) noexcept{
qInfo() << "Toggled!";
qInfo() << "Toggle Status: " + QString::number(toggled);
};
void MainWindow::toggledDelayedSwitchIOS(bool toggled) noexcept{
qInfo() << "Toggled!";
qInfo() << "Toggle Status: " + QString::number(toggled);
};
void MainWindow::toggledSwitchAndroid(bool toggled) noexcept{
qInfo() << "Toggled!";
qInfo() << "Toggle Status: " + QString::number(toggled);
};
void MainWindow::toggledDelayedSwitchAndroid(bool toggled) noexcept{
qInfo() << "Toggled!";
qInfo() << "Toggle Status: " + QString::number(toggled);
};
void MainWindow::toggledButton(bool toggled) noexcept{
qInfo() << "Toggled!";
qInfo() << "Toggle Status: " + QString::number(toggled);
};
void MainWindow::toggledSwitch(bool toggled) noexcept{
qInfo() << "Toggled!";
qInfo() << "Toggle Status: " + QString::number(toggled);
};
void MainWindow::timeoutTimer() noexcept{
qint64 msec = QDateTime::currentMSecsSinceEpoch();
dynamicTooltipLabel->setToolTip(QString::number(msec));
customTextEdit->setToolTip(QString::number(msec));
customLineEdit->setToolTip(QString::number(msec));
};
MainWindow::~MainWindow()
{
delete ui;
}