From 462b6f068b9158aec5f0cfb54c75ee012f3e555d Mon Sep 17 00:00:00 2001 From: ann0see <20726856+ann0see@users.noreply.github.com> Date: Mon, 30 Jun 2025 20:18:48 +0200 Subject: [PATCH] Add dark mode checker depending on Qt version --- src/clientdlg.cpp | 11 +++++++++-- src/clientdlg.h | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/clientdlg.cpp b/src/clientdlg.cpp index b7048155b1..98b557fd3d 100644 --- a/src/clientdlg.cpp +++ b/src/clientdlg.cpp @@ -1479,9 +1479,16 @@ void CClientDlg::SetMixerBoardDeco ( const ERecorderState newRecorderState, cons } else { - if ( palette().color ( QPalette::Window ) == QColor::fromRgbF ( 0.196078, 0.196078, 0.196078, 1 ) ) +#if QT_VERSION >= QT_VERSION_CHECK( 6, 5, 0 ) + // for Qt 6.5.0 or later, we use the inbuilt cross platform color scheme picker. + if ( QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Dark ) +#else + // for earlier versions, check darkmode as proposed in https://www.qt.io/blog/dark-mode-on-windows-11-with-qt-6.5 + const QPalette defaultPalette; + if ( defaultPalette.color ( QPalette::WindowText ).lightness() > defaultPalette.color ( QPalette::Window ).lightness() ) +#endif { - // Dark mode on macOS/Linux needs a light color + // Dark mode needs a light color sTitleStyle += "color: rgb(220,220,220); }"; } diff --git a/src/clientdlg.h b/src/clientdlg.h index ba01ea648e..378a85c12e 100644 --- a/src/clientdlg.h +++ b/src/clientdlg.h @@ -42,6 +42,9 @@ #if QT_VERSION >= QT_VERSION_CHECK( 5, 6, 0 ) # include #endif +#if QT_VERSION >= QT_VERSION_CHECK( 6, 5, 0 ) +# include +#endif #include "global.h" #include "util.h" #include "client.h"