QKdeTheme: generate sensible disabled colors for the system palette
Task-number: QTBUG-31670 Change-Id: Icbd2f35d9c2f5c1ef05c9dfeae4922be01ff2751 Reviewed-by: Dominik Holland <dominik.holland@pelagicore.com> Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>bb10
parent
2e49b79564
commit
bd4f92969a
|
|
@ -265,6 +265,14 @@ static inline bool kdeColor(QPalette *pal, QPalette::ColorRole role,
|
|||
|
||||
void QKdeThemePrivate::readKdeSystemPalette(const QSettings &kdeSettings, QPalette *pal)
|
||||
{
|
||||
if (!kdeSettings.contains(QStringLiteral("Colors:Button/BackgroundNormal"))) {
|
||||
// kcolorscheme.cpp: SetDefaultColors
|
||||
const QColor defaultWindowBackground(214, 210, 208);
|
||||
const QColor defaultButtonBackground(223, 220, 217);
|
||||
*pal = QPalette(defaultButtonBackground, defaultWindowBackground);
|
||||
return;
|
||||
}
|
||||
|
||||
kdeColor(pal, QPalette::Button, kdeSettings, QStringLiteral("Colors:Button/BackgroundNormal"));
|
||||
kdeColor(pal, QPalette::Window, kdeSettings, QStringLiteral("Colors:Window/BackgroundNormal"));
|
||||
kdeColor(pal, QPalette::Text, kdeSettings, QStringLiteral("Colors:View/ForegroundNormal"));
|
||||
|
|
@ -276,6 +284,34 @@ void QKdeThemePrivate::readKdeSystemPalette(const QSettings &kdeSettings, QPalet
|
|||
kdeColor(pal, QPalette::ButtonText, kdeSettings, QStringLiteral("Colors:Button/ForegroundNormal"));
|
||||
kdeColor(pal, QPalette::Link, kdeSettings, QStringLiteral("Colors:View/ForegroundLink"));
|
||||
kdeColor(pal, QPalette::LinkVisited, kdeSettings, QStringLiteral("Colors:View/ForegroundVisited"));
|
||||
kdeColor(pal, QPalette::ToolTipBase, kdeSettings, QStringLiteral("Colors:Tooltip/BackgroundNormal"));
|
||||
kdeColor(pal, QPalette::ToolTipText, kdeSettings, QStringLiteral("Colors:Tooltip/ForegroundNormal"));
|
||||
|
||||
// The above code sets _all_ color roles to "normal" colors. In KDE, the disabled
|
||||
// color roles are calculated by applying various effects described in kdeglobals.
|
||||
// We use a bit simpler approach here, similar logic than in qt_palette_from_color().
|
||||
const QColor button = pal->color(QPalette::Button);
|
||||
int h, s, v;
|
||||
button.getHsv(&h, &s, &v);
|
||||
|
||||
const QBrush whiteBrush = QBrush(Qt::white);
|
||||
const QBrush buttonBrush = QBrush(button);
|
||||
const QBrush buttonBrushDark = QBrush(button.darker(v > 128 ? 200 : 50));
|
||||
const QBrush buttonBrushDark150 = QBrush(button.darker(v > 128 ? 150 : 75));
|
||||
const QBrush buttonBrushLight150 = QBrush(button.lighter(v > 128 ? 150 : 75));
|
||||
|
||||
pal->setBrush(QPalette::Disabled, QPalette::WindowText, buttonBrushDark);
|
||||
pal->setBrush(QPalette::Disabled, QPalette::ButtonText, buttonBrushDark);
|
||||
pal->setBrush(QPalette::Disabled, QPalette::Button, buttonBrush);
|
||||
pal->setBrush(QPalette::Disabled, QPalette::Light, buttonBrushLight150);
|
||||
pal->setBrush(QPalette::Disabled, QPalette::Dark, buttonBrushDark);
|
||||
pal->setBrush(QPalette::Disabled, QPalette::Mid, buttonBrushDark150);
|
||||
pal->setBrush(QPalette::Disabled, QPalette::Text, buttonBrushDark);
|
||||
pal->setBrush(QPalette::Disabled, QPalette::BrightText, whiteBrush);
|
||||
pal->setBrush(QPalette::Disabled, QPalette::Base, buttonBrush);
|
||||
pal->setBrush(QPalette::Disabled, QPalette::Window, buttonBrush);
|
||||
pal->setBrush(QPalette::Disabled, QPalette::Highlight, buttonBrushDark150);
|
||||
pal->setBrush(QPalette::Disabled, QPalette::HighlightedText, buttonBrushLight150);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
Loading…
Reference in New Issue