# HG changeset patch # User Teemu Piippo # Date 1656410601 -10800 # Node ID 99af8bf63d10054cf46c3150a2f4d87c361322f3 # Parent 9266239cf72b5c5897ba34d5925a1d31d7aa3627 Don't create more than one settings editor diff -r 9266239cf72b -r 99af8bf63d10 src/main.cpp --- a/src/main.cpp Tue Jun 28 12:47:46 2022 +0300 +++ b/src/main.cpp Tue Jun 28 13:03:21 2022 +0300 @@ -588,13 +588,13 @@ } }); QObject::connect(ui.actionSettingsEditor, &QAction::triggered, [&]{ - SettingsEditor* settingsEditor = new SettingsEditor{defaultKeyboardShortcuts, &mainWindow}; - QObject::connect(&settingsChanged, &Signal::triggered, settingsEditor, &SettingsEditor::loadSettings); - QObject::connect(settingsEditor, &SettingsEditor::settingsChanged, restoreSettings); - auto subwindow = new QMdiSubWindow{ui.mdiArea}; - subwindow->setAttribute(Qt::WA_DeleteOnClose); - subwindow->setWidget(settingsEditor); - subwindow->show(); + if (ui.mdiArea->findChildren().isEmpty()) { + SettingsEditor* settingsEditor = new SettingsEditor{defaultKeyboardShortcuts, ui.mdiArea}; + QObject::connect(&settingsChanged, &Signal::triggered, settingsEditor, &SettingsEditor::loadSettings); + QObject::connect(settingsEditor, &SettingsEditor::settingsChanged, restoreSettings); + settingsEditor->setAttribute(Qt::WA_DeleteOnClose); + settingsEditor->show(); + } }); QObject::connect(ui.actionQuit, &QAction::triggered, &mainWindow, &QMainWindow::close); #if 0 diff -r 9266239cf72b -r 99af8bf63d10 src/settingseditor/settingseditor.cpp --- a/src/settingseditor/settingseditor.cpp Tue Jun 28 12:47:46 2022 +0300 +++ b/src/settingseditor/settingseditor.cpp Tue Jun 28 13:03:21 2022 +0300 @@ -10,19 +10,22 @@ const uiutilities::KeySequenceMap& defaultKeyboardShortcuts, QWidget* parent ) : - QDialog{parent}, + QMdiSubWindow{parent}, ui{*new Ui_SettingsEditor}, libraries{this}, librariesEditor{this}, defaultKeyboardShortcuts{defaultKeyboardShortcuts} { - this->ui.setupUi(this); + QWidget* widget = new QWidget{this}; + this->ui.setupUi(widget); + this->setWidget(widget); 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->loadSettings(); this->setWindowTitle(tr("Settings")); + this->setWindowIcon(QIcon{":/icons/settings-outline.png"}); this->librariesEditor.setModel(&libraries); QVBoxLayout* layout = new QVBoxLayout{this}; layout->addWidget(&librariesEditor); diff -r 9266239cf72b -r 99af8bf63d10 src/settingseditor/settingseditor.h --- a/src/settingseditor/settingseditor.h Tue Jun 28 12:47:46 2022 +0300 +++ b/src/settingseditor/settingseditor.h Tue Jun 28 13:03:21 2022 +0300 @@ -1,11 +1,11 @@ #pragma once -#include +#include #include "src/basics.h" #include "src/libraries.h" #include "src/uiutilities.h" #include "src/settingseditor/librarieseditor.h" -class SettingsEditor : public QDialog +class SettingsEditor : public QMdiSubWindow { Q_OBJECT public: diff -r 9266239cf72b -r 99af8bf63d10 src/settingseditor/settingseditor.ui --- a/src/settingseditor/settingseditor.ui Tue Jun 28 12:47:46 2022 +0300 +++ b/src/settingseditor/settingseditor.ui Tue Jun 28 13:03:21 2022 +0300 @@ -1,21 +1,27 @@ SettingsEditor - + 0 0 - 621 - 572 + 718 + 629 - Dialog + Settings + + + 96 + 96 + + true @@ -24,8 +30,8 @@ 0 0 - 597 - 504 + 694 + 561 @@ -277,53 +283,8 @@
widgets/colorbutton.h
- - language - viewModeTabs - viewModeSubWindows - mainColorButton - selectedColorButton - backgroundColorButton - lineThickness - lineAntiAliasing - tabWidget - keyboardShortcutsView - - - - buttonBox - accepted() - SettingsEditor - accept() - - - 227 - 394 - - - 157 - 274 - - - - - buttonBox - rejected() - SettingsEditor - reject() - - - 295 - 400 - - - 286 - 274 - - - - +