From: Maximilien Siavelis Date: Fri, 1 Dec 2023 14:32:13 +0000 (+0100) Subject: spns #39957: SALOME dark mode feature in Windows X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b606ff2d9b27a723c9411c5532d22fc04f3ebe1e;p=modules%2Fgui.git spns #39957: SALOME dark mode feature in Windows --- diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index 4812cf6fb..d26f63bb1 100644 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -65,6 +65,8 @@ #include #include #include +#include +#include #endif #include #include @@ -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 *)""};