src/settingseditor/settingseditor.cpp

Sat, 08 Apr 2023 21:48:49 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Sat, 08 Apr 2023 21:48:49 +0300
changeset 356
65b4741b302d
parent 347
5c655cc006de
child 357
66c75604f5b8
permissions
-rw-r--r--

Made editor font configurable
Add grid matrix editor

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);
356
65b4741b302d Made editor font configurable
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 347
diff changeset
49 connect(
65b4741b302d Made editor font configurable
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 347
diff changeset
50 this->ui.codeEditorSystemFont,
65b4741b302d Made editor font configurable
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 347
diff changeset
51 &QCheckBox::stateChanged,
65b4741b302d Made editor font configurable
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 347
diff changeset
52 [this](int state){
65b4741b302d Made editor font configurable
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 347
diff changeset
53 const bool checked = (state == Qt::Checked);
65b4741b302d Made editor font configurable
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 347
diff changeset
54 this->ui.codeEditorFontFamily->setEnabled(not checked);
65b4741b302d Made editor font configurable
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 347
diff changeset
55 this->ui.codeEditorFontSize->setEnabled(not checked);
65b4741b302d Made editor font configurable
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 347
diff changeset
56 }
65b4741b302d Made editor font configurable
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 347
diff changeset
57 );
282
f2dc3bbecbfa Make settings editor a sub window instead of a dialog
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
58 this->loadSettings();
f2dc3bbecbfa Make settings editor a sub window instead of a dialog
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
59 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
60 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
61 this->librariesEditor.setModel(&libraries);
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
62 QVBoxLayout* layout = new QVBoxLayout{this};
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
63 layout->addWidget(&librariesEditor);
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
64 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
65 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
66 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
67 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
68 [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
69 {
282
f2dc3bbecbfa Make settings editor a sub window instead of a dialog
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
70 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
71 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
72 {
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 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
74 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
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 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
77 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
78 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
79 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
80 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
81 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
82 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
83 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
84 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
85 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
86 break;
282
f2dc3bbecbfa Make settings editor a sub window instead of a dialog
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
87 }
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
88 }
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<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
91 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
92 }
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
93 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
94 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
95 }
347
5c655cc006de Rename ColorButton -> ColorEdit
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 341
diff changeset
96 for (auto* widget : this->findChildren<ColorEdit*>()) {
5c655cc006de Rename ColorButton -> ColorEdit
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 341
diff changeset
97 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
98 }
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
99 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
100 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
101 }
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
102 }
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
103
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
104 SettingsEditor::~SettingsEditor()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
105 {
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
106 delete &this->ui;
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
107 }
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
108
282
f2dc3bbecbfa Make settings editor a sub window instead of a dialog
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
109 void SettingsEditor::saveSettings()
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
110 {
256
c6f5de03dc0f Move color button into widgets lib
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 237
diff changeset
111 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
112 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
113 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
114 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
115 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
116 setSetting<Setting::LogOpenGLDebugMessages>(this->ui.logOpenGLDebugMessages->isChecked());
356
65b4741b302d Made editor font configurable
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 347
diff changeset
117 setSetting<Setting::CodeEditorUseSystemFont>(this->ui.codeEditorSystemFont->isChecked());
65b4741b302d Made editor font configurable
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 347
diff changeset
118 setSetting<Setting::CodeEditorFontFamily>(this->ui.codeEditorFontFamily->currentText());
65b4741b302d Made editor font configurable
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 347
diff changeset
119 setSetting<Setting::CodeEditorFontSize>(this->ui.codeEditorFontSize->value());
202
b05af0bab735 Replaced the tab widget with an MDI area
Teemu Piippo <teemu@hecknology.net>
parents: 48
diff changeset
120 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
121 if (viewMode != -1) {
218
63125c36de73 Replace config collector with a simpler system
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 202
diff changeset
122 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
123 }
335
c5830bce1c23 Fix crashing
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 296
diff changeset
124 const QVariant toolButtonStyle = this->ui.toolButtonStyle->currentData();
c5830bce1c23 Fix crashing
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 296
diff changeset
125 if (toolButtonStyle.isValid()) {
c5830bce1c23 Fix crashing
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 296
diff changeset
126 setSetting<Setting::ToolButtonStyle>(
c5830bce1c23 Fix crashing
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 296
diff changeset
127 static_cast<Qt::ToolButtonStyle>(toolButtonStyle.toInt()));
c5830bce1c23 Fix crashing
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 296
diff changeset
128 }
218
63125c36de73 Replace config collector with a simpler system
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 202
diff changeset
129 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
130 Q_EMIT this->settingsChanged();
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
131 }
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
132
282
f2dc3bbecbfa Make settings editor a sub window instead of a dialog
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
133 void SettingsEditor::loadSettings()
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
134 {
259
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 256
diff changeset
135 this->libraries.restoreFromSettings();
256
c6f5de03dc0f Move color button into widgets lib
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 237
diff changeset
136 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
137 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
138 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
139 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
140 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
141 this->ui.logOpenGLDebugMessages->setChecked(setting<Setting::LogOpenGLDebugMessages>());
356
65b4741b302d Made editor font configurable
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 347
diff changeset
142 this->ui.codeEditorSystemFont->setChecked(setting<Setting::CodeEditorUseSystemFont>());
65b4741b302d Made editor font configurable
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 347
diff changeset
143 this->ui.codeEditorFontFamily->setCurrentText(setting<Setting::CodeEditorFontFamily>());
65b4741b302d Made editor font configurable
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 347
diff changeset
144 this->ui.codeEditorFontSize->setValue(setting<Setting::CodeEditorFontSize>());
218
63125c36de73 Replace config collector with a simpler system
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 202
diff changeset
145 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
146 if (viewModeButton != nullptr) {
b05af0bab735 Replaced the tab widget with an MDI area
Teemu Piippo <teemu@hecknology.net>
parents: 48
diff changeset
147 viewModeButton->setChecked(true);
b05af0bab735 Replaced the tab widget with an MDI area
Teemu Piippo <teemu@hecknology.net>
parents: 48
diff changeset
148 }
335
c5830bce1c23 Fix crashing
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 296
diff changeset
149 int toolButtonStyleIndex = this->ui.toolButtonStyle->findData(
c5830bce1c23 Fix crashing
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 296
diff changeset
150 setting<Setting::ToolButtonStyle>());
c5830bce1c23 Fix crashing
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 296
diff changeset
151 if (toolButtonStyleIndex != -1) {
c5830bce1c23 Fix crashing
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 296
diff changeset
152 this->ui.toolButtonStyle->setCurrentIndex(toolButtonStyleIndex);
c5830bce1c23 Fix crashing
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 296
diff changeset
153 }
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
154 }

mercurial