src/settingseditor/settingseditor.cpp

changeset 335
c5830bce1c23
parent 296
38f6fad61bad
child 341
71c8cea3c205
equal deleted inserted replaced
334:083b0d8e220a 335:c5830bce1c23
20 this->ui.setupUi(widget); 20 this->ui.setupUi(widget);
21 this->setWidget(widget); 21 this->setWidget(widget);
22 this->ui.keyboardShortcutsView->setModel(new KeyboardShortcutsEditor{parent, this}); 22 this->ui.keyboardShortcutsView->setModel(new KeyboardShortcutsEditor{parent, this});
23 this->ui.viewModeButtonGroup->setId(this->ui.viewModeTabs, int{QMdiArea::TabbedView}); 23 this->ui.viewModeButtonGroup->setId(this->ui.viewModeTabs, int{QMdiArea::TabbedView});
24 this->ui.viewModeButtonGroup->setId(this->ui.viewModeSubWindows, int{QMdiArea::SubWindowView}); 24 this->ui.viewModeButtonGroup->setId(this->ui.viewModeSubWindows, int{QMdiArea::SubWindowView});
25 this->ui.toolButtonStyle->addItem(tr("Icons only"), Qt::ToolButtonIconOnly);
26 this->ui.toolButtonStyle->addItem(tr("Text only"), Qt::ToolButtonTextOnly);
27 this->ui.toolButtonStyle->addItem(tr("Text beside icon"), Qt::ToolButtonTextBesideIcon);
28 this->ui.toolButtonStyle->addItem(tr("Text under icon"), Qt::ToolButtonTextUnderIcon);
29 this->ui.toolButtonStyle->addItem(tr("Style default"), Qt::ToolButtonFollowStyle);
25 this->loadSettings(); 30 this->loadSettings();
26 this->setWindowTitle(tr("Settings")); 31 this->setWindowTitle(tr("Settings"));
27 this->setWindowIcon(QIcon{":/icons/settings-outline.png"}); 32 this->setWindowIcon(QIcon{":/icons/settings-outline.png"});
28 this->librariesEditor.setModel(&libraries); 33 this->librariesEditor.setModel(&libraries);
29 QVBoxLayout* layout = new QVBoxLayout{this}; 34 QVBoxLayout* layout = new QVBoxLayout{this};
53 setSetting<Setting::LogOpenGLDebugMessages>(this->ui.logOpenGLDebugMessages->isChecked()); 58 setSetting<Setting::LogOpenGLDebugMessages>(this->ui.logOpenGLDebugMessages->isChecked());
54 const int viewMode = this->ui.viewModeButtonGroup->checkedId(); 59 const int viewMode = this->ui.viewModeButtonGroup->checkedId();
55 if (viewMode != -1) { 60 if (viewMode != -1) {
56 setSetting<Setting::ViewMode>(static_cast<QMdiArea::ViewMode>(viewMode)); 61 setSetting<Setting::ViewMode>(static_cast<QMdiArea::ViewMode>(viewMode));
57 } 62 }
63 const QVariant toolButtonStyle = this->ui.toolButtonStyle->currentData();
64 if (toolButtonStyle.isValid()) {
65 setSetting<Setting::ToolButtonStyle>(
66 static_cast<Qt::ToolButtonStyle>(toolButtonStyle.toInt()));
67 }
58 this->librariesEditor.saveSettings(); 68 this->librariesEditor.saveSettings();
59 Q_EMIT this->settingsChanged(); 69 Q_EMIT this->settingsChanged();
60 } 70 }
61 71
62 void SettingsEditor::loadSettings() 72 void SettingsEditor::loadSettings()
70 this->ui.logOpenGLDebugMessages->setChecked(setting<Setting::LogOpenGLDebugMessages>()); 80 this->ui.logOpenGLDebugMessages->setChecked(setting<Setting::LogOpenGLDebugMessages>());
71 auto* const viewModeButton = this->ui.viewModeButtonGroup->button(setting<Setting::ViewMode>()); 81 auto* const viewModeButton = this->ui.viewModeButtonGroup->button(setting<Setting::ViewMode>());
72 if (viewModeButton != nullptr) { 82 if (viewModeButton != nullptr) {
73 viewModeButton->setChecked(true); 83 viewModeButton->setChecked(true);
74 } 84 }
85 int toolButtonStyleIndex = this->ui.toolButtonStyle->findData(
86 setting<Setting::ToolButtonStyle>());
87 if (toolButtonStyleIndex != -1) {
88 this->ui.toolButtonStyle->setCurrentIndex(toolButtonStyleIndex);
89 }
75 } 90 }

mercurial