Skip to content

Commit

Permalink
Check real palette darkness to detect "dark theme"
Browse files Browse the repository at this point in the history
`QStyleHints::colorScheme()` returns chosen color scheme even if current style doesn't support it and uses different palette.

PR qbittorrent#21771.
  • Loading branch information
glassez authored Nov 8, 2024
1 parent a6c7aef commit 4bec9b9
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/gui/uithememanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,9 @@ namespace
{
bool isDarkTheme()
{
switch (qApp->styleHints()->colorScheme())
{
case Qt::ColorScheme::Dark:
return true;
case Qt::ColorScheme::Light:
return false;
default:
// fallback to custom method
return (qApp->palette().color(QPalette::Active, QPalette::Base).lightness() < 127);
}
const QPalette palette = qApp->palette();
const QColor &color = palette.color(QPalette::Active, QPalette::Base);
return (color.lightness() < 127);
}
}

Expand Down

0 comments on commit 4bec9b9

Please sign in to comment.