-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettingsDialog.cpp
More file actions
134 lines (111 loc) · 3.95 KB
/
SettingsDialog.cpp
File metadata and controls
134 lines (111 loc) · 3.95 KB
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
#include "SettingsDialog.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QGuiApplication>
#include <QScreen>
SettingsDialog::SettingsDialog(QWidget *parent)
: QDialog(parent)
{
setWindowTitle("Settings");
QLabel *screenLabel = new QLabel("Target Monitor:");
screenCombo = new QComboBox;
screenCombo->addItem("Auto (Follow Cursor)");
const auto screens = QGuiApplication::screens();
for (int i = 0; i < screens.size(); ++i) {
const auto &s = screens[i];
screenCombo->addItem(QString("Screen %1: %2x%3").arg(i + 1).arg(s->size().width()).arg(s->size().height()));
}
QLabel *dirLabel = new QLabel("Slide Direction:");
directionCombo = new QComboBox;
directionCombo->addItems({"Left", "Right", "Top", "Bottom"});
QLabel *heightLabel = new QLabel("Window Height (%):");
heightSpin = new QSpinBox;
heightSpin->setRange(10, 100);
heightSpin->setValue(75);
QLabel *widthLabel = new QLabel("Window Width (%):");
widthSpin = new QSpinBox;
widthSpin->setRange(10, 100);
widthSpin->setValue(30);
QLabel *hotkeyLabel = new QLabel("Hotkey:");
hotkeyEdit = new QKeySequenceEdit;
QLabel *savedurLabel = new QLabel("Autosave Interval:");
autosaveSpin = new QSpinBox();
autosaveSpin->setRange(10, 3600);
autosaveSpin->setValue(60);
autosaveSpin->setSuffix(" sec");
startVisibleCheck = new QCheckBox("Show window on startup");
reopenCheck = new QCheckBox("Reopen last session");
QPushButton *okButton = new QPushButton("OK");
QPushButton *cancelButton = new QPushButton("Cancel");
connect(okButton, &QPushButton::clicked, this, &QDialog::accept);
connect(cancelButton, &QPushButton::clicked, this, &QDialog::reject);
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(screenLabel);
layout->addWidget(screenCombo);
layout->addWidget(dirLabel);
layout->addWidget(directionCombo);
layout->addWidget(heightLabel);
layout->addWidget(heightSpin);
layout->addWidget(widthLabel);
layout->addWidget(widthSpin);
layout->addWidget(hotkeyLabel);
layout->addWidget(hotkeyEdit);
layout->addWidget(savedurLabel);
layout->addWidget(autosaveSpin);
layout->addWidget(startVisibleCheck);
layout->addWidget(reopenCheck);
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->addWidget(okButton);
buttonLayout->addWidget(cancelButton);
layout->addLayout(buttonLayout);
setLayout(layout);
}
void SettingsDialog::setScreenIndex(int index) {
screenCombo->setCurrentIndex(index);
}
int SettingsDialog::screenIndex() const {
return screenCombo->currentIndex();
}
void SettingsDialog::setSlideDirection(int index) {
directionCombo->setCurrentIndex(index);
}
int SettingsDialog::slideDirection() const {
return directionCombo->currentIndex();
}
void SettingsDialog::setHeightPercent(double percent) {
heightSpin->setValue(static_cast<int>(percent));
}
double SettingsDialog::heightPercent() const {
return heightSpin->value();
}
void SettingsDialog::setWidthPercent(double percent) {
widthSpin->setValue(static_cast<int>(percent));
}
double SettingsDialog::widthPercent() const {
return widthSpin->value();
}
void SettingsDialog::setHotkeySequence(const QString &sequence) {
hotkeyEdit->setKeySequence(sequence);
}
QString SettingsDialog::hotkeySequence() const {
return hotkeyEdit->keySequence().toString();
}
void SettingsDialog::setAutosaveInterval(int seconds) {
autosaveSpin->setValue(seconds);
}
int SettingsDialog::autosaveInterval() const {
return autosaveSpin->value();
}
void SettingsDialog::setStartVisible(bool visible) {
startVisibleCheck->setChecked(visible);
}
bool SettingsDialog::startVisible() const {
return startVisibleCheck->isChecked();
}
void SettingsDialog::setReopenLastSession(bool enabled) {
reopenCheck->setChecked(enabled);
}
bool SettingsDialog::reopenLastSession() const {
return reopenCheck->isChecked();
}