export a plasma version number in themes

some of the behavior of the theme has changed.
this makes some of the old themes to not work correctly
(like black text on black)
read a version number of the "plasma version this theme has been intended for"
and use it to change the behavior for retrocompatibility
(all themes that don't export this are assumed to be from KDE4)

Change-Id: I4bc20a0c10de9f9a6c3facd63b6c5b6da210039a
This commit is contained in:
Marco Martin 2014-12-02 14:23:30 +01:00
parent 15547cd885
commit 0ca29bc0f2
6 changed files with 40 additions and 1 deletions

View File

@ -86,6 +86,7 @@ X-KDE-PluginInfo-Category=
X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true X-KDE-PluginInfo-EnabledByDefault=true
X-Plasma-API=5.0
[Wallpaper] [Wallpaper]
defaultWallpaperTheme=Elarun defaultWallpaperTheme=Elarun

View File

@ -41,6 +41,7 @@ X-KDE-PluginInfo-Category=
X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=LGPL X-KDE-PluginInfo-License=LGPL
X-KDE-PluginInfo-EnabledByDefault=true X-KDE-PluginInfo-EnabledByDefault=true
X-Plasma-API=5.0
[Wallpaper] [Wallpaper]
defaultWallpaperTheme=Next defaultWallpaperTheme=Next

View File

@ -43,6 +43,7 @@ X-KDE-PluginInfo-Category=
X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=LGPL X-KDE-PluginInfo-License=LGPL
X-KDE-PluginInfo-EnabledByDefault=true X-KDE-PluginInfo-EnabledByDefault=true
X-Plasma-API=5.0
[Wallpaper] [Wallpaper]
defaultWallpaperTheme=Next defaultWallpaperTheme=Next

View File

@ -82,6 +82,7 @@ X-KDE-PluginInfo-Category=
X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true X-KDE-PluginInfo-EnabledByDefault=true
X-Plasma-API=5.0
[Wallpaper] [Wallpaper]
defaultWallpaperTheme=Elarun defaultWallpaperTheme=Elarun

View File

@ -66,7 +66,10 @@ ThemePrivate::ThemePrivate(QObject *parent)
useGlobal(true), useGlobal(true),
hasWallpapers(false), hasWallpapers(false),
fixedName(false), fixedName(false),
backgroundContrastEnabled(true) backgroundContrastEnabled(true),
apiMajor(1),
apiMinor(0),
apiRevision(0)
{ {
ThemeConfig config; ThemeConfig config;
cacheTheme = config.cacheTheme(); cacheTheme = config.cacheTheme();
@ -532,6 +535,13 @@ QColor ThemePrivate::color(Theme::ColorRole role, Theme::ColorGroup group) const
{ {
const KColorScheme *scheme = 0; const KColorScheme *scheme = 0;
//Before 5.0 Plasma theme really only used Normal and Button
//many old themes are built on this assumption and will break
//otherwise
if (apiMajor < 5 && group != Theme::NormalColorGroup) {
group = Theme::ButtonColorGroup;
}
switch (group) { switch (group) {
case Theme::ButtonColorGroup: { case Theme::ButtonColorGroup: {
scheme = &buttonColorScheme; scheme = &buttonColorScheme;
@ -796,6 +806,26 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings
KConfig metadata(metadataPath); KConfig metadata(metadataPath);
processWallpaperSettings(&metadata); processWallpaperSettings(&metadata);
} }
//Check for what Plasma version the theme has been done
//There are some behavioral differences between KDE4 Plasma and Plasma 5
cg = KConfigGroup(&metadata, "Desktop Entry");
const QString apiVersion = cg.readEntry("X-Plasma-API", QString());
apiMajor = 1;
apiMinor = 0;
apiRevision = 0;
if (!apiVersion.isEmpty()) {
QStringList parts = apiVersion.split('.');
if (!parts.isEmpty()) {
apiMajor = parts.value(0).toInt();
}
if (parts.count() > 1) {
apiMinor = parts.value(1).toInt();
}
if (parts.count() > 2) {
apiRevision = parts.value(2).toInt();
}
}
} }
if (realTheme && isDefault && writeSettings) { if (realTheme && isDefault && writeSettings) {

View File

@ -153,6 +153,11 @@ public:
qreal backgroundIntensity; qreal backgroundIntensity;
qreal backgroundSaturation; qreal backgroundSaturation;
bool backgroundContrastEnabled; bool backgroundContrastEnabled;
//Version number of Plasma the Theme has been designed for
int apiMajor;
int apiMinor;
int apiRevision;
}; };
} }