-
Notifications
You must be signed in to change notification settings - Fork 9
/
settingswindow.cpp
84 lines (72 loc) · 2.77 KB
/
settingswindow.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
/*
MabiMe Character Simulator - by Yai (Sophie N)
Email: [email protected]
Copyright (C) 2016
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "settingswindow.h"
#include "ui_settingswindow.h"
#include <QDebug>
#include <QSettings>
SettingsWindow::SettingsWindow(QWidget *parent, QString path) :
QWidget(parent),
ui(new Ui::SettingsWindow)
{
setWindowFlags(Qt::Dialog);
this->setWindowFlags(windowFlags() &~Qt::WindowContextHelpButtonHint);
ui->setupUi(this);
detectedPath = path;
#if defined(Q_OS_WIN)
bool canAutoDetect = true;
#else
bool canAutoDetect = false;
#endif
ui->c_autodetect->setChecked(s.value("AutoDetectEnabled", canAutoDetect).toBool());
ui->e_autodetect->setText(s.value("ClientPath", "").toString());
ui->c_language_pack->setChecked(s.value("CustomLanguagePackEnabled", false).toBool());
ui->e_language_pack->setText(s.value("CustomLanguagePackPath", "").toString());
ui->l_categories->setIconSize(QSize(24, 24));
for (int i = 1; i < ui->l_categories->count(); i++) {
ui->l_categories->item(i)->setSizeHint(QSize(0, 40));
}
ui->l_categories->setCurrentRow(0);
this->on_c_autodetect_toggled(ui->c_autodetect->isChecked());
}
SettingsWindow::~SettingsWindow()
{
delete ui;
}
void SettingsWindow::on_c_autodetect_toggled(bool checked)
{
ui->l_autodetect->setEnabled(!checked);
ui->b_autodetect->setEnabled(!checked);
ui->e_autodetect->setEnabled(!checked);
ui->e_autodetect->setText(checked ? "detected: <" + detectedPath + ">" : s.value("ClientPath", "").toString());
}
void SettingsWindow::on_b_cancel_clicked()
{
this->close();
}
void SettingsWindow::on_b_savesettings_clicked()
{
s.setValue("AutoDetectEnabled", ui->c_autodetect->isChecked());
s.setValue("ClientPath", ui->c_autodetect->isChecked() ? "" : ui->e_autodetect->text());
s.setValue("CustomLanguagePackEnabled", ui->c_language_pack->isChecked());
s.setValue("CustomLanguagePackPath", ui->e_language_pack->text());
this->close();
}
void SettingsWindow::on_c_language_pack_toggled(bool checked)
{
ui->l_language_pack->setEnabled(checked);
ui->b_language_pack->setEnabled(checked);
ui->e_language_pack->setEnabled(checked);
}