src/settingseditor/settingseditor.cpp

Sat, 08 Apr 2023 16:59:55 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Sat, 08 Apr 2023 16:59:55 +0300
changeset 355
e81f4ad53efd
parent 347
5c655cc006de
child 356
65b4741b302d
permissions
-rw-r--r--

Move the about dialog to MainWindow. The hack to retrieve GL extensions is made a bit cleaner

7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1 #include <QSettings>
202
b05af0bab735 Replaced the tab widget with an MDI area
Teemu Piippo <teemu@hecknology.net>
parents: 48
diff changeset
2 #include <QMdiArea>
264
76a025db4948 Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 259
diff changeset
3 #include <ui_settingseditor.h>
76a025db4948 Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 259
diff changeset
4 #include "src/settings.h"
76a025db4948 Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 259
diff changeset
5 #include "src/gl/common.h"
76a025db4948 Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 259
diff changeset
6 #include "src/settingseditor/keyboardshortcutseditor.h"
76a025db4948 Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 259
diff changeset
7 #include "src/settingseditor/settingseditor.h"
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
8
341
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
9 static QVariantMap storeSettings()
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
10 {
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
11 QVariantMap result;
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
12 QSettings settingsObject;
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
13 for (const QString& key : settingsObject.allKeys()) {
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
14 result[key] = settingsObject.value(key);
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
15 }
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
16 return result;
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
17 }
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
18
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
19 static void restoreSettings(const QVariantMap& storedValues)
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
20 {
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
21 QSettings settingsObject;
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
22 settingsObject.clear();
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
23 for (const QString& key : storedValues.keys()) {
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
24 settingsObject.setValue(key, storedValues[key]);
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
25 }
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
26 }
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
27
16
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
28 SettingsEditor::SettingsEditor(
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
29 const uiutilities::KeySequenceMap& defaultKeyboardShortcuts,
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
30 QWidget* parent
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
31 ) :
285
99af8bf63d10 Don't create more than one settings editor
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 282
diff changeset
32 QMdiSubWindow{parent},
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
33 ui{*new Ui_SettingsEditor},
218
63125c36de73 Replace config collector with a simpler system
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 202
diff changeset
34 libraries{this},
63125c36de73 Replace config collector with a simpler system
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 202
diff changeset
35 librariesEditor{this},
16
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
36 defaultKeyboardShortcuts{defaultKeyboardShortcuts}
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
37 {
341
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
38 QWidget* centralWidget = new QWidget{this};
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
39 this->ui.setupUi(centralWidget);
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
40 this->setWidget(centralWidget);
202
b05af0bab735 Replaced the tab widget with an MDI area
Teemu Piippo <teemu@hecknology.net>
parents: 48
diff changeset
41 this->ui.keyboardShortcutsView->setModel(new KeyboardShortcutsEditor{parent, this});
b05af0bab735 Replaced the tab widget with an MDI area
Teemu Piippo <teemu@hecknology.net>
parents: 48
diff changeset
42 this->ui.viewModeButtonGroup->setId(this->ui.viewModeTabs, int{QMdiArea::TabbedView});
b05af0bab735 Replaced the tab widget with an MDI area
Teemu Piippo <teemu@hecknology.net>
parents: 48
diff changeset
43 this->ui.viewModeButtonGroup->setId(this->ui.viewModeSubWindows, int{QMdiArea::SubWindowView});
335
c5830bce1c23 Fix crashing
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 296
diff changeset
44 this->ui.toolButtonStyle->addItem(tr("Icons only"), Qt::ToolButtonIconOnly);
c5830bce1c23 Fix crashing
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 296
diff changeset
45 this->ui.toolButtonStyle->addItem(tr("Text only"), Qt::ToolButtonTextOnly);
c5830bce1c23 Fix crashing
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 296
diff changeset
46 this->ui.toolButtonStyle->addItem(tr("Text beside icon"), Qt::ToolButtonTextBesideIcon);
c5830bce1c23 Fix crashing
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 296
diff changeset
47 this->ui.toolButtonStyle->addItem(tr("Text under icon"), Qt::ToolButtonTextUnderIcon);
c5830bce1c23 Fix crashing
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 296
diff changeset
48 this->ui.toolButtonStyle->addItem(tr("Style default"), Qt::ToolButtonFollowStyle);
282
f2dc3bbecbfa Make settings editor a sub window instead of a dialog
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
49 this->loadSettings();
f2dc3bbecbfa Make settings editor a sub window instead of a dialog
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
50 this->setWindowTitle(tr("Settings"));
285
99af8bf63d10 Don't create more than one settings editor
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 282
diff changeset
51 this->setWindowIcon(QIcon{":/icons/settings-outline.png"});
259
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 256
diff changeset
52 this->librariesEditor.setModel(&libraries);
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
53 QVBoxLayout* layout = new QVBoxLayout{this};
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
54 layout->addWidget(&librariesEditor);
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
55 this->ui.tabLdrawLibraries->setLayout(layout);
341
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
56 QSettings settingsObject;
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
57 connect(
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
58 this->ui.buttonBox, &QDialogButtonBox::clicked,
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
59 [this, previousSettings = storeSettings()](QAbstractButton* button)
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
60 {
282
f2dc3bbecbfa Make settings editor a sub window instead of a dialog
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
61 const auto role = this->ui.buttonBox->buttonRole(button);
341
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
62 switch (role)
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
63 {
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
64 case QDialogButtonBox::AcceptRole:
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
65 this->close();
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
66 break;
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
67 case QDialogButtonBox::RejectRole:
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
68 restoreSettings(previousSettings);
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
69 Q_EMIT this->settingsChanged();
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
70 this->close();
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
71 break;
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
72 case QDialogButtonBox::ResetRole:
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
73 restoreSettings(previousSettings);
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
74 Q_EMIT this->settingsChanged();
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
75 break;
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
76 default:
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
77 break;
282
f2dc3bbecbfa Make settings editor a sub window instead of a dialog
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
78 }
341
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
79 }
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
80 );
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
81 for (auto* widget : this->findChildren<QAbstractButton*>()) {
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
82 connect(widget, &QAbstractButton::clicked, this, &SettingsEditor::saveSettings);
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
83 }
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
84 for (auto* widget : this->findChildren<QSpinBox*>()) {
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
85 connect(widget, qOverload<int>(&QSpinBox::valueChanged), this, &SettingsEditor::saveSettings);
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
86 }
347
5c655cc006de Rename ColorButton -> ColorEdit
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 341
diff changeset
87 for (auto* widget : this->findChildren<ColorEdit*>()) {
5c655cc006de Rename ColorButton -> ColorEdit
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 341
diff changeset
88 connect(widget, &ColorEdit::colorChanged, this, &SettingsEditor::saveSettings);
341
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
89 }
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
90 for (auto* widget : this->findChildren<QComboBox*>()) {
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
91 connect(widget, qOverload<int>(&QComboBox::currentIndexChanged), this, &SettingsEditor::saveSettings);
71c8cea3c205 Save settings as soon as they are changed, Cancel and Reset buttons revert changes
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 335
diff changeset
92 }
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
93 }
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
94
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
95 SettingsEditor::~SettingsEditor()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
96 {
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
97 delete &this->ui;
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
98 }
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
99
282
f2dc3bbecbfa Make settings editor a sub window instead of a dialog
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
100 void SettingsEditor::saveSettings()
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
101 {
256
c6f5de03dc0f Move color button into widgets lib
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 237
diff changeset
102 setSetting<Setting::MainColor>(this->ui.mainColorButton->color());
c6f5de03dc0f Move color button into widgets lib
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 237
diff changeset
103 setSetting<Setting::BackgroundColor>(this->ui.backgroundColorButton->color());
c6f5de03dc0f Move color button into widgets lib
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 237
diff changeset
104 setSetting<Setting::SelectedColor>(this->ui.selectedColorButton->color());
218
63125c36de73 Replace config collector with a simpler system
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 202
diff changeset
105 setSetting<Setting::LineThickness>(static_cast<GLfloat>(this->ui.lineThickness->value()));
63125c36de73 Replace config collector with a simpler system
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 202
diff changeset
106 setSetting<Setting::LineAntiAliasing>(this->ui.lineAntiAliasing->isChecked());
237
10a6298f636f Add an option to log opengl messages
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
107 setSetting<Setting::LogOpenGLDebugMessages>(this->ui.logOpenGLDebugMessages->isChecked());
202
b05af0bab735 Replaced the tab widget with an MDI area
Teemu Piippo <teemu@hecknology.net>
parents: 48
diff changeset
108 const int viewMode = this->ui.viewModeButtonGroup->checkedId();
b05af0bab735 Replaced the tab widget with an MDI area
Teemu Piippo <teemu@hecknology.net>
parents: 48
diff changeset
109 if (viewMode != -1) {
218
63125c36de73 Replace config collector with a simpler system
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 202
diff changeset
110 setSetting<Setting::ViewMode>(static_cast<QMdiArea::ViewMode>(viewMode));
202
b05af0bab735 Replaced the tab widget with an MDI area
Teemu Piippo <teemu@hecknology.net>
parents: 48
diff changeset
111 }
335
c5830bce1c23 Fix crashing
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 296
diff changeset
112 const QVariant toolButtonStyle = this->ui.toolButtonStyle->currentData();
c5830bce1c23 Fix crashing
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 296
diff changeset
113 if (toolButtonStyle.isValid()) {
c5830bce1c23 Fix crashing
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 296
diff changeset
114 setSetting<Setting::ToolButtonStyle>(
c5830bce1c23 Fix crashing
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 296
diff changeset
115 static_cast<Qt::ToolButtonStyle>(toolButtonStyle.toInt()));
c5830bce1c23 Fix crashing
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 296
diff changeset
116 }
218
63125c36de73 Replace config collector with a simpler system
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 202
diff changeset
117 this->librariesEditor.saveSettings();
282
f2dc3bbecbfa Make settings editor a sub window instead of a dialog
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
118 Q_EMIT this->settingsChanged();
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
119 }
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
120
282
f2dc3bbecbfa Make settings editor a sub window instead of a dialog
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
121 void SettingsEditor::loadSettings()
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
122 {
259
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 256
diff changeset
123 this->libraries.restoreFromSettings();
256
c6f5de03dc0f Move color button into widgets lib
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 237
diff changeset
124 this->ui.mainColorButton->setColor(setting<Setting::MainColor>());
c6f5de03dc0f Move color button into widgets lib
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 237
diff changeset
125 this->ui.backgroundColorButton->setColor(setting<Setting::BackgroundColor>());
c6f5de03dc0f Move color button into widgets lib
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 237
diff changeset
126 this->ui.selectedColorButton->setColor(setting<Setting::SelectedColor>());
218
63125c36de73 Replace config collector with a simpler system
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 202
diff changeset
127 this->ui.lineThickness->setValue(double_cast(setting<Setting::LineThickness>()));
63125c36de73 Replace config collector with a simpler system
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 202
diff changeset
128 this->ui.lineAntiAliasing->setChecked(setting<Setting::LineAntiAliasing>());
237
10a6298f636f Add an option to log opengl messages
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
129 this->ui.logOpenGLDebugMessages->setChecked(setting<Setting::LogOpenGLDebugMessages>());
218
63125c36de73 Replace config collector with a simpler system
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 202
diff changeset
130 auto* const viewModeButton = this->ui.viewModeButtonGroup->button(setting<Setting::ViewMode>());
202
b05af0bab735 Replaced the tab widget with an MDI area
Teemu Piippo <teemu@hecknology.net>
parents: 48
diff changeset
131 if (viewModeButton != nullptr) {
b05af0bab735 Replaced the tab widget with an MDI area
Teemu Piippo <teemu@hecknology.net>
parents: 48
diff changeset
132 viewModeButton->setChecked(true);
b05af0bab735 Replaced the tab widget with an MDI area
Teemu Piippo <teemu@hecknology.net>
parents: 48
diff changeset
133 }
335
c5830bce1c23 Fix crashing
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 296
diff changeset
134 int toolButtonStyleIndex = this->ui.toolButtonStyle->findData(
c5830bce1c23 Fix crashing
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 296
diff changeset
135 setting<Setting::ToolButtonStyle>());
c5830bce1c23 Fix crashing
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 296
diff changeset
136 if (toolButtonStyleIndex != -1) {
c5830bce1c23 Fix crashing
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 296
diff changeset
137 this->ui.toolButtonStyle->setCurrentIndex(toolButtonStyleIndex);
c5830bce1c23 Fix crashing
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 296
diff changeset
138 }
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
139 }

mercurial