src/settingseditor/settingseditor.cpp

changeset 202
b05af0bab735
parent 48
3c10f0e2fbe0
child 218
63125c36de73
--- a/src/settingseditor/settingseditor.cpp	Tue Jun 07 01:37:26 2022 +0300
+++ b/src/settingseditor/settingseditor.cpp	Tue Jun 07 20:44:19 2022 +0300
@@ -1,4 +1,5 @@
 #include <QSettings>
+#include <QMdiArea>
 #include "gl/common.h"
 #include "keyboardshortcutseditor.h"
 #include "settingseditor.h"
@@ -17,6 +18,9 @@
 	defaultKeyboardShortcuts{defaultKeyboardShortcuts}
 {
 	this->ui.setupUi(this);
+	this->ui.keyboardShortcutsView->setModel(new KeyboardShortcutsEditor{parent, this});
+	this->ui.viewModeButtonGroup->setId(this->ui.viewModeTabs, int{QMdiArea::TabbedView});
+	this->ui.viewModeButtonGroup->setId(this->ui.viewModeSubWindows, int{QMdiArea::SubWindowView});
 	this->loadLocales();
 	this->setDefaults();
 	QVBoxLayout* layout = new QVBoxLayout{this};
@@ -27,7 +31,6 @@
 		&SettingsEditor::accepted,
 		this,
 		&SettingsEditor::handleAccepted);
-	this->ui.keyboardShortcutsView->setModel(new KeyboardShortcutsEditor{parent, this});
 }
 
 SettingsEditor::~SettingsEditor()
@@ -43,6 +46,10 @@
 	this->settings->setSelectedColor(this->ui.selectedColorButton->selectedColor());
 	this->settings->setLineThickness(static_cast<GLfloat>(this->ui.lineThickness->value()));
 	this->settings->setLineAntiAliasing(this->ui.lineAntiAliasing->isChecked());
+	const int viewMode = this->ui.viewModeButtonGroup->checkedId();
+	if (viewMode != -1) {
+		this->settings->setViewMode(viewMode);
+	}
 	this->librariesEditor.saveSettings(this->settings);
 }
 
@@ -76,6 +83,10 @@
 	this->ui.selectedColorButton->setSelectedColor(this->settings->selectedColor());
 	this->ui.lineThickness->setValue(static_cast<double>(this->settings->lineThickness()));
 	this->ui.lineAntiAliasing->setChecked(this->settings->lineAntiAliasing());
+	auto* const viewModeButton = this->ui.viewModeButtonGroup->button(this->settings->viewMode());
+	if (viewModeButton != nullptr) {
+		viewModeButton->setChecked(true);
+	}
 }
 
 void SettingsEditor::setCurrentLanguage(const QString& localeCode)

mercurial