Commit 670f3ec5 authored by Marco Martin's avatar Marco Martin

search for a default wallpaper in lookandfeel

Summary:
now look and feel packages can specify a default image wallpaper.
when a new containment is created at first plasma start or at activity creation
search for a default wallpaper inthe order:
look and feel package
if fails, from the plasma theme

we are sure to find a default after it as if neither of those specify one,
the wallpaper specified by the breeze plasma theme (Next) will be used

D21225 takes care of setting the wallpaper when a lnf theme is selected by the kcm

Test Plan:
tested to start plasma with an empty config file with different themes
that do or don't include wallpapers

Reviewers: #plasma, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: kossebau, davidedmundson, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D21226
parent 792dfe8f
......@@ -10,6 +10,9 @@ Theme=breeze
[plasmarc][Theme]
name=default
[Wallpaper]
Image=Next
[kcminputrc][Mouse]
cursorTheme=breeze_cursors
......
......@@ -279,11 +279,39 @@ KPackage::Package *Image::package()
void Image::useSingleImageDefaults()
{
Plasma::Theme theme;
m_wallpaper = theme.wallpaperPath();
int index = m_wallpaper.indexOf(QString::fromLatin1("/contents/images/"));
if (index > -1) { // We have file from package -> get path to package
m_wallpaper.truncate(index);
m_wallpaper = QString();
// Try from the look and feel package first, then from the plasma theme
KPackage::Package lookAndFeelPackage = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel"));
KConfigGroup cg(KSharedConfig::openConfig(QStringLiteral("kdeglobals")), "KDE");
const QString packageName = cg.readEntry("LookAndFeelPackage", QString());
// If empty, it will be the default (currently Breeze)
if (!packageName.isEmpty()) {
lookAndFeelPackage.setPath(packageName);
}
KConfigGroup lnfDefaultsConfig = KConfigGroup(KSharedConfig::openConfig(lookAndFeelPackage.filePath("defaults")), "Wallpaper");
const QString image = lnfDefaultsConfig.readEntry("Image", "");
if (!image.isEmpty()) {
KPackage::Package package = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Wallpaper/Images"));
package.setPath(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("wallpapers/") + image, QStandardPaths::LocateDirectory));
if (package.isValid()) {
m_wallpaper = package.path();
} else {
m_wallpaper = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("wallpapers/") + image);
}
}
// Try to get a default from the plasma theme
if (m_wallpaper.isEmpty()) {
Plasma::Theme theme;
m_wallpaper = theme.wallpaperPath();
int index = m_wallpaper.indexOf(QString::fromLatin1("/contents/images/"));
if (index > -1) { // We have file from package -> get path to package
m_wallpaper = m_wallpaper.left(index);
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment