diff options
| author | Felix (xq) Queißner <git@mq32.de> | 2020-06-21 23:13:34 +0200 |
|---|---|---|
| committer | Felix (xq) Queißner <git@mq32.de> | 2020-06-21 23:13:34 +0200 |
| commit | e327de2ca9b4b60a94e3df6c5a70568233ccd678 (patch) | |
| tree | 4690ffc1e25e6cc4589a01e4ee4c61fd055c3ef8 /src | |
| parent | 8efb66c23eedd839e3e5ebe8a19668198574e686 (diff) | |
| download | kristall-e327de2ca9b4b60a94e3df6c5a70568233ccd678.tar.gz | |
Adds 'OS Default' theme.
Diffstat (limited to 'src')
| -rw-r--r-- | src/about/updates.gemini | 1 | ||||
| -rw-r--r-- | src/kristall.hpp | 1 | ||||
| -rw-r--r-- | src/main.cpp | 16 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 5 | ||||
| -rw-r--r-- | src/settingsdialog.cpp | 11 |
5 files changed, 26 insertions, 8 deletions
diff --git a/src/about/updates.gemini b/src/about/updates.gemini index 79d3145..c9e4a56 100644 --- a/src/about/updates.gemini +++ b/src/about/updates.gemini @@ -13,6 +13,7 @@ * Adds configurable and improved redirection handling including warnings for potentially malicious redirects. * Adds improved text highlighting, now works with UTF-8. Still experimental, though 😉 * Adds about:style-preview +* Adds new UI theme: OS Default (uses Qt's default skin) * Fixed bug: Status bar label now does elide links that are too long instead of resizing the window. * Fixed bug: Gopher end-of-file marker is now better detected. * Fixed bug: Auto-URL detection works with leading/trailing spaces diff --git a/src/kristall.hpp b/src/kristall.hpp index 1f0a65d..e5ff24e 100644 --- a/src/kristall.hpp +++ b/src/kristall.hpp @@ -11,6 +11,7 @@ enum class Theme : int { + os_default = -1, light = 0, dark = 1, }; diff --git a/src/main.cpp b/src/main.cpp index 742af6d..256ed2b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -78,10 +78,13 @@ void GenericSettings::load(QSettings &settings) enable_text_decoration = settings.value("text_decoration", false).toBool(); - if(settings.value("theme", "light").toString() == "dark") + QString theme_name = settings.value("theme", "os_default").toString(); + if(theme_name== "dark") theme = Theme::dark; - else + else if(theme_name == "light") theme = Theme::light; + else + theme = Theme::os_default; if(settings.value("gophermap_display", "rendered").toString() == "rendered") gophermap_display = FormattedText; @@ -99,7 +102,14 @@ void GenericSettings::save(QSettings &settings) const settings.setValue("start_page", this->start_page); settings.setValue("text_display", (text_display == FormattedText) ? "fancy" : "plain"); settings.setValue("text_decoration", enable_text_decoration); - settings.setValue("theme", (theme == Theme::dark) ? "dark" : "light"); + QString theme_name = "os_default"; + switch(theme) { + case Theme::dark: theme_name = "dark"; break; + case Theme::light: theme_name = "light"; break; + case Theme::os_default: theme_name = "os_default"; break; + } + + settings.setValue("theme", theme_name); settings.setValue("gophermap_display", (gophermap_display == FormattedText) ? "rendered" : "text"); settings.setValue("use_os_scheme_handler", use_os_scheme_handler); settings.setValue("max_redirections", max_redirections); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2e96aa9..81a209a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -335,6 +335,11 @@ void MainWindow::on_actionAbout_Qt_triggered() void MainWindow::reloadTheme() { + if(global_options.theme == Theme::os_default) + { + application->setStyleSheet(""); + QIcon::setThemeName("light"); + } if(global_options.theme == Theme::light) { QFile file(":/light.qss"); diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index 3c7f9d4..f2c6307 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -25,13 +25,14 @@ SettingsDialog::SettingsDialog(QWidget *parent) : static_assert(DocumentStyle::AutoLightTheme == 2); this->ui->auto_theme->clear(); - this->ui->auto_theme->addItem("Disabled", QVariant::fromValue<int>(DocumentStyle::Fixed)); - this->ui->auto_theme->addItem("Dark Theme", QVariant::fromValue<int>(DocumentStyle::AutoDarkTheme)); - this->ui->auto_theme->addItem("Light Theme", QVariant::fromValue<int>(DocumentStyle::AutoLightTheme)); + this->ui->auto_theme->addItem(tr("Disabled"), QVariant::fromValue<int>(DocumentStyle::Fixed)); + this->ui->auto_theme->addItem(tr("Dark Theme"), QVariant::fromValue<int>(DocumentStyle::AutoDarkTheme)); + this->ui->auto_theme->addItem(tr("Light Theme"), QVariant::fromValue<int>(DocumentStyle::AutoLightTheme)); this->ui->ui_theme->clear(); - this->ui->ui_theme->addItem("Light", QVariant::fromValue<int>(int(Theme::light))); - this->ui->ui_theme->addItem("Dark", QVariant::fromValue<int>(int(Theme::dark))); + this->ui->ui_theme->addItem(tr("OS Default"), QVariant::fromValue<int>(int(Theme::os_default))); + this->ui->ui_theme->addItem(tr("Light"), QVariant::fromValue<int>(int(Theme::light))); + this->ui->ui_theme->addItem(tr("Dark"), QVariant::fromValue<int>(int(Theme::dark))); setGeminiStyle(DocumentStyle { }); |
