summaryrefslogtreecommitdiffstats
path: root/src/platformsupport
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2013-06-13 19:42:32 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-06-16 10:57:40 +0200
commitbd4f92969af2b8b11dcd631d408550a858a63f8a (patch)
treebd0250f44074562071a0d9e3c50352d455a84975 /src/platformsupport
parent2e49b795645908079ec19c28f4ca025084d137ef (diff)
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>
Diffstat (limited to 'src/platformsupport')
-rw-r--r--src/platformsupport/themes/genericunix/qgenericunixthemes.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
index be21e39ecd..fdd45a49c5 100644
--- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
@@ -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);
}
/*!