forked from kenygia/MooseEdit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SettingsDialog.cpp
93 lines (85 loc) · 2.55 KB
/
SettingsDialog.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
#include "SettingsDialog.h"
#include "ui_SettingsDialog.h"
SettingsDialog::SettingsDialog(EditorSettings *settings, QWidget *parent) :
QDialog(parent), originalSettings(settings),
ui(new Ui::SettingsDialog)
{
if (originalSettings == 0) {
newSettings = 0;
} else {
newSettings = new EditorSettings(*originalSettings);
}
ui->setupUi(this);
initializeValues();
}
SettingsDialog::~SettingsDialog()
{
if (newSettings != 0) {
delete newSettings;
}
delete ui;
}
void SettingsDialog::initializeValues() {
if (newSettings != 0) {
bool useCompression = (newSettings->getProperty(L"useCompression") == L"1"? true : false);
bool highCompressionMode = (newSettings->getProperty(L"highCompressionMode") == L"1"? true : false);
QCheckBox *compressionCheckBox = this->findChild<QCheckBox *>("useCompressionCheckBox");
if (compressionCheckBox != 0) {
compressionCheckBox->setChecked(useCompression);
}
QCheckBox *highCompressionCheckBox = this->findChild<QCheckBox *>("highCompressionCheckBox");
if (highCompressionCheckBox != 0) {
highCompressionCheckBox->setChecked(highCompressionMode);
}
applyPostProcessing();
}
}
void SettingsDialog::applyPostProcessing() {
bool useCompression = (newSettings->getProperty(L"useCompression") == L"1"? true : false);
QCheckBox *highCompressionCheckBox = this->findChild<QCheckBox *>("highCompressionCheckBox");
if (highCompressionCheckBox != 0) {
if (!useCompression) {
highCompressionCheckBox->setEnabled(false);
} else {
highCompressionCheckBox->setEnabled(true);
}
}
}
void SettingsDialog::on_useCompressionCheckBox_clicked()
{
if (newSettings != 0) {
QCheckBox *compressionCheckBox = this->findChild<QCheckBox *>("useCompressionCheckBox");
if (compressionCheckBox != 0) {
if (compressionCheckBox->isChecked()) {
newSettings->setProperty(L"useCompression", L"1");
} else {
newSettings->setProperty(L"useCompression", L"0");
}
}
applyPostProcessing();
}
}
void SettingsDialog::on_highCompressionCheckBox_clicked()
{
if (newSettings != 0) {
QCheckBox *highCompressionCheckBox = this->findChild<QCheckBox *>("highCompressionCheckBox");
if (highCompressionCheckBox != 0) {
if (highCompressionCheckBox->isChecked()) {
newSettings->setProperty(L"highCompressionMode", L"1");
} else {
newSettings->setProperty(L"highCompressionMode", L"0");
}
}
}
}
void SettingsDialog::on_buttonBox_accepted()
{
if (originalSettings != 0 && newSettings != 0) {
*originalSettings = *newSettings;
}
this->setResult(1);
}
void SettingsDialog::on_buttonBox_rejected()
{
this->setResult(0);
}