-
Notifications
You must be signed in to change notification settings - Fork 7
/
settings.cpp
177 lines (140 loc) · 5.45 KB
/
settings.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
#include "settings.h"
#include "ui_settings.h"
#include <QSettings>
#include <QFileDialog>
#include "mainwindow.h"
Settings::Settings(QWidget *parent) :
QDialog(parent),
ui(new Ui::Settings) {
ui->setupUi(this);
QSettings settings;
ui->lineEdit_swgfolder->setText(settings.value("swg_folder").toString());
ui->checkBox_close->setChecked(settings.value("close_after_start", false).toBool());
ui->checkBox_minimize->setChecked(settings.value("minimize_after_start", false).toBool());
ui->checkBox_debug->setChecked(settings.value("capture_debug_output", false).toBool());
ui->checkBox_multithreaded->setChecked(settings.value("multi_threaded_full_scan", false).toBool());
ui->lineEdit_wine_env->setText(settings.value("wine_env").toString());
QString wineBinary = settings.value("wine_binary").toString();
if (!wineBinary.isEmpty())
ui->lineEdit_wine->setText(wineBinary);
ui->lineEdit_wine_args->setText(settings.value("wine_args").toString());
connect(ui->pushButton_SelectFolder, SIGNAL(clicked()), this, SLOT(selectFolder()));
//connect(ui->lineEdit_swgfolder, SIGNAL(textChanged(QString)), this, SLOT(folderChanged(QString)));
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(updateAllOptions()));
connect(ui->buttonBox, SIGNAL(accepted()), (MainWindow*)parent, SLOT(startLoadBasicCheck()));
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(restoreOptions()));
connect(ui->checkBox_close, SIGNAL(toggled(bool)), this, SLOT(closeAfterStartChanged(bool)));
connect(ui->checkBox_minimize, SIGNAL(toggled(bool)), this, SLOT(minimizeToTrayAfterStartChanged(bool)));
#ifndef Q_OS_WIN32
ui->groupBox->setEnabled(true);
#endif
//connect(ui->)
}
Settings::~Settings() {
delete ui;
ui = NULL;
}
void Settings::selectFolder() {
QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
"/home",
QFileDialog::ShowDirsOnly
| QFileDialog::DontResolveSymlinks);
ui->lineEdit_swgfolder->setText(dir);
}
void Settings::restoreMimizeAfterStart() {
QSettings settings;
ui->checkBox_minimize->setChecked(settings.value("minimize_after_start", false).toBool());
}
void Settings::updateAllOptions() {
updateCloseAfterStartSetting();
updateFolderSetting();
updateMinimizeAfterStart();
updateCaptureDebugSetting();
updateMultiThreadedFullScan();
updateWineBinary();
updateWineArguments();
updateWineEnvironment();
}
void Settings::updateMultiThreadedFullScan() {
QSettings settings;
settings.setValue("multi_threaded_full_scan", ui->checkBox_multithreaded->isChecked());
}
void Settings::updateCaptureDebugSetting() {
QSettings settings;
settings.setValue("capture_debug_output", ui->checkBox_debug->isChecked());
}
void Settings::updateMinimizeAfterStart() {
QSettings settings;
settings.setValue("minimize_after_start", ui->checkBox_minimize->isChecked());
}
void Settings::closeAfterStartChanged(bool state) {
if (state && ui->checkBox_minimize->isChecked())
ui->checkBox_minimize->setChecked(false);
}
void Settings::minimizeToTrayAfterStartChanged(bool state) {
if (state && ui->checkBox_close->isCheckable())
ui->checkBox_close->setChecked(false);
}
void Settings::updateCloseAfterStartSetting() {
QSettings settings;
settings.setValue("close_after_start", ui->checkBox_close->isChecked());
}
void Settings::updateFolderSetting() {
QString newFolder = ui->lineEdit_swgfolder->text();
QSettings settings;
settings.setValue("swg_folder", newFolder);
}
void Settings::updateWineBinary() {
QString bin = ui->lineEdit_wine->text();
QSettings settings;
settings.setValue("wine_binary", bin);
}
void Settings::updateWineArguments() {
QString arguments = ui->lineEdit_wine_args->text();
QSettings settings;
settings.setValue("wine_args", arguments);
}
void Settings::updateWineEnvironment() {
QString env = ui->lineEdit_wine_env->text();
QSettings settings;
settings.setValue("wine_env", env);
}
void Settings::restoreOptions() {
restoreFolder();
restoreCloseAfterStart();
restoreMimizeAfterStart();
restoreCaptureDebug();
restoreMultiThreadedFullScan();
restoreWineArgs();
restoreWineBinary();
restoreWineEnvironment();
}
void Settings::restoreWineEnvironment() {
QSettings settings;
ui->lineEdit_wine_env->setText(settings.value("wine_env").toString());
}
void Settings::restoreWineBinary() {
QSettings settings;
ui->lineEdit_wine->setText(settings.value("wine_binary").toString());
}
void Settings::restoreWineArgs() {
QSettings settings;
ui->lineEdit_wine_args->setText(settings.value("wine_args").toString());
}
void Settings::restoreCaptureDebug() {
QSettings settings;
ui->checkBox_debug->setChecked(settings.value("capture_debug_output", false).toBool());
}
void Settings::restoreCloseAfterStart() {
QSettings settings;
ui->checkBox_close->setChecked(settings.value("close_after_start", false).toBool());
}
void Settings::restoreMultiThreadedFullScan() {
QSettings settings;
ui->checkBox_multithreaded->setChecked(settings.value("multi_threaded_full_scan", false).toBool());
}
void Settings::restoreFolder() {
QSettings settings;
QString folder = settings.value("swg_folder").toString();
ui->lineEdit_swgfolder->setText(folder);
}