use a QmlWallpaper package type for wallpapers

This commit is contained in:
Marco Martin 2013-09-02 20:25:04 +02:00
parent 2e14e707fe
commit 800298935f
7 changed files with 66 additions and 13 deletions

View File

@ -93,8 +93,7 @@ void WallpaperInterface::syncWallpaperPackage()
m_qmlObject->setInitializationDelayed(true); m_qmlObject->setInitializationDelayed(true);
} }
m_pkg = Plasma::PluginLoader::self()->loadPackage("Plasma/Generic"); m_pkg = Plasma::PluginLoader::self()->loadPackage("Plasma/QmlWallpaper");
m_pkg.setDefaultPackageRoot("plasma/wallpapers");
m_pkg.setPath(m_wallpaperPlugin); m_pkg.setPath(m_wallpaperPlugin);
m_configLoader->deleteLater(); m_configLoader->deleteLater();

View File

@ -71,7 +71,7 @@ add_executable(plasma-shell
panelview.cpp panelview.cpp
shellpluginloader.cpp shellpluginloader.cpp
shellmanager.cpp shellmanager.cpp
lookandfeelpackage.cpp packages.cpp
view.cpp view.cpp
panelconfigview.cpp panelconfigview.cpp
${scripting_SRC} ${scripting_SRC}

View File

@ -52,8 +52,7 @@ ContainmentConfigView::ContainmentConfigView(Plasma::Containment *cont, QWindow
engine()->rootContext()->setContextProperty("configDialog", this); engine()->rootContext()->setContextProperty("configDialog", this);
setCurrentWallpaper(cont->containment()->wallpaper()); setCurrentWallpaper(cont->containment()->wallpaper());
Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage("Plasma/Generic"); Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage("Plasma/QmlWallpaper");
pkg.setDefaultPackageRoot("plasma/wallpapers");
pkg.setPath(m_containment->wallpaper()); pkg.setPath(m_containment->wallpaper());
QFile file(pkg.filePath("config", "main.xml")); QFile file(pkg.filePath("config", "main.xml"));
KConfigGroup cfg = m_containment->config(); KConfigGroup cfg = m_containment->config();

View File

@ -49,7 +49,7 @@ int main(int argc, char** argv)
QQmlDebuggingEnabler enabler; QQmlDebuggingEnabler enabler;
} }
// Plasma::PluginLoader::setPluginLoader(new ShellPluginLoader); Plasma::PluginLoader::setPluginLoader(new ShellPluginLoader);
// DesktopCorona *corona = new DesktopCorona(); // DesktopCorona *corona = new DesktopCorona();
// corona->loadLayout(); // corona->loadLayout();
// if (corona->containments().isEmpty()) { // if (corona->containments().isEmpty()) {

View File

@ -18,14 +18,17 @@
* Boston, MA 02110-1301, USA. * * Boston, MA 02110-1301, USA. *
*******************************************************************************/ *******************************************************************************/
#include "lookandfeelpackage.h" #include "packages.h"
#include <QDebug>
#include <KLocalizedString> #include <KLocalizedString>
#include <kdeclarative.h>
#include <Plasma/Package> #include <Plasma/Package>
void LookAndFeelPackageStructure::initPackage(Plasma::Package *package) void LookAndFeelPackage::initPackage(Plasma::Package *package)
{ {
// http://community.kde.org/Plasma/lookAndFeelPackage# // http://community.kde.org/Plasma/lookAndFeelPackage#
@ -71,4 +74,47 @@ void LookAndFeelPackageStructure::initPackage(Plasma::Package *package)
} }
void QmlWallpaperPackage::initPackage(Plasma::Package *package)
{
package->addFileDefinition("mainscript", "ui/main.qml", i18n("Main Script File"));
//FIXME: why setting it required doesn't work?
//package->setRequired("mainscript", true);
QStringList platform = 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"));
}

View File

@ -19,19 +19,24 @@
* Boston, MA 02110-1301, USA. * * Boston, MA 02110-1301, USA. *
*******************************************************************************/ *******************************************************************************/
#ifndef SHELLPACKAGE_H #ifndef SHELLPACKAGES_H
#define SHELLPACKAGE_H #define SHELLPACKAGES_H
#include <Plasma/PackageStructure> #include <Plasma/PackageStructure>
#include <Plasma/Plasma> #include <Plasma/Plasma>
class LookAndFeelPackageStructure : public Plasma::PackageStructure class LookAndFeelPackage : public Plasma::PackageStructure
{ {
public: public:
void initPackage(Plasma::Package *package); void initPackage(Plasma::Package *package);
}; };
class QmlWallpaperPackage : public Plasma::PackageStructure
{
public:
void initPackage(Plasma::Package *package);
};
#endif // LOOKANDFEELPACKAGE_H #endif // LOOKANDFEELPACKAGE_H

View File

@ -18,8 +18,9 @@
*/ */
#include "shellpluginloader.h" #include "shellpluginloader.h"
#include "lookandfeelpackage.h" #include "packages.h"
#include <QDebug>
ShellPluginLoader::ShellPluginLoader() ShellPluginLoader::ShellPluginLoader()
: Plasma::PluginLoader() : Plasma::PluginLoader()
@ -35,7 +36,10 @@ Plasma::Package ShellPluginLoader::internalLoadPackage(const QString &packageFor
Q_UNUSED(specialization) Q_UNUSED(specialization)
if (packageFormat.endsWith("/LookAndFeel")) { if (packageFormat.endsWith("/LookAndFeel")) {
Plasma::PackageStructure *structure = new LookAndFeelPackageStructure(); Plasma::PackageStructure *structure = new LookAndFeelPackage();
return Plasma::Package(structure);
} else if (packageFormat.endsWith("/QmlWallpaper")) {
Plasma::PackageStructure *structure = new QmlWallpaperPackage();
return Plasma::Package(structure); return Plasma::Package(structure);
} else { } else {
return Plasma::Package(); return Plasma::Package();