Salome HOME
Updated copyright comment
[modules/gui.git] / src / Session / SALOME_Session_Server.cxx
index 621fc466c4530577e30ea56b5ae1c2020d84239c..b4bd5c6116f9d9207e3cf77581dc7db8152c0dd6 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -20,9 +20,9 @@
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
+#include <ArgvKeeper.hxx>
 #include <Container_init_python.hxx> // this include must be the first one as it includes Python.h
 #include <Basics_Utils.hxx>
-#include <ConnectionManager_i.hxx>
 #include <OpUtil.hxx>
 #include <RegistryService.hxx>
 #include <SALOME_LifeCycleCORBA.hxx>
@@ -65,6 +65,8 @@
 #include <windows.h>
 #include <stdio.h>
 #include <shellapi.h>
+#include <QSettings>
+#include <QStyleFactory>
 #endif
 #include <time.h>
 #include <memory>
 #include <QTextStream>
 #include <QWaitCondition>
 
+#ifdef WIN32
+extern "C" {
+// For DWORD (see end of file)
+#include "windef.h"
+// Force high-performance graphics on dual-GPU systems
+  // http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf
+  __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
+  // https://community.amd.com/thread/169965
+  __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
+}
+#endif
+
 //! CORBA server for SALOME GUI session
 /*!
  * SALOME_Session_Server launches a SALOME session servant.
@@ -455,6 +469,7 @@ int AbstractGUIAppMain(int argc, char **argv)
 {
   using NamingServiceImplementation = typename GUI_APP_STYLE::NamingServiceImplementation;
   setSSLMode(GUI_APP_STYLE::SSL_MODE);
+  setGUIMode(true);
   GUI_APP_STYLE self;
   // Set-up application settings configuration (as for QSettings)
   // Note: these are default settings which can be customized (see below)
@@ -482,8 +497,40 @@ int AbstractGUIAppMain(int argc, char **argv)
 
   // Create Qt application instance: this should be done as early as possible!
   // Note: QApplication forces setting locale LC_ALL to system one: setlocale(LC_ALL, "").
+  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 *)""};
@@ -566,15 +613,14 @@ int AbstractGUIAppMain(int argc, char **argv)
   try
   {
     // ...create ORB, get RootPOA object, NamingService, etc.
-    ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
-    ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
     int orbArgc = 1;
     if (std::string(argv[1]).find("-ORBInitRef") != std::string::npos)
     {
       orbArgc = 3;
       remoteLauncher = true;
     }
-    orb = init(orbArgc, argv);
+    SetArgcArgv(orbArgc, argv);
+    orb = KERNEL::GetRefToORB();
 
     CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
     poa = PortableServer::POA::_narrow(obj);