mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-21 16:55:46 +03:00
Check real palette darkness to detect "dark theme"
`QStyleHints::colorScheme()` returns chosen color scheme even if current style doesn't support it and uses different palette. PR #21771.
This commit is contained in:
parent
a6c7aef6c1
commit
4bec9b90c4
1 changed files with 3 additions and 10 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue