# HG changeset patch # User Teemu Piippo # Date 1580570410 -7200 # Node ID 30cb5e8367367dbf7cb4e76beee604fd66ea3422 # Parent caac957e9834b5d98767c9775662662b33e12f0c added configurable background color diff -r caac957e9834 -r 30cb5e836736 locale/sv.ts --- a/locale/sv.ts Sat Feb 01 17:10:11 2020 +0200 +++ b/locale/sv.ts Sat Feb 01 17:20:10 2020 +0200 @@ -275,7 +275,11 @@ - Main color: + Main colour: + + + + Background colour: diff -r caac957e9834 -r 30cb5e836736 src/gl/common.h --- a/src/gl/common.h Sat Feb 01 17:10:11 2020 +0200 +++ b/src/gl/common.h Sat Feb 01 17:20:10 2020 +0200 @@ -156,6 +156,7 @@ { gl::RenderStyle style = gl::RenderStyle::Normal; QColor mainColor{255, 255, 64}; + QColor backgroundColor{48, 48, 48}; float lineThickness = 2.0f; }; } diff -r caac957e9834 -r 30cb5e836736 src/gl/partrenderer.cpp --- a/src/gl/partrenderer.cpp Sat Feb 01 17:10:11 2020 +0200 +++ b/src/gl/partrenderer.cpp Sat Feb 01 17:20:10 2020 +0200 @@ -100,7 +100,12 @@ void PartRenderer::renderScene() { - glClearColor(0.8f, 0.8f, 0.8f, 1.0f); + const QColor& backgroundColor = this->renderPreferences.backgroundColor; + glClearColor( + static_cast(backgroundColor.redF()), + static_cast(backgroundColor.greenF()), + static_cast(backgroundColor.blueF()), + 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); glEnable(GL_POLYGON_OFFSET_FILL); diff -r caac957e9834 -r 30cb5e836736 src/mainwindow.cpp --- a/src/mainwindow.cpp Sat Feb 01 17:10:11 2020 +0200 +++ b/src/mainwindow.cpp Sat Feb 01 17:20:10 2020 +0200 @@ -67,6 +67,7 @@ }); } this->updateTitle(); + this->restoreStartupSettings(); this->restoreSettings(); this->updateRenderPreferences(); this->newModel(); @@ -296,16 +297,25 @@ this->libraries.storeToSettings(&this->settings); } +void MainWindow::restoreStartupSettings() +{ + this->restoreGeometry(this->settings.value("MainWindow/Geometry").toByteArray()); +} + /** * @brief Restores saved settings relating to the main window */ void MainWindow::restoreSettings() { - this->restoreGeometry(this->settings.value("MainWindow/Geometry").toByteArray()); this->recentlyOpenedFiles = this->settings.value("MainWindow/RecentlyOpened").toStringList(); this->documentSplitterState = this->settings.value("MainWindow/DocumentSplitterState").toByteArray(); this->renderPreferences.style = static_cast(this->settings.value("Render/Style").toInt()); - this->renderPreferences.mainColor = this->settings.value("Render/MainColor").toString(); + this->renderPreferences.mainColor = this->settings.value( + "Render/MainColor", + gl::RenderPreferences{}.mainColor).toString(); + this->renderPreferences.backgroundColor = this->settings.value( + "Render/BackgroundColor", + gl::RenderPreferences{}.backgroundColor).toString(); const QString systemLocale = QLocale::system().name(); const QVariant defaultLocale = this->settings.value("locale", systemLocale); changeLanguage(defaultLocale.toString()); diff -r caac957e9834 -r 30cb5e836736 src/mainwindow.h --- a/src/mainwindow.h Sat Feb 01 17:10:11 2020 +0200 +++ b/src/mainwindow.h Sat Feb 01 17:20:10 2020 +0200 @@ -60,6 +60,7 @@ void updateTitle(); void updateRenderPreferences(); void saveSettings(); + void restoreStartupSettings(); void restoreSettings(); void changeLanguage(QString localeCode); void addRecentlyOpenedFile(const QString& path); diff -r caac957e9834 -r 30cb5e836736 src/settingseditor/settingseditor.cpp --- a/src/settingseditor/settingseditor.cpp Sat Feb 01 17:10:11 2020 +0200 +++ b/src/settingseditor/settingseditor.cpp Sat Feb 01 17:20:10 2020 +0200 @@ -1,4 +1,5 @@ #include +#include "gl/common.h" #include "keyboardshortcutseditor.h" #include "settingseditor.h" #include "ui_settingseditor.h" @@ -38,6 +39,7 @@ { this->settings->setValue("locale", this->ui.language->currentData().toString()); this->settings->setValue("Render/MainColor", this->ui.mainColorButton->selectedColor().name()); + this->settings->setValue("Render/BackgroundColor", this->ui.backgroundColorButton->selectedColor().name()); this->librariesEditor.saveSettings(this->settings); } @@ -66,7 +68,12 @@ void SettingsEditor::setDefaults() { this->setCurrentLanguage(this->settings->value("locale", QLocale::system().name()).toString()); - this->ui.mainColorButton->setSelectedColor(this->settings->value("Render/MainColor").toString()); + this->ui.mainColorButton->setSelectedColor(this->settings->value( + "Render/MainColor", + gl::RenderPreferences{}.mainColor).toString()); + this->ui.backgroundColorButton->setSelectedColor(this->settings->value( + "Render/BackgroundColor", + gl::RenderPreferences{}.backgroundColor).toString()); } void SettingsEditor::setCurrentLanguage(const QString& localeCode) diff -r caac957e9834 -r 30cb5e836736 src/settingseditor/settingseditor.ui --- a/src/settingseditor/settingseditor.ui Sat Feb 01 17:10:11 2020 +0200 +++ b/src/settingseditor/settingseditor.ui Sat Feb 01 17:20:10 2020 +0200 @@ -80,7 +80,7 @@ - Main color: + Main colour: @@ -108,6 +108,50 @@ + + + + Background colour: + + + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + +