]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
spns #39957: SALOME dark mode feature in Windows
authorMaximilien Siavelis <maximlien.siavelis@simulease.com>
Fri, 1 Dec 2023 14:32:13 +0000 (15:32 +0100)
committerNabil Ghodbane <nabil.ghodbane@cea.fr>
Wed, 28 Feb 2024 12:00:53 +0000 (13:00 +0100)
src/Session/SALOME_Session_Server.cxx

index 4812cf6fb6a8494eb55c893ab3c9ee43a7a9f919..d26f63bb1dfd73830d29a614a696866f365e6b69 100644 (file)
@@ -65,6 +65,8 @@
 #include <windows.h>
 #include <stdio.h>
 #include <shellapi.h>
+#include <QSettings>
+#include <QStyleFactory>
 #endif
 #include <time.h>
 #include <memory>
@@ -498,6 +500,37 @@ int AbstractGUIAppMain(int argc, char **argv)
   SetArgcArgv(argc,argv);
   Application app(argc, argv);
 
+#ifdef WIN32
+    QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",
+                    QSettings::NativeFormat);
+    if(settings.value("AppsUseLightTheme")==0){
+        app.setStyle(QStyleFactory::create("Fusion"));
+        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);
+        darkPalette.setColor(QPalette::PlaceholderText, Qt::white);
+        darkPalette.setColor(QPalette::NoRole, Qt::white);
+
+        app.setPalette(darkPalette);
+        app.setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }");
+    }
+#endif
   // Initialize Python (only once)
   // Note: Python forces setting locale LC_CTYPE to system one: setlocale(LC_CTYPE, "").
   char *py_argv[] = {(char *)""};