mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-20 23:47:23 -06: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:
committed by
Vladimir Golovnev (Glassez)
parent
5e105b0348
commit
39b965af48
@@ -47,16 +47,9 @@ namespace
|
|||||||
{
|
{
|
||||||
bool isDarkTheme()
|
bool isDarkTheme()
|
||||||
{
|
{
|
||||||
switch (qApp->styleHints()->colorScheme())
|
const QPalette palette = qApp->palette();
|
||||||
{
|
const QColor &color = palette.color(QPalette::Active, QPalette::Base);
|
||||||
case Qt::ColorScheme::Dark:
|
return (color.lightness() < 127);
|
||||||
return true;
|
|
||||||
case Qt::ColorScheme::Light:
|
|
||||||
return false;
|
|
||||||
default:
|
|
||||||
// fallback to custom method
|
|
||||||
return (qApp->palette().color(QPalette::Active, QPalette::Base).lightness() < 127);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user