Menu

[465617]: / src / advancedoptionsdialog.cpp  Maximize  Restore  History

Download this file

82 lines (72 with data), 3.9 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
#include "advancedoptionsdialog.h"
#include "mainwindow.h"
AdvancedOptionsDialog::AdvancedOptionsDialog(QWidget *parent)
: QDialog(parent)
{
setupUi(this);
setWindowTitle(windowTitle().arg(MainWindow::getAppTitle()));
// fill fields vector with checkable control elements
{
fields << checkBox_Maximizing;
fields << horizontalSlider_logBackendDepth;
fields << horizontalSlider_logTraceDepth;
fields << checkBox_ShowHiddenFields;
fields << spinBox_beepAfter;
fields << checkBox_UseNoTempFiles;
fields << checkBox_ShowNoFileProgress;
fields << radioButton_threadRealtime;
fields << radioButton_threadHigh;
fields << radioButton_threadNormal;
fields << radioButton_threadIdle;
}
MainWindow* mainWindow = qobject_cast<MainWindow*>(this->parent());
readSettings(mainWindow->getSettings());
isAccepted = false;
horizontalSlider_logBackendDepth_origValue = horizontalSlider_logBackendDepth->value();
horizontalSlider_logTraceDepth_origValue = horizontalSlider_logTraceDepth->value();
spinBox_beepAfter_origValue = spinBox_beepAfter->value();
}
AdvancedOptionsDialog::~AdvancedOptionsDialog(){
if (isAccepted){
MainWindow* mainWindow = qobject_cast<MainWindow*>(this->parent());
writeSettings(mainWindow->getSettings());
if (horizontalSlider_logBackendDepth->value() != horizontalSlider_logBackendDepth_origValue){
mainWindow->actionLogBackend->setChecked(horizontalSlider_logBackendDepth->value() > 0);
}
if (horizontalSlider_logTraceDepth->value() != horizontalSlider_logTraceDepth_origValue){
mainWindow->actionLogTrace->setChecked(horizontalSlider_logTraceDepth->value() > 0);
}
}
}
void AdvancedOptionsDialog::readSettings(QSettings *settings){
settings->beginGroup("advancedOptionsDialog");
for (int i=0; i<fields.count(); i++){
if (fields[i]->objectName().startsWith("horizontalSlider"))
(qobject_cast<QSlider*>(fields[i]))->setValue(settings->value(fields[i]->objectName(), (qobject_cast<QSlider*>(fields[i]))->value()).toInt());
if (fields[i]->objectName().startsWith("spinBox"))
(qobject_cast<QSpinBox*>(fields[i]))->setValue(settings->value(fields[i]->objectName(), (qobject_cast<QSpinBox*>(fields[i]))->value()).toInt());
else if (fields[i]->objectName().startsWith("checkBox"))
(qobject_cast<QCheckBox*>(fields[i]))->setChecked(settings->value(fields[i]->objectName(), (qobject_cast<QCheckBox*>(fields[i]))->isChecked()).toBool());
else if (fields[i]->objectName().startsWith("radioButton"))
(qobject_cast<QRadioButton*>(fields[i]))->setChecked(settings->value(fields[i]->objectName(), (qobject_cast<QRadioButton*>(fields[i]))->isChecked()).toBool());
}
settings->endGroup();
}
void AdvancedOptionsDialog::writeSettings(QSettings *settings){
settings->beginGroup("advancedOptionsDialog");
for (int i=0; i<fields.count(); i++){
if (fields[i]->objectName().startsWith("horizontalSlider"))
settings->setValue(fields[i]->objectName(), (qobject_cast<QSlider*>(fields[i]))->value());
if (fields[i]->objectName().startsWith("spinBox"))
settings->setValue(fields[i]->objectName(), (qobject_cast<QSpinBox*>(fields[i]))->value());
else if (fields[i]->objectName().startsWith("checkBox"))
settings->setValue(fields[i]->objectName(), (qobject_cast<QCheckBox*>(fields[i]))->isChecked());
else if (fields[i]->objectName().startsWith("radioButton"))
settings->setValue(fields[i]->objectName(), (qobject_cast<QRadioButton*>(fields[i]))->isChecked());
}
settings->endGroup();
}
void AdvancedOptionsDialog::accept(){
isAccepted = true;
return QDialog::accept();
}
MongoDB Logo MongoDB