summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2012-03-17 19:46:33 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-20 09:32:34 +0100
commitc4ac14fae1765cae9d5ab94c8af486e2d14dede7 (patch)
treee6e2b2d00d893e8176f080f0b9c69ecf905542f5
parent6d9f04422ac2b64e43f0e78c1fdb9ced29e4b187 (diff)
Fix KDE palette.
In QKdeTheme We want to load every color. Else, only the first color is loaded, and the rest of the palette is just black making the applications basicaly not usable. But KDE only put in its config files the colors that are different from the default colors. This is the reason why we need to resolve against the style's default palette. We need to make sure the resolve_mask is 0 for an empty palette, even before the application palette is set. This was not required in Qt4 because the system palette was initialized differently. I realize this will only work with QApplication (and not with a single QGuiApplication) but it was not working before either. Change-Id: Ifb3c2c1358ef6d83a1ca5aa8fac3d2d4ea712b94 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
-rw-r--r--src/gui/kernel/qpalette.cpp1
-rw-r--r--src/platformsupport/themes/genericunix/qgenericunixthemes.cpp32
-rw-r--r--src/widgets/kernel/qapplication.cpp13
3 files changed, 24 insertions, 22 deletions
diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp
index 9a2eb12e3f..ab62ec0992 100644
--- a/src/gui/kernel/qpalette.cpp
+++ b/src/gui/kernel/qpalette.cpp
@@ -524,6 +524,7 @@ QPalette::QPalette()
} else {
init();
qt_palette_from_color(*this, Qt::black);
+ resolve_mask = 0;
}
}
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
index 597dbde74f..5c57b0c12f 100644
--- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
@@ -136,21 +136,19 @@ static inline bool kdeColor(QPalette *pal, QPalette::ColorRole role,
return true;
}
-// Reads the KDE system palette
-static inline bool readKdeSystemPalette(const QSettings &kdeSettings, QPalette *pal)
+static inline void readKdeSystemPalette(const QSettings &kdeSettings, QPalette *pal)
{
- // Setup KDE palette
- 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"))
- || kdeColor(pal, QPalette::WindowText, kdeSettings, QStringLiteral("Colors:Window/ForegroundNormal"))
- || kdeColor(pal, QPalette::Base, kdeSettings, QStringLiteral("Colors:View/BackgroundNormal"))
- || kdeColor(pal, QPalette::Highlight, kdeSettings, QStringLiteral("Colors:Selection/BackgroundNormal"))
- || kdeColor(pal, QPalette::HighlightedText, kdeSettings, QStringLiteral("Colors:Selection/ForegroundNormal"))
- || kdeColor(pal, QPalette::AlternateBase, kdeSettings, QStringLiteral("Colors:View/BackgroundAlternate"))
- || 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::Button, kdeSettings, QStringLiteral("Colors:Button/BackgroundNormal"));
+ kdeColor(pal, QPalette::Window, kdeSettings, QStringLiteral("Colors:Window/BackgroundNormal"));
+ kdeColor(pal, QPalette::Text, kdeSettings, QStringLiteral("Colors:View/ForegroundNormal"));
+ kdeColor(pal, QPalette::WindowText, kdeSettings, QStringLiteral("Colors:Window/ForegroundNormal"));
+ kdeColor(pal, QPalette::Base, kdeSettings, QStringLiteral("Colors:View/BackgroundNormal"));
+ kdeColor(pal, QPalette::Highlight, kdeSettings, QStringLiteral("Colors:Selection/BackgroundNormal"));
+ kdeColor(pal, QPalette::HighlightedText, kdeSettings, QStringLiteral("Colors:Selection/ForegroundNormal"));
+ kdeColor(pal, QPalette::AlternateBase, kdeSettings, QStringLiteral("Colors:View/BackgroundAlternate"));
+ 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"));
}
/*!
@@ -215,9 +213,9 @@ void QKdeTheme::refresh()
const QSettings kdeSettings(settingsFile, QSettings::IniFormat);
- QPalette systemPalette;
- if (readKdeSystemPalette(kdeSettings, &systemPalette))
- m_resources.palettes[SystemPalette] = new QPalette(systemPalette);
+ QPalette systemPalette = QPalette();
+ readKdeSystemPalette(kdeSettings, &systemPalette);
+ m_resources.palettes[SystemPalette] = new QPalette(systemPalette);
//## TODO tooltip color
const QVariant styleValue = kdeSettings.value(QStringLiteral("widgetStyle"));
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 348eb2f343..7441d55865 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -130,14 +130,17 @@ QApplicationPrivate *QApplicationPrivate::self = 0;
static void initSystemPalette()
{
- if (!QApplicationPrivate::sys_pal)
+ if (!QApplicationPrivate::sys_pal) {
+ QPalette defaultPlatte;
+ if (QApplicationPrivate::app_style)
+ defaultPlatte = QApplicationPrivate::app_style->standardPalette();
if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette()) {
- QApplicationPrivate::setSystemPalette(*themePalette);
+ QApplicationPrivate::setSystemPalette(themePalette->resolve(defaultPlatte));
QApplicationPrivate::initializeWidgetPaletteHash();
+ } else {
+ QApplicationPrivate::setSystemPalette(defaultPlatte);
}
-
- if (!QApplicationPrivate::sys_pal && QApplicationPrivate::app_style)
- QApplicationPrivate::setSystemPalette(QApplicationPrivate::app_style->standardPalette());
+ }
}
static void clearSystemPalette()