diff --git a/0001-take-the-proper-default-at-first-start.patch b/0001-take-the-proper-default-at-first-start.patch new file mode 100644 index 0000000..17bac86 --- /dev/null +++ b/0001-take-the-proper-default-at-first-start.patch @@ -0,0 +1,30 @@ +From 3b2d770df42def293dbf4fed6bc2a1431b78490d Mon Sep 17 00:00:00 2001 +From: Marco Martin +Date: Fri, 26 Sep 2014 15:43:22 +0200 +Subject: [PATCH 1/1] take the proper default at first start + +wallpaper.configuration.Image is empty at first start, but the +image wallpaper object has the proper default + +BUG:339414 +--- + wallpapers/image/imagepackage/contents/ui/main.qml | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/wallpapers/image/imagepackage/contents/ui/main.qml b/wallpapers/image/imagepackage/contents/ui/main.qml +index 3ec8391..d81bd29 100644 +--- a/wallpapers/image/imagepackage/contents/ui/main.qml ++++ b/wallpapers/image/imagepackage/contents/ui/main.qml +@@ -86,6 +86,9 @@ Rectangle { + } + + Component.onCompleted: { ++ if (!configuredImage && imageWallpaper.wallpaperPath) { ++ return; ++ } + imageWallpaper.addUrl(configuredImage) + if (wallpaper.pluginName == "org.kde.slideshow") { + wallpaper.setAction("next", i18nd("plasma_applet_org.kde.image","Next Wallpaper Image"),"user-desktop"); +-- +2.1.0 + diff --git a/plasma5-workspace-rpmlintrc b/plasma5-workspace-rpmlintrc new file mode 100644 index 0000000..cc4ae51 --- /dev/null +++ b/plasma5-workspace-rpmlintrc @@ -0,0 +1,2 @@ +# we don't use find_lang macro as it doesn't searches in subdirectories +addFilter("file-not-in-%lang .*") \ No newline at end of file diff --git a/plasma5-workspace.changes b/plasma5-workspace.changes index e3d054f..35ed1e8 100644 --- a/plasma5-workspace.changes +++ b/plasma5-workspace.changes @@ -4,6 +4,10 @@ Fri Sep 26 09:20:21 UTC 2014 - hrvoje.senjan@gmail.com - Update to 5.0.95: * No changes since previous snapshot - Install translations +- Add rpmlintrc file for file-not-in-%lang warnings: we don't use + find_lang macro as it doesn't searches in subdirectories +- Swap wallpaper.diff for 0001-take-the-proper-default-at-first-start.patch + it is a simpler solution (kde#339216, kde#339414) ------------------------------------------------------------------- Tue Sep 23 20:24:35 UTC 2014 - hrvoje.senjan@gmail.com diff --git a/plasma5-workspace.spec b/plasma5-workspace.spec index 18910aa..5fa7a3d 100644 --- a/plasma5-workspace.spec +++ b/plasma5-workspace.spec @@ -25,14 +25,15 @@ Group: System/GUI/KDE Url: http://www.kde.org/ Source: plasma-workspace-%{version}.tar.xz Source1: baselibs.conf +Source99: %{name}-rpmlintrc # PATCH-FIX_OPENSUSE 0001-Rename-qdbus-in-startkde.patch cgiboudeaux@gmx.com -- Rename the qdbus executable in startkde Patch0: 0001-Rename-qdbus-in-startkde.patch # PATCH-FIX_OPENSUSE create_kdehome.patch -- https://bugs.kde.org/show_bug.cgi?id=338422#c8 Patch1: create_kdehome.patch # PATCH-FIX_OPENSUSE 0003-Remove-export-of-QT_PLUGIN_PATH.patch -- we install plugins to directory known to Qt5, so export just pollutes both Qt4 and Qt5 plugins Patch2: 0003-Remove-export-of-QT_PLUGIN_PATH.patch -# PATCH-FIX_OPENSUSE wallpaper.diff -- kde#339216 -Patch3: wallpaper.diff +# PATCH-FIX_UPSTREAM 0001-take-the-proper-default-at-first-start.patch -- kde#339216, kde#339414 +Patch3: 0001-take-the-proper-default-at-first-start.patch BuildRequires: alsa-devel BuildRequires: baloo5-devel >= 5.0.0 BuildRequires: kactivities5-devel >= 5.0.0 @@ -306,7 +307,6 @@ workspace. Development files. %files lang %defattr(-,root,root) -%doc COPYING* %{_kf5_localedir}/ %changelog diff --git a/wallpaper.diff b/wallpaper.diff deleted file mode 100644 index adc1b49..0000000 --- a/wallpaper.diff +++ /dev/null @@ -1,1308 +0,0 @@ -diff --git a/shell/packageplugins/CMakeLists.txt b/shell/packageplugins/CMakeLists.txt -index 54b8c89..16ea8c0 100644 ---- a/shell/packageplugins/CMakeLists.txt -+++ b/shell/packageplugins/CMakeLists.txt -@@ -1,5 +1,4 @@ - add_subdirectory(layouttemplate) - add_subdirectory(lookandfeel) - add_subdirectory(shell) --add_subdirectory(qmlWallpaper) --add_subdirectory(wallpaperimages) -+add_subdirectory(wallpaper) -diff --git a/shell/packageplugins/qmlWallpaper/CMakeLists.txt b/shell/packageplugins/qmlWallpaper/CMakeLists.txt -deleted file mode 100644 -index 5f9f871..0000000 ---- a/shell/packageplugins/qmlWallpaper/CMakeLists.txt -+++ /dev/null -@@ -1,17 +0,0 @@ --add_definitions(-DTRANSLATION_DOMAIN=\"plasma_package_wallpaper\") -- --set(wallpaper_SRCS -- wallpaper.cpp --) -- --add_library(plasma_packagestructure_wallpaper MODULE ${wallpaper_SRCS}) -- --target_link_libraries(plasma_packagestructure_wallpaper -- KF5::Declarative -- KF5::I18n -- KF5::Plasma --) -- --kservice_desktop_to_json(plasma_packagestructure_wallpaper plasma-packagestructure-wallpaper.desktop) -- --install(TARGETS plasma_packagestructure_wallpaper DESTINATION ${PLUGIN_INSTALL_DIR}/plasma/packagestructure) -diff --git a/shell/packageplugins/qmlWallpaper/plasma-packagestructure-wallpaper.desktop b/shell/packageplugins/qmlWallpaper/plasma-packagestructure-wallpaper.desktop -deleted file mode 100644 -index bb6ce31..0000000 ---- a/shell/packageplugins/qmlWallpaper/plasma-packagestructure-wallpaper.desktop -+++ /dev/null -@@ -1,36 +0,0 @@ --[Desktop Entry] --Name=Wallpaper --Name[ca]=Fons d'escriptori --Name[cs]=Tapeta --Name[da]=Baggrundsbillede --Name[de]=Hintergrundbild --Name[en_GB]=Wallpaper --Name[es]=Fondo del escritorio --Name[fi]=Tausta --Name[hu]=Háttérkép --Name[ko]=배경 그림 --Name[nb]=Tapet --Name[nds]=Achtergrundbild --Name[nl]=Achtergrondafbeelding --Name[pl]=Tapeta --Name[pt]=Papel de Parede --Name[pt_BR]=Papel de parede --Name[ru]=Обои --Name[sk]=Tapeta --Name[sl]=Slika ozadja --Name[sr]=Тапет --Name[sr@ijekavian]=Тапет --Name[sr@ijekavianlatin]=Tapet --Name[sr@latin]=Tapet --Name[sv]=Skrivbordsunderlägg --Name[uk]=Зображення тла --Name[x-test]=xxWallpaperxx --Name[zh_TW]=桌布 --Type=Service --X-KDE-ServiceTypes=Plasma/PackageStructure --X-KDE-Library=plasma_packagestructure_wallpaper -- --X-KDE-PluginInfo-Author=Marco Martin --X-KDE-PluginInfo-Email=notmart@gmail.com --X-KDE-PluginInfo-Name=Plasma/Wallpaper --X-KDE-PluginInfo-Version=1 -diff --git a/shell/packageplugins/qmlWallpaper/wallpaper.cpp b/shell/packageplugins/qmlWallpaper/wallpaper.cpp -deleted file mode 100644 -index 4aa8c2a..0000000 ---- a/shell/packageplugins/qmlWallpaper/wallpaper.cpp -+++ /dev/null -@@ -1,72 +0,0 @@ --/****************************************************************************** --* Copyright 2007-2009 by Aaron Seigo * --* Copyright 2013 by Sebastian Kügler * --* * --* This library is free software; you can redistribute it and/or * --* modify it under the terms of the GNU Library General Public * --* License as published by the Free Software Foundation; either * --* version 2 of the License, or (at your option) any later version. * --* * --* This library is distributed in the hope that it will be useful, * --* but WITHOUT ANY WARRANTY; without even the implied warranty of * --* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * --* Library General Public License for more details. * --* * --* You should have received a copy of the GNU Library General Public License * --* along with this library; see the file COPYING.LIB. If not, write to * --* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * --* Boston, MA 02110-1301, USA. * --*******************************************************************************/ -- --#include "wallpaper.h" -- -- --#include --#include -- --void QmlWallpaperPackage::initPackage(Plasma::Package *package) --{ -- package->addFileDefinition("mainscript", "ui/main.qml", i18n("Main Script File")); -- package->setRequired("mainscript", true); -- -- QStringList platform = KDeclarative::KDeclarative::runtimePlatform(); -- if (!platform.isEmpty()) { -- QMutableStringListIterator it(platform); -- while (it.hasNext()) { -- it.next(); -- it.setValue("platformcontents/" + it.value()); -- } -- -- platform.append("contents"); -- package->setContentsPrefixPaths(platform); -- } -- -- package->setDefaultPackageRoot("plasma/wallpapers/"); -- -- package->addDirectoryDefinition("images", "images", i18n("Images")); -- package->addDirectoryDefinition("theme", "theme", i18n("Themed Images")); -- QStringList mimetypes; -- mimetypes << "image/svg+xml" << "image/png" << "image/jpeg"; -- package->setMimeTypes("images", mimetypes); -- package->setMimeTypes("theme", mimetypes); -- -- package->addDirectoryDefinition("config", "config", i18n("Configuration Definitions")); -- mimetypes.clear(); -- mimetypes << "text/xml"; -- package->setMimeTypes("config", mimetypes); -- -- package->addDirectoryDefinition("ui", "ui", i18n("User Interface")); -- -- package->addDirectoryDefinition("data", "data", i18n("Data Files")); -- -- package->addDirectoryDefinition("scripts", "code", i18n("Executable Scripts")); -- mimetypes.clear(); -- mimetypes << "text/plain"; -- package->setMimeTypes("scripts", mimetypes); -- -- package->addDirectoryDefinition("translations", "locale", i18n("Translations")); --} -- --K_EXPORT_PLASMA_PACKAGE_WITH_JSON(QmlWallpaperPackage, "plasma-packagestructure-wallpaper.json") -- --#include "wallpaper.moc" -diff --git a/shell/packageplugins/qmlWallpaper/wallpaper.h b/shell/packageplugins/qmlWallpaper/wallpaper.h -deleted file mode 100644 -index f3cd5d6..0000000 ---- a/shell/packageplugins/qmlWallpaper/wallpaper.h -+++ /dev/null -@@ -1,34 +0,0 @@ --/****************************************************************************** --* Copyright 2007 by Aaron Seigo * --* Copyright 2013 by Marco Martin * --* Copyright 2013 by Sebastian Kügler * --* * --* This library is free software; you can redistribute it and/or * --* modify it under the terms of the GNU Library General Public * --* License as published by the Free Software Foundation; either * --* version 2 of the License, or (at your option) any later version. * --* * --* This library is distributed in the hope that it will be useful, * --* but WITHOUT ANY WARRANTY; without even the implied warranty of * --* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * --* Library General Public License for more details. * --* * --* You should have received a copy of the GNU Library General Public License * --* along with this library; see the file COPYING.LIB. If not, write to * --* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * --* Boston, MA 02110-1301, USA. * --*******************************************************************************/ -- --#ifndef WALLPAPER_H --#define WALLPAPER_H -- --#include -- --class QmlWallpaperPackage : public Plasma::PackageStructure --{ --public: -- QmlWallpaperPackage(QObject*, const QVariantList &) {} -- void initPackage(Plasma::Package *package); --}; -- --#endif -diff --git a/shell/packageplugins/wallpaper/CMakeLists.txt b/shell/packageplugins/wallpaper/CMakeLists.txt -new file mode 100644 -index 0000000..5f9f871 ---- /dev/null -+++ b/shell/packageplugins/wallpaper/CMakeLists.txt -@@ -0,0 +1,17 @@ -+add_definitions(-DTRANSLATION_DOMAIN=\"plasma_package_wallpaper\") -+ -+set(wallpaper_SRCS -+ wallpaper.cpp -+) -+ -+add_library(plasma_packagestructure_wallpaper MODULE ${wallpaper_SRCS}) -+ -+target_link_libraries(plasma_packagestructure_wallpaper -+ KF5::Declarative -+ KF5::I18n -+ KF5::Plasma -+) -+ -+kservice_desktop_to_json(plasma_packagestructure_wallpaper plasma-packagestructure-wallpaper.desktop) -+ -+install(TARGETS plasma_packagestructure_wallpaper DESTINATION ${PLUGIN_INSTALL_DIR}/plasma/packagestructure) -diff --git a/shell/packageplugins/wallpaper/plasma-packagestructure-wallpaper.desktop b/shell/packageplugins/wallpaper/plasma-packagestructure-wallpaper.desktop -new file mode 100644 -index 0000000..bb6ce31 ---- /dev/null -+++ b/shell/packageplugins/wallpaper/plasma-packagestructure-wallpaper.desktop -@@ -0,0 +1,36 @@ -+[Desktop Entry] -+Name=Wallpaper -+Name[ca]=Fons d'escriptori -+Name[cs]=Tapeta -+Name[da]=Baggrundsbillede -+Name[de]=Hintergrundbild -+Name[en_GB]=Wallpaper -+Name[es]=Fondo del escritorio -+Name[fi]=Tausta -+Name[hu]=Háttérkép -+Name[ko]=배경 그림 -+Name[nb]=Tapet -+Name[nds]=Achtergrundbild -+Name[nl]=Achtergrondafbeelding -+Name[pl]=Tapeta -+Name[pt]=Papel de Parede -+Name[pt_BR]=Papel de parede -+Name[ru]=Обои -+Name[sk]=Tapeta -+Name[sl]=Slika ozadja -+Name[sr]=Тапет -+Name[sr@ijekavian]=Тапет -+Name[sr@ijekavianlatin]=Tapet -+Name[sr@latin]=Tapet -+Name[sv]=Skrivbordsunderlägg -+Name[uk]=Зображення тла -+Name[x-test]=xxWallpaperxx -+Name[zh_TW]=桌布 -+Type=Service -+X-KDE-ServiceTypes=Plasma/PackageStructure -+X-KDE-Library=plasma_packagestructure_wallpaper -+ -+X-KDE-PluginInfo-Author=Marco Martin -+X-KDE-PluginInfo-Email=notmart@gmail.com -+X-KDE-PluginInfo-Name=Plasma/Wallpaper -+X-KDE-PluginInfo-Version=1 -diff --git a/shell/packageplugins/wallpaper/wallpaper.cpp b/shell/packageplugins/wallpaper/wallpaper.cpp -new file mode 100644 -index 0000000..4aa8c2a ---- /dev/null -+++ b/shell/packageplugins/wallpaper/wallpaper.cpp -@@ -0,0 +1,72 @@ -+/****************************************************************************** -+* Copyright 2007-2009 by Aaron Seigo * -+* Copyright 2013 by Sebastian Kügler * -+* * -+* This library is free software; you can redistribute it and/or * -+* modify it under the terms of the GNU Library General Public * -+* License as published by the Free Software Foundation; either * -+* version 2 of the License, or (at your option) any later version. * -+* * -+* This library is distributed in the hope that it will be useful, * -+* but WITHOUT ANY WARRANTY; without even the implied warranty of * -+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * -+* Library General Public License for more details. * -+* * -+* You should have received a copy of the GNU Library General Public License * -+* along with this library; see the file COPYING.LIB. If not, write to * -+* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * -+* Boston, MA 02110-1301, USA. * -+*******************************************************************************/ -+ -+#include "wallpaper.h" -+ -+ -+#include -+#include -+ -+void QmlWallpaperPackage::initPackage(Plasma::Package *package) -+{ -+ package->addFileDefinition("mainscript", "ui/main.qml", i18n("Main Script File")); -+ package->setRequired("mainscript", true); -+ -+ QStringList platform = KDeclarative::KDeclarative::runtimePlatform(); -+ if (!platform.isEmpty()) { -+ QMutableStringListIterator it(platform); -+ while (it.hasNext()) { -+ it.next(); -+ it.setValue("platformcontents/" + it.value()); -+ } -+ -+ platform.append("contents"); -+ package->setContentsPrefixPaths(platform); -+ } -+ -+ package->setDefaultPackageRoot("plasma/wallpapers/"); -+ -+ package->addDirectoryDefinition("images", "images", i18n("Images")); -+ package->addDirectoryDefinition("theme", "theme", i18n("Themed Images")); -+ QStringList mimetypes; -+ mimetypes << "image/svg+xml" << "image/png" << "image/jpeg"; -+ package->setMimeTypes("images", mimetypes); -+ package->setMimeTypes("theme", mimetypes); -+ -+ package->addDirectoryDefinition("config", "config", i18n("Configuration Definitions")); -+ mimetypes.clear(); -+ mimetypes << "text/xml"; -+ package->setMimeTypes("config", mimetypes); -+ -+ package->addDirectoryDefinition("ui", "ui", i18n("User Interface")); -+ -+ package->addDirectoryDefinition("data", "data", i18n("Data Files")); -+ -+ package->addDirectoryDefinition("scripts", "code", i18n("Executable Scripts")); -+ mimetypes.clear(); -+ mimetypes << "text/plain"; -+ package->setMimeTypes("scripts", mimetypes); -+ -+ package->addDirectoryDefinition("translations", "locale", i18n("Translations")); -+} -+ -+K_EXPORT_PLASMA_PACKAGE_WITH_JSON(QmlWallpaperPackage, "plasma-packagestructure-wallpaper.json") -+ -+#include "wallpaper.moc" -diff --git a/shell/packageplugins/wallpaper/wallpaper.h b/shell/packageplugins/wallpaper/wallpaper.h -new file mode 100644 -index 0000000..f3cd5d6 ---- /dev/null -+++ b/shell/packageplugins/wallpaper/wallpaper.h -@@ -0,0 +1,34 @@ -+/****************************************************************************** -+* Copyright 2007 by Aaron Seigo * -+* Copyright 2013 by Marco Martin * -+* Copyright 2013 by Sebastian Kügler * -+* * -+* This library is free software; you can redistribute it and/or * -+* modify it under the terms of the GNU Library General Public * -+* License as published by the Free Software Foundation; either * -+* version 2 of the License, or (at your option) any later version. * -+* * -+* This library is distributed in the hope that it will be useful, * -+* but WITHOUT ANY WARRANTY; without even the implied warranty of * -+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * -+* Library General Public License for more details. * -+* * -+* You should have received a copy of the GNU Library General Public License * -+* along with this library; see the file COPYING.LIB. If not, write to * -+* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * -+* Boston, MA 02110-1301, USA. * -+*******************************************************************************/ -+ -+#ifndef WALLPAPER_H -+#define WALLPAPER_H -+ -+#include -+ -+class QmlWallpaperPackage : public Plasma::PackageStructure -+{ -+public: -+ QmlWallpaperPackage(QObject*, const QVariantList &) {} -+ void initPackage(Plasma::Package *package); -+}; -+ -+#endif -diff --git a/shell/packageplugins/wallpaperimages/CMakeLists.txt b/shell/packageplugins/wallpaperimages/CMakeLists.txt -deleted file mode 100644 -index 83af217..0000000 ---- a/shell/packageplugins/wallpaperimages/CMakeLists.txt -+++ /dev/null -@@ -1,16 +0,0 @@ --add_definitions(-DTRANSLATION_DOMAIN=\"plasma_package_wallpaperimages\") -- --set(wallpaper_SRCS -- wallpaperpackage.cpp --) -- --add_library(plasma_packagestructure_wallpaperimages MODULE ${wallpaper_SRCS}) -- --target_link_libraries(plasma_packagestructure_wallpaperimages -- KF5::I18n -- KF5::Plasma --) -- --kservice_desktop_to_json(plasma_packagestructure_wallpaperimages plasma-packagestructure-wallpaperimages.desktop) -- --install(TARGETS plasma_packagestructure_wallpaperimages DESTINATION ${PLUGIN_INSTALL_DIR}/plasma/packagestructure) -diff --git a/shell/packageplugins/wallpaperimages/wallpaperpackage.cpp b/shell/packageplugins/wallpaperimages/wallpaperpackage.cpp -deleted file mode 100644 -index 9231bce..0000000 ---- a/shell/packageplugins/wallpaperimages/wallpaperpackage.cpp -+++ /dev/null -@@ -1,82 +0,0 @@ --/* -- * Copyright 2013 by Marco Martin -- -- * This program is free software; you can redistribute it and/or modify -- * it under the terms of the GNU Library General Public License as -- * published by the Free Software Foundation; either version 2, or -- * (at your option) any later version. -- * -- * This program is distributed in the hope that it will be useful, -- * but WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- * GNU General Public License for more details -- * -- * You should have received a copy of the GNU Library General Public -- * License along with this program; if not, write to the -- * Free Software Foundation, Inc., -- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -- */ -- --#include "wallpaperpackage.h" -- --#include --#include -- --#include -- --WallpaperPackage::WallpaperPackage(QObject *parent, const QVariantList &args) -- : Plasma::PackageStructure(parent, args) --{ --} -- --void WallpaperPackage::initPackage(Plasma::Package *package) --{ -- package->addDirectoryDefinition("images", "images/", i18n("Images")); -- -- QStringList mimetypes; -- mimetypes << "image/svg" << "image/png" << "image/jpeg" << "image/jpg"; -- package->setMimeTypes("images", mimetypes); -- -- package->setRequired("images", true); -- package->addFileDefinition("screenshot", "screenshot.png", i18n("Screenshot")); -- package->setAllowExternalPaths(true); --} -- --void WallpaperPackage::pathChanged(Plasma::Package *package) --{ -- static bool guard = false; -- -- if (guard) { -- return; -- } -- -- guard = true; -- QString ppath = package->path(); -- if (ppath.endsWith('/')) { -- ppath.chop(1); -- if (!QFile::exists(ppath)) { -- ppath = package->path(); -- } -- } -- -- QFileInfo info(ppath); -- const bool isFullPackage = info.isDir(); -- package->removeDefinition("preferred"); -- package->setRequired("images", isFullPackage); -- -- if (isFullPackage) { -- package->setContentsPrefixPaths(QStringList() << "contents/"); -- } else { -- package->addFileDefinition("screenshot", info.fileName(), i18n("Preview")); -- package->addFileDefinition("preferred", info.fileName(), QString()); -- package->setContentsPrefixPaths(QStringList()); -- package->setPath(info.path()); -- } -- -- guard = false; --} -- --K_EXPORT_PLASMA_PACKAGE_WITH_JSON(WallpaperPackage, "plasma-packagestructure-wallpaperimages.json") -- --#include "wallpaperpackage.moc" -- -diff --git a/shell/packageplugins/wallpaperimages/wallpaperpackage.h b/shell/packageplugins/wallpaperimages/wallpaperpackage.h -deleted file mode 100644 -index 541e1f7..0000000 ---- a/shell/packageplugins/wallpaperimages/wallpaperpackage.h -+++ /dev/null -@@ -1,36 +0,0 @@ --/* -- * Copyright 2013 by Marco Martin -- -- * This program is free software; you can redistribute it and/or modify -- * it under the terms of the GNU Library General Public License as -- * published by the Free Software Foundation; either version 2, or -- * (at your option) any later version. -- * -- * This program is distributed in the hope that it will be useful, -- * but WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- * GNU General Public License for more details -- * -- * You should have received a copy of the GNU Library General Public -- * License along with this program; if not, write to the -- * Free Software Foundation, Inc., -- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -- */ -- --#ifndef WALLPAPERSTRUCTURE_H --#define WALLPAPERSTRUCTURE_H -- --#include -- --class WallpaperPackage : public Plasma::PackageStructure --{ -- Q_OBJECT -- --public: -- explicit WallpaperPackage(QObject *parent = 0, const QVariantList &args = QVariantList()); -- -- void initPackage(Plasma::Package *package); -- void pathChanged(Plasma::Package *package); --}; -- --#endif -diff --git a/shell/scripting/applet.cpp b/shell/scripting/applet.cpp -index 056e17f..43a8acc 100644 ---- a/shell/scripting/applet.cpp -+++ b/shell/scripting/applet.cpp -@@ -38,7 +38,8 @@ class Applet::Private - public: - Private() - : configDirty(false), -- inWallpaperConfig(false) -+ inWallpaperConfig(false), -+ wallpaperConfigDirty(false) - { - } - -@@ -48,6 +49,7 @@ public: - QStringList globalConfigGroupPath; - bool configDirty : 1; - bool inWallpaperConfig : 1; -+ bool wallpaperConfigDirty : 1; - }; - - Applet::Applet(QObject *parent) -@@ -116,14 +118,16 @@ void Applet::writeConfig(const QString &key, const QVariant &value) - { - if (d->configGroup.isValid()) { - if (d->inWallpaperConfig) { -+ d->wallpaperConfigDirty = true; - //hacky, but only way to make the wallpaper react immediately - QObject *wallpaperGraphicsObject = applet()->property("wallpaperGraphicsObject").value(); -+ - if (wallpaperGraphicsObject) { - KDeclarative::ConfigPropertyMap *config = static_cast(wallpaperGraphicsObject->property("configuration").value()); - config->setProperty(key.toLatin1(), value); - } -+ //check if it can be written in the applets' configScheme - } else if (applet()->configScheme()) { -- //check if it can be written in the applets' configScheme - KConfigSkeletonItem *item = applet()->configScheme()->findItemByName(key); - if (item) { - item->setProperty(value); -@@ -271,6 +275,11 @@ bool Applet::locked() const - return app->immutability() != Plasma::Types::Mutable; - } - -+bool Applet::wallpaperConfigDirty() const -+{ -+ return d->wallpaperConfigDirty; -+} -+ - Plasma::Applet *Applet::applet() const - { - return 0; -diff --git a/shell/scripting/applet.h b/shell/scripting/applet.h -index cb78ac4..082a930 100644 ---- a/shell/scripting/applet.h -+++ b/shell/scripting/applet.h -@@ -60,6 +60,8 @@ public: - void setLocked(bool locked); - bool locked() const; - -+ bool wallpaperConfigDirty() const; -+ - virtual Plasma::Applet *applet() const; - - protected: -diff --git a/shell/scripting/containment.cpp b/shell/scripting/containment.cpp -index 288b9ce..fc7fa82 100644 ---- a/shell/scripting/containment.cpp -+++ b/shell/scripting/containment.cpp -@@ -63,11 +63,14 @@ Containment::~Containment() - if (d->oldWallpaperPlugin != d->wallpaperPlugin || - d->oldWallpaperMode != d->wallpaperMode) { - containment->setWallpaper(d->wallpaperPlugin); -+ } else if (wallpaperConfigDirty()) { -+ KConfigGroup cg(containment->config()); -+ cg = KConfigGroup(&cg, "Wallpaper"); -+ cg = KConfigGroup(&cg, containment->wallpaper()); - } - } - - reloadConfigIfNeeded(); -- - delete d; - } - -diff --git a/wallpapers/image/CMakeLists.txt b/wallpapers/image/CMakeLists.txt -index 5a2ccd5..50d1f1c 100644 ---- a/wallpapers/image/CMakeLists.txt -+++ b/wallpapers/image/CMakeLists.txt -@@ -5,6 +5,7 @@ add_definitions(-DTRANSLATION_DOMAIN=\"plasma_applet_org.kde.image\") - set(image_SRCS - image.cpp - imageplugin.cpp -+ wallpaperpackage.cpp - backgroundlistmodel.cpp - ) - -diff --git a/wallpapers/image/backgroundlistmodel.cpp b/wallpapers/image/backgroundlistmodel.cpp -index a667c10..ccb9d10 100644 ---- a/wallpapers/image/backgroundlistmodel.cpp -+++ b/wallpapers/image/backgroundlistmodel.cpp -@@ -40,6 +40,7 @@ - #include - - #include "image.h" -+#include "wallpaperpackage.h" - - QSet BackgroundFinder::m_suffixes; - -@@ -56,9 +57,9 @@ void ImageSizeFinder::run() - } - - --BackgroundListModel::BackgroundListModel(Image *wallpaper, QObject *parent) -+BackgroundListModel::BackgroundListModel(Image *listener, QObject *parent) - : QAbstractListModel(parent), -- m_wallpaper(wallpaper) -+ m_structureParent(listener) - { - connect(&m_dirwatch, SIGNAL(deleted(QString)), this, SLOT(removeBackground(QString))); - -@@ -110,7 +111,7 @@ void BackgroundListModel::reload(const QStringList &selected) - emit countChanged(); - } - -- if (!m_wallpaper) { -+ if (!m_structureParent) { - return; - } - -@@ -122,7 +123,7 @@ void BackgroundListModel::reload(const QStringList &selected) - const QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "wallpapers/", QStandardPaths::LocateDirectory); - qDebug() << " WP : -------" << dirs; - -- BackgroundFinder *finder = new BackgroundFinder(m_wallpaper.data(), dirs); -+ BackgroundFinder *finder = new BackgroundFinder(m_structureParent.data(), dirs); - connect(finder, SIGNAL(backgroundsFound(QStringList,QString)), this, SLOT(backgroundsFound(QStringList,QString))); - m_findToken = finder->token(); - finder->start(); -@@ -138,7 +139,7 @@ void BackgroundListModel::backgroundsFound(const QStringList &paths, const QStri - - void BackgroundListModel::processPaths(const QStringList &paths) - { -- if (!m_wallpaper) { -+ if (!m_structureParent) { - return; - } - -@@ -173,12 +174,10 @@ void BackgroundListModel::processPaths(const QStringList &paths) - if ((info.isSymLink() || contentsIndex != -1) && paths.contains(file)) { - continue; - } -- - if (!contains(file) && QFile::exists(file)) { -- Plasma::Package package = Plasma::PluginLoader::self()->loadPackage("Wallpaper/Images"); -+ Plasma::Package package = Plasma::Package(new WallpaperPackage(m_structureParent.data(), m_structureParent.data())); - package.setPath(file); - if (package.isValid()) { -- m_wallpaper->findPreferedImageInPackage(package); - newPackages << package; - } - } -@@ -203,18 +202,18 @@ void BackgroundListModel::processPaths(const QStringList &paths) - - void BackgroundListModel::addBackground(const QString& path) - { -- if (!m_wallpaper || !contains(path)) { -+ if (!m_structureParent || !contains(path)) { - if (!m_dirwatch.contains(path)) { - m_dirwatch.addFile(path); - } - beginInsertRows(QModelIndex(), 0, 0); -- Plasma::Package package = Plasma::PluginLoader::self()->loadPackage("Wallpaper/Images"); -+ //Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage(QString::fromLatin1("Plasma/Wallpaper")); -+ Plasma::Package pkg = Plasma::Package(new WallpaperPackage(0, 0)); - - m_removableWallpapers.insert(path); -- package.setPath(path); -- m_wallpaper->findPreferedImageInPackage(package); -- qDebug() << "WP Bckground added " << path << package.isValid(); -- m_packages.prepend(package); -+ pkg.setPath(path); -+ qDebug() << "WP Bckground added " << path << pkg.isValid(); -+ m_packages.prepend(pkg); - endInsertRows(); - emit countChanged(); - } -@@ -283,7 +282,7 @@ QSize BackgroundListModel::bestSize(const Plasma::Package &package) const - - void BackgroundListModel::sizeFound(const QString &path, const QSize &s) - { -- if (!m_wallpaper) { -+ if (!m_structureParent) { - return; - } - -@@ -393,7 +392,7 @@ QVariant BackgroundListModel::data(const QModelIndex &index, int role) const - - void BackgroundListModel::showPreview(const KFileItem &item, const QPixmap &preview) - { -- if (!m_wallpaper) { -+ if (!m_structureParent) { - return; - } - -@@ -424,8 +423,8 @@ Plasma::Package BackgroundListModel::package(int index) const - return m_packages.at(index); - } - --BackgroundFinder::BackgroundFinder(Image *wallpaper, const QStringList &paths) -- : QThread(wallpaper), -+BackgroundFinder::BackgroundFinder(Image *structureParent, const QStringList &paths) -+ : QThread(structureParent), - m_paths(paths), - m_token(QUuid().toString()) - { -@@ -460,7 +459,8 @@ void BackgroundFinder::run() - - QDir dir; - dir.setFilter(QDir::AllDirs | QDir::Files | QDir::Hidden | QDir::Readable); -- Plasma::Package package = Plasma::PluginLoader::self()->loadPackage("Wallpaper/Images"); -+ //Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage(QString::fromLatin1("Plasma/Wallpaper")); -+ Plasma::Package pkg = Plasma::Package(new WallpaperPackage(0, 0)); - - int i; - for (i = 0; i < m_paths.count(); ++i) { -@@ -479,9 +479,9 @@ void BackgroundFinder::run() - - const QString filePath = wp.filePath(); - if (QFile::exists(filePath + QString::fromLatin1("/metadata.desktop"))) { -- package.setPath(filePath); -- if (package.isValid()) { -- papersFound << package.path(); -+ pkg.setPath(filePath); -+ if (pkg.isValid()) { -+ papersFound << pkg.path(); - //qDebug() << "adding package" << wp.filePath(); - continue; - } -diff --git a/wallpapers/image/backgroundlistmodel.h b/wallpapers/image/backgroundlistmodel.h -index 0fa0d92..d5690e6 100644 ---- a/wallpapers/image/backgroundlistmodel.h -+++ b/wallpapers/image/backgroundlistmodel.h -@@ -106,7 +106,7 @@ protected Q_SLOTS: - private: - QSize bestSize(const Plasma::Package &package) const; - -- QPointer m_wallpaper; -+ QWeakPointer m_structureParent; - QList m_packages; - QSet m_removableWallpapers; - QHash m_sizeCache; -@@ -123,7 +123,7 @@ class BackgroundFinder : public QThread - Q_OBJECT - - public: -- BackgroundFinder(Image *wallpaper, const QStringList &p); -+ BackgroundFinder(Image *structureParent, const QStringList &p); - ~BackgroundFinder(); - - QString token() const; -diff --git a/wallpapers/image/image.cpp b/wallpapers/image/image.cpp -index 373d824..d672dfe 100644 ---- a/wallpapers/image/image.cpp -+++ b/wallpapers/image/image.cpp -@@ -22,9 +22,7 @@ - ***************************************************************************/ - - #include "image.h" -- --#include --#include // FLT_MAX -+#include "wallpaperpackage.h" - - #include - #include -@@ -44,7 +42,6 @@ - #include - - #include --#include - #include - #include "backgroundlistmodel.h" - -@@ -59,7 +56,7 @@ Image::Image(QObject *parent) - m_width(0), - m_height(0) - { -- m_wallpaperPackage = Plasma::PluginLoader::self()->loadPackage("Wallpaper/Images"); -+ m_wallpaperPackage = Plasma::Package(new WallpaperPackage(this, this)); - - connect(&m_timer, SIGNAL(timeout()), this, SLOT(nextSlide())); - -@@ -115,73 +112,9 @@ void Image::setRenderingMode(RenderingMode mode) - QTimer::singleShot(200, this, SLOT(startSlideshow())); - updateDirWatch(m_slidePaths); - updateDirWatch(m_slidePaths); -- } else { -- // we need to reset the prefered image -- setSingleImage(); -- } --} -- --float distance(const QSize& size, const QSize& desired) --{ -- // compute difference of areas -- float delta = size.width() * size.height() - -- desired.width() * desired.height(); -- // scale down to about 1.0 -- delta /= ((desired.width() * desired.height())+(size.width() * size.height()))/2; -- -- // Difference of areas, slight preference to scale down -- return delta >= 0.0 ? delta : -delta + 2.0; --} -- --QSize resSize(const QString &str) --{ -- int index = str.indexOf('x'); -- if (index != -1) { -- return QSize(str.left(index).toInt(), -- str.mid(index + 1).toInt()); -- } -- -- return QSize(); --} -- --void Image::findPreferedImageInPackage(Plasma::Package &package) --{ -- if (!package.isValid() || !package.filePath("preferred").isEmpty()) { -- return; -- } -- -- QStringList images = package.entryList("images"); -- if (images.empty()) { -- return; -- } -- -- //qDebug() << "wanted" << size; -- -- // choose the nearest resolution -- float best = FLT_MAX; -- -- QString bestImage; -- foreach (const QString &entry, images) { -- QSize candidate = resSize(QFileInfo(entry).baseName()); -- if (candidate == QSize()) { -- continue; -- } -- -- double dist = distance(candidate, m_targetSize); -- //qDebug() << "candidate" << candidate << "distance" << dist; -- if (bestImage.isEmpty() || dist < best) { -- bestImage = entry; -- best = dist; -- //qDebug() << "best" << bestImage; -- if (dist == 0) { -- break; -- } -- } - } - -- //qDebug() << "best image" << bestImage; -- package.removeDefinition("preferred"); -- package.addFileDefinition("preferred", "images/" + bestImage, i18n("Recommended wallpaper file")); -+ emit renderingModeChanged(); - } - - QSize Image::targetSize() const -@@ -220,6 +153,8 @@ void Image::setWidth(int w) - } - } - -+ -+ - Plasma::Package *Image::package() - { - return &m_wallpaperPackage; -@@ -379,27 +314,23 @@ void Image::addDirFromSelectionDialog() - } - } - --void Image::syncWallpaperPackage() --{ -- m_wallpaperPackage.setPath(m_wallpaper); -- findPreferedImageInPackage(m_wallpaperPackage); -- m_wallpaperPath = m_wallpaperPackage.filePath("preferred"); --} -- - void Image::setSingleImage() - { -- const QString oldPath = m_wallpaperPath; - if (m_wallpaper.isEmpty()) { - useSingleImageDefaults(); - } - - QString img; - if (QDir::isAbsolutePath(m_wallpaper)) { -- syncWallpaperPackage(); -+ m_wallpaperPackage.setPath(m_wallpaper); -+ img = m_wallpaperPackage.filePath("preferred"); -+ m_wallpaperPath = m_wallpaperPackage.filePath("preferred"); - -- if (QFile::exists(m_wallpaperPath)) { -- img = m_wallpaperPath; -+ if (img.isEmpty() && QFile::exists(m_wallpaper)) { -+ img = m_wallpaper; -+ m_wallpaperPath = m_wallpaper; - } -+ Q_EMIT wallpaperPathChanged(); - } else { - //if it's not an absolute path, check if it's just a wallpaper name - const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("wallpapers/") + QString(m_wallpaper + QString::fromLatin1("/metadata.desktop"))); -@@ -408,19 +339,21 @@ void Image::setSingleImage() - QDir dir(path); - dir.cdUp(); - -- syncWallpaperPackage(); -- img = m_wallpaperPath; -+ m_wallpaperPackage.setPath(m_wallpaper); -+ img = m_wallpaperPackage.filePath("preferred"); -+ m_wallpaperPath = m_wallpaperPackage.filePath("preferred"); -+ Q_EMIT wallpaperPathChanged(); - } - } - - if (img.isEmpty()) { - // ok, so the package we have failed to work out; let's try the default -+ // if we have already -+ const QString wallpaper = m_wallpaper; - useSingleImageDefaults(); -- syncWallpaperPackage(); -- } -- -- if (m_wallpaperPath != oldPath) { -- Q_EMIT wallpaperPathChanged(); -+ if (wallpaper != m_wallpaper) { -+ setSingleImage(); -+ } - } - } - -@@ -436,20 +369,19 @@ void Image::addUrls(const QList &urls) - - void Image::addUrl(const QUrl &url, bool setAsCurrent) - { -- QString path; -+ ///qDebug() << "droppage!" << url << url.isLocalFile(); - if (url.isLocalFile()) { -- path = url.toLocalFile(); -- } else if (url.scheme().isEmpty()) { -- if (QDir::isAbsolutePath(url.path())) { -- path = url.path(); -+ const QString path = url.toLocalFile(); -+ if (setAsCurrent) { -+ setWallpaper(path); - } else { -- path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, -- QLatin1String("wallpapers/") + url.path(), -- QStandardPaths::LocateDirectory); -- } -- -- if (path.isEmpty()) { -- return; -+ if (m_mode != SingleImage) { -+ // it's a slide show, add it to the slide show -+ m_slideshowBackgrounds.append(path); -+ m_unseenSlideshowBackgrounds.append(path); -+ } -+ // always add it to the user papers, though -+ addUsersWallpaper(path); - } - } else { - QString wallpaperPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("wallpapers/") + url.path(); -@@ -462,20 +394,6 @@ void Image::addUrl(const QUrl &url, bool setAsCurrent) - connect(job, SIGNAL(result(KJob*)), this, SLOT(addWallpaperRetrieved(KJob*))); - } - } -- -- return; -- } -- -- if (setAsCurrent) { -- setWallpaper(path); -- } else { -- if (m_mode != SingleImage) { -- // it's a slide show, add it to the slide show -- m_slideshowBackgrounds.append(path); -- m_unseenSlideshowBackgrounds.append(path); -- } -- // always add it to the user papers, though -- addUsersWallpaper(path); - } - } - -@@ -688,7 +606,6 @@ void Image::nextSlide() - const QString currentPath = m_unseenSlideshowBackgrounds.at(m_currentSlide); - - m_wallpaperPackage.setPath(currentPath); -- findPreferedImageInPackage(m_wallpaperPackage); - - m_timer.stop(); - m_timer.start(m_delay * 1000); -@@ -747,7 +664,7 @@ void Image::removeWallpaper(QString name) - - //Package plugin name - if (!name.contains('/')) { -- Plasma::Package p = Plasma::PluginLoader::self()->loadPackage("Wallpaper/Images"); -+ Plasma::Package p = Plasma::Package(new WallpaperPackage(this, this)); - KJob *j = p.uninstall(name, localWallpapers); - connect(j, &KJob::finished, [=] () { - m_model->reload(m_usersWallpapers); -diff --git a/wallpapers/image/image.h b/wallpapers/image/image.h -index 4fb87d2..c517c28 100644 ---- a/wallpapers/image/image.h -+++ b/wallpapers/image/image.h -@@ -105,8 +105,6 @@ class Image : public QObject - QStringList slidePaths() const; - void setSlidePaths(const QStringList &slidePaths); - -- void findPreferedImageInPackage(Plasma::Package &package); -- - public Q_SLOTS: - void nextSlide(); - void removeWallpaper(QString name); -@@ -145,11 +143,12 @@ class Image : public QObject - void backgroundsFound(const QStringList &paths, const QString &token); - - protected: -- void syncWallpaperPackage(); - void setSingleImage(); - void useSingleImageDefaults(); - - private: -+ static bool s_startupResumed; -+ static bool s_startupSuspended; - - int m_delay; - QStringList m_dirs; -diff --git a/wallpapers/image/wallpaperpackage.cpp b/wallpapers/image/wallpaperpackage.cpp -new file mode 100644 -index 0000000..1ee524e ---- /dev/null -+++ b/wallpapers/image/wallpaperpackage.cpp -@@ -0,0 +1,174 @@ -+/* -+ * Copyright 2013 by Marco Martin -+ -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU Library General Public License as -+ * published by the Free Software Foundation; either version 2, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details -+ * -+ * You should have received a copy of the GNU Library General Public -+ * License along with this program; if not, write to the -+ * Free Software Foundation, Inc., -+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -+ */ -+ -+#include "wallpaperpackage.h" -+ -+#include -+#include // FLT_MAX -+ -+#include -+#include -+ -+#include -+ -+WallpaperPackage::WallpaperPackage(Image *paper, QObject *parent, const QVariantList &args) -+ : Plasma::PackageStructure(parent, args), -+ m_paper(paper), -+ m_fullPackage(true), -+ m_targetSize(100000, 100000) -+{ -+} -+ -+void WallpaperPackage::initPackage(Plasma::Package *package) -+{ -+ package->addDirectoryDefinition("images", "images/", i18n("Images")); -+ -+ QStringList mimetypes; -+ mimetypes << "image/svg" << "image/png" << "image/jpeg" << "image/jpg"; -+ package->setMimeTypes("images", mimetypes); -+ -+ package->setRequired("images", true); -+ package->addFileDefinition("screenshot", "screenshot.png", i18n("Screenshot")); -+ package->setAllowExternalPaths(true); -+ -+ if (m_paper) { -+ m_targetSize = m_paper->targetSize(); -+ -+ connect(m_paper, SIGNAL(renderingModeChanged()), this, SLOT(renderHintsChanged())); -+ connect(m_paper, SIGNAL(destroyed(QObject*)), this, SLOT(paperDestroyed())); -+ } -+} -+ -+void WallpaperPackage::renderHintsChanged() -+{ -+ if (m_paper) { -+ m_targetSize = m_paper->targetSize(); -+ -+ if (m_fullPackage) { -+ findBestPaper(m_paper->package()); -+ } -+ } -+} -+ -+void WallpaperPackage::pathChanged(Plasma::Package *package) -+{ -+ static bool guard = false; -+ -+ if (guard) { -+ return; -+ } -+ -+ guard = true; -+ QString ppath = package->path(); -+ if (ppath.endsWith('/')) { -+ ppath.chop(1); -+ if (!QFile::exists(ppath)) { -+ ppath = package->path(); -+ } -+ } -+ QFileInfo info(ppath); -+ m_fullPackage = info.isDir(); -+ package->removeDefinition("preferred"); -+ package->setRequired("images", m_fullPackage); -+ -+ if (m_fullPackage) { -+ package->setContentsPrefixPaths(QStringList() << "contents/"); -+ findBestPaper(package); -+ } else { -+ // dirty trick to support having a file passed in instead of a directory -+ package->addFileDefinition("preferred", info.fileName(), i18n("Recommended wallpaper file")); -+ package->addFileDefinition("screenshot", info.fileName(), i18n("Preview")); -+ package->setContentsPrefixPaths(QStringList()); -+ package->setPath(info.path()); -+ } -+ -+ guard = false; -+} -+ -+QSize WallpaperPackage::resSize(const QString &str) const -+{ -+ int index = str.indexOf('x'); -+ if (index != -1) { -+ return QSize(str.left(index).toInt(), -+ str.mid(index + 1).toInt()); -+ } else { -+ return QSize(); -+ } -+} -+ -+void WallpaperPackage::findBestPaper(Plasma::Package *package) -+{ -+ if (!package->isValid()) { -+ return; -+ } -+ -+ QStringList images = package->entryList("images"); -+ if (images.empty()) { -+ return; -+ } -+ -+ //qDebug() << "wanted" << size; -+ -+ // choose the nearest resolution -+ float best = FLT_MAX; -+ -+ QString bestImage; -+ foreach (const QString &entry, images) { -+ QSize candidate = resSize(QFileInfo(entry).baseName()); -+ if (candidate == QSize()) { -+ continue; -+ } -+ -+ double dist = distance(candidate, m_targetSize); -+ //qDebug() << "candidate" << candidate << "distance" << dist; -+ if (bestImage.isEmpty() || dist < best) { -+ bestImage = entry; -+ best = dist; -+ //qDebug() << "best" << bestImage; -+ if (dist == 0) { -+ break; -+ } -+ } -+ } -+ -+ //qDebug() << "best image" << bestImage; -+ package->removeDefinition("preferred"); -+ package->addFileDefinition("preferred", "images/" + bestImage, i18n("Recommended wallpaper file")); -+} -+ -+float WallpaperPackage::distance(const QSize& size, const QSize& desired) const -+{ -+ // compute difference of areas -+ float delta = size.width() * size.height() - -+ desired.width() * desired.height(); -+ // scale down to about 1.0 -+ delta /= ((desired.width() * desired.height())+(size.width() * size.height()))/2; -+ -+ // Difference of areas, slight preference to scale down -+ return delta >= 0.0 ? delta : -delta + 2.0; -+} -+ -+void WallpaperPackage::paperDestroyed() -+{ -+ m_paper = 0; -+} -+ -+ -+#include "wallpaperpackage.moc" -+ -diff --git a/wallpapers/image/wallpaperpackage.h b/wallpapers/image/wallpaperpackage.h -new file mode 100644 -index 0000000..45e8736 ---- /dev/null -+++ b/wallpapers/image/wallpaperpackage.h -@@ -0,0 +1,55 @@ -+/* -+ * Copyright 2013 by Marco Martin -+ -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU Library General Public License as -+ * published by the Free Software Foundation; either version 2, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details -+ * -+ * You should have received a copy of the GNU Library General Public -+ * License along with this program; if not, write to the -+ * Free Software Foundation, Inc., -+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -+ */ -+ -+#ifndef WALLPAPERSTRUCTURE_H -+#define WALLPAPERSTRUCTURE_H -+ -+#include -+ -+#include "image.h" -+ -+class WallpaperPackage : public Plasma::PackageStructure -+{ -+ Q_OBJECT -+ -+public: -+ explicit WallpaperPackage(Image *paper, QObject *parent = 0, const QVariantList &args = QVariantList()); -+ -+ void initPackage(Plasma::Package *package); -+ void pathChanged(Plasma::Package *package); -+ -+protected: -+ void pathChanged(); -+ -+private: -+ QSize resSize(const QString &str) const; -+ void findBestPaper(Plasma::Package *package); -+ float distance(const QSize& size, const QSize& desired) const; -+ -+private Q_SLOTS: -+ void paperDestroyed(); -+ void renderHintsChanged(); -+ -+private: -+ Image *m_paper; -+ bool m_fullPackage; -+ QSize m_targetSize; -+}; -+ -+#endif