Skip to content

Commit 462b6f0

Browse files
committed
Add dark mode checker depending on Qt version
1 parent 703da09 commit 462b6f0

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/clientdlg.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,9 +1479,16 @@ void CClientDlg::SetMixerBoardDeco ( const ERecorderState newRecorderState, cons
14791479
}
14801480
else
14811481
{
1482-
if ( palette().color ( QPalette::Window ) == QColor::fromRgbF ( 0.196078, 0.196078, 0.196078, 1 ) )
1482+
#if QT_VERSION >= QT_VERSION_CHECK( 6, 5, 0 )
1483+
// for Qt 6.5.0 or later, we use the inbuilt cross platform color scheme picker.
1484+
if ( QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Dark )
1485+
#else
1486+
// for earlier versions, check darkmode as proposed in https://www.qt.io/blog/dark-mode-on-windows-11-with-qt-6.5
1487+
const QPalette defaultPalette;
1488+
if ( defaultPalette.color ( QPalette::WindowText ).lightness() > defaultPalette.color ( QPalette::Window ).lightness() )
1489+
#endif
14831490
{
1484-
// Dark mode on macOS/Linux needs a light color
1491+
// Dark mode needs a light color
14851492

14861493
sTitleStyle += "color: rgb(220,220,220); }";
14871494
}

src/clientdlg.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
#if QT_VERSION >= QT_VERSION_CHECK( 5, 6, 0 )
4343
# include <QVersionNumber>
4444
#endif
45+
#if QT_VERSION >= QT_VERSION_CHECK( 6, 5, 0 )
46+
# include <QStyleHints>
47+
#endif
4548
#include "global.h"
4649
#include "util.h"
4750
#include "client.h"

0 commit comments

Comments
 (0)