Sat, 01 Feb 2020 17:20:10 +0200
added configurable background color
--- 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 @@ <translation type="unfinished"></translation> </message> <message> - <source>Main color:</source> + <source>Main colour:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Background colour:</source> <translation type="unfinished"></translation> </message> </context>
--- 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; }; }
--- 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<float>(backgroundColor.redF()), + static_cast<float>(backgroundColor.greenF()), + static_cast<float>(backgroundColor.blueF()), + 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); glEnable(GL_POLYGON_OFFSET_FILL);
--- 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<gl::RenderStyle>(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());
--- 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);
--- 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 <QSettings> +#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)
--- 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 @@ <item row="0" column="0"> <widget class="QLabel" name="label_2"> <property name="text"> - <string>Main color:</string> + <string>Main colour:</string> </property> </widget> </item> @@ -108,6 +108,50 @@ </item> </layout> </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Background colour:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="ColorButton" name="backgroundColorButton"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item row="2" column="0"> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> </layout> </widget> </item>