File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change 4040#include " modules/value-editor/valueviewmodel.h"
4141#include " qmlutils.h"
4242
43+ #ifdef Q_OS_WINDOWS
44+ #include < dwmapi.h>
45+ #endif
46+
4347Application::Application (int & argc, char ** argv)
4448 : QApplication(argc, argv),
4549 m_engine(this ),
@@ -405,6 +409,26 @@ void Application::updatePalette()
405409 return ;
406410 }
407411
408- m_engine.rootObjects ().at (0 )->setProperty (
409- " palette" , QGuiApplication::palette ());
412+ auto rootObject = m_engine.rootObjects ().at (0 );
413+
414+ rootObject->setProperty (" palette" , QGuiApplication::palette ());
415+
416+ #ifdef Q_OS_WINDOWS
417+ if (!isDarkThemeEnabled ()) return ;
418+
419+ auto window = qobject_cast<QWindow*>(rootObject);
420+
421+ if (window) {
422+ auto winHwnd = reinterpret_cast <HWND>(window->winId ());
423+ BOOL USE_DARK_MODE = true ;
424+ BOOL SET_IMMERSIVE_DARK_MODE_SUCCESS = SUCCEEDED (DwmSetWindowAttribute (
425+ winHwnd, 20 , &USE_DARK_MODE, sizeof (USE_DARK_MODE)));
426+
427+ if (SET_IMMERSIVE_DARK_MODE_SUCCESS) {
428+ // Dirty hack to re-draw window and apply darkmode color
429+ rootObject->setProperty (" visible" , false );
430+ rootObject->setProperty (" visible" , true );
431+ }
432+ }
433+ #endif
410434}
Original file line number Diff line number Diff line change @@ -94,6 +94,8 @@ win32 {
9494
9595 release : DESTDIR = ./../bin/windows/release
9696 debug : DESTDIR = ./../bin/windows/debug
97+
98+ LIBS += -ldwmapi
9799}
98100
99101unix :macx { # OSX
You can’t perform that action at this time.
0 commit comments