Skip to content

Commit 39a595e

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

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/clientdlg.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,19 @@ void CClientDlg::SetMixerBoardDeco ( const ERecorderState newRecorderState, cons
14791479
}
14801480
else
14811481
{
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+
# if defined( Q_OS_WINDOWS )
1487+
// for windows only, check darkmode as proposed in https://www.qt.io/blog/dark-mode-on-windows-11-with-qt-6.5
1488+
const QPalette defaultPalette;
1489+
if ( defaultPalette.color ( QPalette::WindowText ).lightness() > defaultPalette.color ( QPalette::Window ).lightness() )
1490+
# else
14821491
if ( palette().color ( QPalette::Window ) == QColor::fromRgbF ( 0.196078, 0.196078, 0.196078, 1 ) )
1492+
# endif
1493+
#endif
1494+
14831495
{
14841496
// Dark mode on macOS/Linux needs a light color
14851497

src/clientdlg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#if QT_VERSION >= QT_VERSION_CHECK( 5, 6, 0 )
4343
# include <QVersionNumber>
4444
#endif
45+
4546
#include "global.h"
4647
#include "util.h"
4748
#include "client.h"

0 commit comments

Comments
 (0)