summaryrefslogtreecommitdiffhomepage
path: root/gui
diff options
context:
space:
mode:
authorStéphane Lenclud <github@lenclud.com>2020-09-15 17:36:56 +0200
committerStéphane Lenclud <github@lenclud.com>2020-09-20 13:24:24 +0200
commit32c8c82b963e349a8345a24c7a5e3597632c2f9c (patch)
tree1e1426a2a71429ebf29bb0cfbfb0f2ad66d0d4dd /gui
parentabb14f0ba4ef4c072ae330bcefa0419b701bc88b (diff)
Apply dark theme on Windows if user enabled it in system settings.feature_windows_dark_theme
Diffstat (limited to 'gui')
-rw-r--r--gui/init.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/gui/init.cpp b/gui/init.cpp
index 3aae5772..2b7b01ad 100644
--- a/gui/init.cpp
+++ b/gui/init.cpp
@@ -159,6 +159,39 @@ static void qdebug_to_console(QtMsgType loglevel, const QMessageLogContext& ctx,
#ifdef _WIN32
+static void apply_dark_windows_theme_if_needed()
+{
+ // On Windows apply dark theme if requested by user settings
+ QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", QSettings::NativeFormat);
+ if (settings.value("AppsUseLightTheme") == 0) {
+ qApp->setStyle(QStyleFactory::create("Dark"));
+ QPalette darkPalette;
+ QColor darkColor = QColor(45, 45, 45);
+ QColor disabledColor = QColor(127, 127, 127);
+ darkPalette.setColor(QPalette::Window, darkColor);
+ darkPalette.setColor(QPalette::WindowText, Qt::white);
+ darkPalette.setColor(QPalette::Base, QColor(18, 18, 18));
+ darkPalette.setColor(QPalette::AlternateBase, darkColor);
+ darkPalette.setColor(QPalette::ToolTipBase, Qt::white);
+ darkPalette.setColor(QPalette::ToolTipText, Qt::white);
+ darkPalette.setColor(QPalette::Text, Qt::white);
+ darkPalette.setColor(QPalette::Disabled, QPalette::Text, disabledColor);
+ darkPalette.setColor(QPalette::Button, darkColor);
+ darkPalette.setColor(QPalette::ButtonText, Qt::white);
+ darkPalette.setColor(QPalette::Disabled, QPalette::ButtonText, disabledColor);
+ darkPalette.setColor(QPalette::BrightText, Qt::red);
+ darkPalette.setColor(QPalette::Link, QColor(42, 130, 218));
+
+ darkPalette.setColor(QPalette::Highlight, QColor(42, 130, 218));
+ darkPalette.setColor(QPalette::HighlightedText, Qt::black);
+ darkPalette.setColor(QPalette::Disabled, QPalette::HighlightedText, disabledColor);
+
+ qApp->setPalette(darkPalette);
+
+ qApp->setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }");
+ }
+}
+
static void add_win32_path()
{
// see https://software.intel.com/en-us/articles/limitation-to-the-length-of-the-system-path-variable
@@ -270,6 +303,7 @@ int otr_main(int argc, char** argv, std::function<std::unique_ptr<QWidget>()> co
QApplication app(argc, argv);
#ifdef _WIN32
+ apply_dark_windows_theme_if_needed();
add_win32_path();
attach_parent_console();
#endif