diff --git a/SettingsStore.cpp b/SettingsStore.cpp index 734a595..441b0b1 100644 --- a/SettingsStore.cpp +++ b/SettingsStore.cpp @@ -37,6 +37,7 @@ static QString KEY_UI_DICTIONARY = SETTINGS_GROUP + "/" + "ui_dictionary"; static QString KEY_UI_FONT = SETTINGS_GROUP + "/" + "ui_font"; static QString KEY_ORIGINAL_UI_FONT = SETTINGS_GROUP + "/" + "original_ui_font"; +static QString KEY_UI_CUSTOM_DARK_THEME = SETTINGS_GROUP + "/" + "ui_custom_dark_theme"; static QString KEY_HIGHDPI_SETTING = SETTINGS_GROUP + "/" + "high_dpi"; static QString KEY_DISABLEGPU_SETTING = SETTINGS_GROUP + "/" + "disable_gpu"; @@ -145,6 +146,12 @@ bool SettingsStore::spellCheck() } #endif +bool SettingsStore::uiUseCustomDarkTheme() +{ + clearSettingsGroup(); + return value(KEY_UI_CUSTOM_DARK_THEME, true).toBool(); +} + float SettingsStore::zoomImage() { clearSettingsGroup(); @@ -304,6 +311,12 @@ void SettingsStore::setSpellCheck(bool enabled) } #endif +void SettingsStore::setUiUseCustomDarkTheme(bool enable) +{ + clearSettingsGroup(); + setValue(KEY_UI_CUSTOM_DARK_THEME, enable); +} + void SettingsStore::setZoomImage(float zoom) { clearSettingsGroup(); diff --git a/SettingsStore.h b/SettingsStore.h index a1d0c11..70d9d9e 100644 --- a/SettingsStore.h +++ b/SettingsStore.h @@ -69,6 +69,8 @@ class SettingsStore : public QSettings // bool spellCheck(); + bool uiUseCustomDarkTheme(); + /** * The zoom factor used by the component. * @@ -157,6 +159,8 @@ public slots: // void setSpellCheck(bool enabled); + void setUiUseCustomDarkTheme(bool enable); + /** * Set the zoom factor used by the component. * diff --git a/main.cpp b/main.cpp index 779ee77..8a24c3f 100644 --- a/main.cpp +++ b/main.cpp @@ -262,6 +262,12 @@ int main(int argc, char *argv[]) #ifdef Q_OS_WIN32 QStyle* astyle = QStyleFactory::create("fusion"); app.setStyle(astyle); + // Use our custom Windows dark theme unless user opts-in with preference + if (Utility::WindowsShouldUseDarkMode() && settings.uiUseCustomDarkTheme()) { + // Apply custom dark style + app.setStyle(new PEDarkStyle); + app.setPalette(QApplication::style()->standardPalette()); + } #endif // Q_OS_WIN32 #if !defined(Q_OS_MAC) && !defined(Q_OS_WIN32) // *nix @@ -270,14 +276,6 @@ int main(int argc, char *argv[]) app.setStyle(astyle); #endif // *nix -#ifndef Q_OS_MAC - if (Utility::WindowsShouldUseDarkMode()) { - // Apply custom dark style - app.setStyle(new PEDarkStyle); - app.setPalette(QApplication::style()->standardPalette()); - } -#endif - // it seems that any time there is stylesheet used, system dark-light palette // changes are not propagated to widgets with stylesheets (See QTBUG-124268). // This in turn prevents some widgets from properly geting repainted with the new