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>
This commit is contained in:
parent
6d9f04422a
commit
c4ac14fae1
@ -524,6 +524,7 @@ QPalette::QPalette()
|
|||||||
} else {
|
} else {
|
||||||
init();
|
init();
|
||||||
qt_palette_from_color(*this, Qt::black);
|
qt_palette_from_color(*this, Qt::black);
|
||||||
|
resolve_mask = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,21 +136,19 @@ static inline bool kdeColor(QPalette *pal, QPalette::ColorRole role,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reads the KDE system palette
|
static inline void readKdeSystemPalette(const QSettings &kdeSettings, QPalette *pal)
|
||||||
static inline bool readKdeSystemPalette(const QSettings &kdeSettings, QPalette *pal)
|
|
||||||
{
|
{
|
||||||
// Setup KDE palette
|
kdeColor(pal, QPalette::Button, kdeSettings, QStringLiteral("Colors:Button/BackgroundNormal"));
|
||||||
return kdeColor(pal, QPalette::Button, kdeSettings, QStringLiteral("Colors:Button/BackgroundNormal"))
|
kdeColor(pal, QPalette::Window, kdeSettings, QStringLiteral("Colors:Window/BackgroundNormal"));
|
||||||
|| kdeColor(pal, QPalette::Window, kdeSettings, QStringLiteral("Colors:Window/BackgroundNormal"))
|
kdeColor(pal, QPalette::Text, kdeSettings, QStringLiteral("Colors:View/ForegroundNormal"));
|
||||||
|| kdeColor(pal, QPalette::Text, kdeSettings, QStringLiteral("Colors:View/ForegroundNormal"))
|
kdeColor(pal, QPalette::WindowText, kdeSettings, QStringLiteral("Colors:Window/ForegroundNormal"));
|
||||||
|| kdeColor(pal, QPalette::WindowText, kdeSettings, QStringLiteral("Colors:Window/ForegroundNormal"))
|
kdeColor(pal, QPalette::Base, kdeSettings, QStringLiteral("Colors:View/BackgroundNormal"));
|
||||||
|| kdeColor(pal, QPalette::Base, kdeSettings, QStringLiteral("Colors:View/BackgroundNormal"))
|
kdeColor(pal, QPalette::Highlight, kdeSettings, QStringLiteral("Colors:Selection/BackgroundNormal"));
|
||||||
|| kdeColor(pal, QPalette::Highlight, kdeSettings, QStringLiteral("Colors:Selection/BackgroundNormal"))
|
kdeColor(pal, QPalette::HighlightedText, kdeSettings, QStringLiteral("Colors:Selection/ForegroundNormal"));
|
||||||
|| kdeColor(pal, QPalette::HighlightedText, kdeSettings, QStringLiteral("Colors:Selection/ForegroundNormal"))
|
kdeColor(pal, QPalette::AlternateBase, kdeSettings, QStringLiteral("Colors:View/BackgroundAlternate"));
|
||||||
|| kdeColor(pal, QPalette::AlternateBase, kdeSettings, QStringLiteral("Colors:View/BackgroundAlternate"))
|
kdeColor(pal, QPalette::ButtonText, kdeSettings, QStringLiteral("Colors:Button/ForegroundNormal"));
|
||||||
|| kdeColor(pal, QPalette::ButtonText, kdeSettings, QStringLiteral("Colors:Button/ForegroundNormal"))
|
kdeColor(pal, QPalette::Link, kdeSettings, QStringLiteral("Colors:View/ForegroundLink"));
|
||||||
|| kdeColor(pal, QPalette::Link, kdeSettings, QStringLiteral("Colors:View/ForegroundLink"))
|
kdeColor(pal, QPalette::LinkVisited, kdeSettings, QStringLiteral("Colors:View/ForegroundVisited"));
|
||||||
|| kdeColor(pal, QPalette::LinkVisited, kdeSettings, QStringLiteral("Colors:View/ForegroundVisited"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -215,8 +213,8 @@ void QKdeTheme::refresh()
|
|||||||
|
|
||||||
const QSettings kdeSettings(settingsFile, QSettings::IniFormat);
|
const QSettings kdeSettings(settingsFile, QSettings::IniFormat);
|
||||||
|
|
||||||
QPalette systemPalette;
|
QPalette systemPalette = QPalette();
|
||||||
if (readKdeSystemPalette(kdeSettings, &systemPalette))
|
readKdeSystemPalette(kdeSettings, &systemPalette);
|
||||||
m_resources.palettes[SystemPalette] = new QPalette(systemPalette);
|
m_resources.palettes[SystemPalette] = new QPalette(systemPalette);
|
||||||
//## TODO tooltip color
|
//## TODO tooltip color
|
||||||
|
|
||||||
|
@ -130,14 +130,17 @@ QApplicationPrivate *QApplicationPrivate::self = 0;
|
|||||||
|
|
||||||
static void initSystemPalette()
|
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()) {
|
if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette()) {
|
||||||
QApplicationPrivate::setSystemPalette(*themePalette);
|
QApplicationPrivate::setSystemPalette(themePalette->resolve(defaultPlatte));
|
||||||
QApplicationPrivate::initializeWidgetPaletteHash();
|
QApplicationPrivate::initializeWidgetPaletteHash();
|
||||||
|
} else {
|
||||||
|
QApplicationPrivate::setSystemPalette(defaultPlatte);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!QApplicationPrivate::sys_pal && QApplicationPrivate::app_style)
|
|
||||||
QApplicationPrivate::setSystemPalette(QApplicationPrivate::app_style->standardPalette());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clearSystemPalette()
|
static void clearSystemPalette()
|
||||||
|
Loading…
Reference in New Issue
Block a user