From e15217f6456c29e880e4b7632a0b96752f6dde45 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 21 Nov 2012 15:26:59 +0100 Subject: [PATCH] remove dependencies from WallPaper --- CMakeLists.txt | 8 +- applet.cpp | 1 - containment.cpp | 157 +----- containment.h | 31 +- design/qml_todos.txt | 7 + .../declarativecontainment.cpp | 53 ++ .../declarativecontainment.h | 74 +++ .../declarativecontainment_p.cpp | 478 ++++++++++++++++++ .../declarativecontainment_p.h | 102 ++++ pluginloader.cpp | 2 - private/containment_p.cpp | 412 --------------- private/containment_p.h | 36 +- private/packages.cpp | 139 ----- private/packages_p.h | 26 - private/wallpaper_p.h | 18 - scripting/scriptengine.cpp | 27 - scripting/wallpaperscript.cpp | 57 --- scripting/wallpaperscript.h | 39 -- wallpaper.cpp | 222 +------- wallpaper.h | 170 ------- 20 files changed, 752 insertions(+), 1307 deletions(-) create mode 100644 intoDeclarativeEngine/declarativecontainment.cpp create mode 100644 intoDeclarativeEngine/declarativecontainment.h create mode 100644 intoDeclarativeEngine/declarativecontainment_p.cpp create mode 100644 intoDeclarativeEngine/declarativecontainment_p.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d58dce45..6c2dbdf02 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -133,7 +133,6 @@ set(plasma_LIB_SRCS private/serviceprovider.cpp private/storage.cpp private/storagethread.cpp - private/wallpaperrenderthread.cpp private/windowpreview.cpp private/windowshadows.cpp private/applet_p.cpp @@ -159,14 +158,12 @@ set(plasma_LIB_SRCS scripting/appletscript.cpp scripting/dataenginescript.cpp scripting/runnerscript.cpp - scripting/wallpaperscript.cpp scripting/scriptengine.cpp service.cpp servicejob.cpp svg.cpp theme.cpp version.cpp - wallpaper.cpp #Temporary QtJolie branch @@ -269,8 +266,7 @@ set(plasma_LIB_INCLUDES svg.h theme.h version.h - view.h - wallpaper.h) + view.h) install(FILES @@ -282,7 +278,6 @@ install(FILES scripting/appletscript.h scripting/dataenginescript.h scripting/runnerscript.h - scripting/wallpaperscript.h scripting/scriptengine.h DESTINATION ${INCLUDE_INSTALL_DIR}/plasma/scripting COMPONENT Devel) @@ -295,7 +290,6 @@ install(FILES data/servicetypes/plasma-runner.desktop data/servicetypes/plasma-scriptengine.desktop data/servicetypes/plasma-service.desktop - data/servicetypes/plasma-wallpaper.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR}) install(FILES diff --git a/applet.cpp b/applet.cpp index bced0e5ca..a0e6d1122 100644 --- a/applet.cpp +++ b/applet.cpp @@ -84,7 +84,6 @@ #include "remote/authorizationmanager.h" #include "remote/authorizationmanager_p.h" #include "theme.h" -#include "wallpaper.h" #include "paintutils.h" #include "abstractdialogmanager.h" #include "pluginloader.h" diff --git a/containment.cpp b/containment.cpp index 2f1e57a7d..d8c9e4c56 100644 --- a/containment.cpp +++ b/containment.cpp @@ -54,7 +54,6 @@ #include "corona.h" #include "pluginloader.h" #include "svg.h" -#include "wallpaper.h" #include "remote/accessappletjob.h" #include "remote/accessmanager.h" @@ -323,16 +322,10 @@ void Containment::save(KConfigGroup &g) const group.writeEntry("activityId", d->activityId); - if (d->wallpaper) { - group.writeEntry("wallpaperplugin", d->wallpaper->pluginName()); - group.writeEntry("wallpaperpluginmode", d->wallpaper->renderingMode().name()); + group.writeEntry("wallpaperplugin", d->wallpaper); + group.writeEntry("wallpaperpluginmode", d->wallpaperMode); - if (d->wallpaper->isInitialized()) { - KConfigGroup wallpaperConfig(&group, "Wallpaper"); - wallpaperConfig = KConfigGroup(&wallpaperConfig, d->wallpaper->pluginName()); - d->wallpaper->save(wallpaperConfig); - } - } + //TODO: the wallpaper implementation must know it has to save at this point saveContents(group); } @@ -543,9 +536,6 @@ void Containment::addApplet(Applet *applet, const QPointF &pos, bool delayInit) if (currentContainment && currentContainment != this) { emit currentContainment->appletRemoved(applet); - if (currentContainment->d->focusedApplet == applet) { - currentContainment->d->focusedApplet = 0; - } disconnect(applet, 0, currentContainment, 0); KConfigGroup oldConfig = applet->config(); @@ -692,23 +682,6 @@ QStringList Containment::listContainmentTypes() return types.toList(); } -void Containment::dropEvent(QDropEvent *event) -{ - if (isContainment()) { - d->dropData(event->pos(), event); - } -} - -//TODO: remove and make it GSS -void Containment::resizeEvent(QResizeEvent *event) -{ - if (isContainment()) { - if (d->wallpaper) { - d->wallpaper->setBoundingRect(QRectF(QPointF(0, 0), event->size())); - } - } -} - void Containment::keyPressEvent(QKeyEvent *event) { //kDebug() << "keyPressEvent with" << event->key() @@ -727,15 +700,6 @@ void Containment::wheelEvent(QWheelEvent *event) { event->ignore(); - if (d->wallpaper && d->wallpaper->isInitialized()) { - event->ignore(); - d->wallpaper->wheelEvent(event); - - if (event->isAccepted()) { - return; - } - } - QString trigger = ContainmentActions::eventToString(event); if (d->prepareContainmentActions(trigger, event->globalPos())) { @@ -769,10 +733,12 @@ void Containment::removeToolBoxAction(QAction *action) void Containment::addAssociatedWidget(QWidget *widget) { + //TODO: move this whole method in the c++ part of the QML implementation Applet::addAssociatedWidget(widget); - if (d->focusedApplet) { + + /*if (d->focusedApplet) { d->focusedApplet->addAssociatedWidget(widget); - } + }*/ foreach (const Applet *applet, d->applets) { if (applet->d->activationAction) { @@ -783,10 +749,11 @@ void Containment::addAssociatedWidget(QWidget *widget) void Containment::removeAssociatedWidget(QWidget *widget) { + //TODO: move this whole method in the c++ part of the QML implementation Applet::removeAssociatedWidget(widget); - if (d->focusedApplet) { + /*if (d->focusedApplet) { d->focusedApplet->removeAssociatedWidget(widget); - } + }*/ foreach (const Applet *applet, d->applets) { if (applet->d->activationAction) { @@ -798,15 +765,6 @@ void Containment::removeAssociatedWidget(QWidget *widget) void Containment::setDrawWallpaper(bool drawWallpaper) { d->drawWallpaper = drawWallpaper; - if (drawWallpaper) { - KConfigGroup cfg = config(); - const QString wallpaper = cfg.readEntry("wallpaperplugin", ContainmentPrivate::defaultWallpaper); - const QString mode = cfg.readEntry("wallpaperpluginmode", ContainmentPrivate::defaultWallpaperMode); - setWallpaper(wallpaper, mode); - } else { - delete d->wallpaper; - d->wallpaper = 0; - } } bool Containment::drawWallpaper() @@ -817,67 +775,34 @@ bool Containment::drawWallpaper() void Containment::setWallpaper(const QString &pluginName, const QString &mode) { KConfigGroup cfg = config(); - bool newPlugin = true; - bool newMode = true; + bool newPlugin = pluginName != d->wallpaper; + bool newMode = mode != d->wallpaperMode; - if (d->drawWallpaper) { - if (d->wallpaper) { - // we have a wallpaper, so let's decide whether we need to swap it out - if (d->wallpaper->pluginName() != pluginName) { - delete d->wallpaper; - d->wallpaper = 0; - } else { - // it's the same plugin, so let's save its state now so when - // we call restore later on we're safe - newMode = d->wallpaper->renderingMode().name() != mode; - newPlugin = false; - } - } - - if (!pluginName.isEmpty() && !d->wallpaper) { - d->wallpaper = Plasma::Wallpaper::load(pluginName); - } - - if (d->wallpaper) { - d->wallpaper->setParent(this); - d->wallpaper->setRenderingMode(mode); - - if (newPlugin) { - cfg.writeEntry("wallpaperplugin", pluginName); - } - - if (d->wallpaper->isInitialized()) { - KConfigGroup wallpaperConfig = KConfigGroup(&cfg, "Wallpaper"); - wallpaperConfig = KConfigGroup(&wallpaperConfig, pluginName); - d->wallpaper->restore(wallpaperConfig); - } - - if (newMode) { - cfg.writeEntry("wallpaperpluginmode", mode); - } - } - } - - if (!d->wallpaper) { - cfg.deleteEntry("wallpaperplugin"); - cfg.deleteEntry("wallpaperpluginmode"); - } if (newPlugin || newMode) { - if (newPlugin && d->wallpaper) { - connect(d->wallpaper, SIGNAL(configureRequested()), this, SLOT(requestConfiguration())); - connect(d->wallpaper, SIGNAL(configNeedsSaving()), this, SIGNAL(configNeedsSaving())); - } + d->wallpaper = pluginName; + d->wallpaperMode = mode; + if (newMode) { + cfg.writeEntry("wallpaperpluginmode", mode); + } + if (newPlugin) { + cfg.writeEntry("wallpaperplugin", pluginName); + } emit configNeedsSaving(); } } -Plasma::Wallpaper *Containment::wallpaper() const +QString Containment::wallpaper() const { return d->wallpaper; } +QString Containment::wallpaperMode() const +{ + return d->wallpaperMode; +} + void Containment::setContainmentActions(const QString &trigger, const QString &pluginName) { KConfigGroup cfg = containmentActionsConfig(); @@ -949,36 +874,6 @@ QString Containment::activity() const return d->activityId; } -void Containment::focusNextApplet() -{ - if (d->applets.isEmpty()) { - return; - } - int index = d->focusedApplet ? d->applets.indexOf(d->focusedApplet) + 1 : 0; - if (index >= d->applets.size()) { - index = 0; - } -#ifndef NDEBUG - kDebug() << "index" << index; -#endif - d->focusApplet(d->applets.at(index)); -} - -void Containment::focusPreviousApplet() -{ - if (d->applets.isEmpty()) { - return; - } - int index = d->focusedApplet ? d->applets.indexOf(d->focusedApplet) - 1 : -1; - if (index < 0) { - index = d->applets.size() - 1; - } -#ifndef NDEBUG - kDebug() << "index" << index; -#endif - d->focusApplet(d->applets.at(index)); -} - void Containment::destroy() { destroy(true); diff --git a/containment.h b/containment.h index 4342eb19e..4c5959f95 100644 --- a/containment.h +++ b/containment.h @@ -316,7 +316,12 @@ class PLASMA_EXPORT Containment : public Applet /** * Return wallpaper plugin. */ - Plasma::Wallpaper *wallpaper() const; + QString wallpaper() const; + + /** + * Return wallpaper rendering mode. + */ + QString wallpaperMode() const; /** * Sets the current activity by id @@ -448,16 +453,6 @@ Q_SIGNALS: */ void addSiblingContainment(); - /** - * switch keyboard focus to the next of our applets - */ - void focusNextApplet(); - - /** - * switch keyboard focus to the previous one of our applets - */ - void focusPreviousApplet(); - /** * Destroys this containment and all its applets (after a confirmation dialog); * it will be removed nicely and deleted. @@ -511,13 +506,6 @@ Q_SIGNALS: void contextMenuEvent(QContextMenuEvent *event); void keyPressEvent(QKeyEvent *event); void wheelEvent(QWheelEvent *event); - void dropEvent(QDropEvent *event); - - /** - * @reimp - * @sa QObject::resizeEvent() - */ - void resizeEvent(QResizeEvent *event); private: @@ -534,14 +522,7 @@ Q_SIGNALS: Q_PRIVATE_SLOT(d, void appletDeleted(Plasma::Applet*)) Q_PRIVATE_SLOT(d, void triggerShowAddWidgets()) Q_PRIVATE_SLOT(d, void requestConfiguration()) - Q_PRIVATE_SLOT(d, void showDropZoneDelayed()) Q_PRIVATE_SLOT(d, void checkStatus(Plasma::ItemStatus)) - Q_PRIVATE_SLOT(d, void remoteAppletReady(Plasma::AccessAppletJob *)) - /** - * This slot is called when the 'stat' after a job event has finished. - */ - Q_PRIVATE_SLOT(d, void mimeTypeRetrieved(KIO::Job *, const QString &)) - Q_PRIVATE_SLOT(d, void dropJobResult(KJob *)) friend class Applet; friend class AppletPrivate; diff --git a/design/qml_todos.txt b/design/qml_todos.txt index 638e8eaa4..a90e10841 100644 --- a/design/qml_todos.txt +++ b/design/qml_todos.txt @@ -33,4 +33,11 @@ Porting of Applet and Containment * ContainmentPrivate::appletAt(const QPointF &point) -> depends from ContainmentActions refactoring : disabled now in the code * ContainmentPrivate::setScreen(int newScreen, int newDesktop, bool preventInvalidDesktops) * all geometry functions in Applet and Containment (width, height, geometry, raise, lower...) +* move Containment::addAssociatedWidget/removeAssociatedWidget in the c++ part of the QML implementation +Porting of Wallpaper +==================== +* port complete dropData/mimeTypeRetrieved from ContainmentPrivate to the c++ part of the Containment implementation. The code is right now in intoDeclarativeEngine/declarativecontainment_p.cpp +* Containments should just have a string property for wallpapers that is the name of a Package with the wallpaper qml +* the qml wallpaper must receive a signal when Containment::save() is called so it can do own config save (TODO around line 329 of containment.cpp) +* redo WallpaperPackage, but this time is a package to load qml \ No newline at end of file diff --git a/intoDeclarativeEngine/declarativecontainment.cpp b/intoDeclarativeEngine/declarativecontainment.cpp new file mode 100644 index 000000000..1232ad96c --- /dev/null +++ b/intoDeclarativeEngine/declarativecontainment.cpp @@ -0,0 +1,53 @@ +/* + * Copyright 2007 by Aaron Seigo + * Copyright 2008 by Ménard Alexis + * Copyright 2009 Chani Armitage + * Copyright 2012 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. + */ + + +void Containment::focusNextApplet() +{ + if (d->applets.isEmpty()) { + return; + } + int index = d->focusedApplet ? d->applets.indexOf(d->focusedApplet) + 1 : 0; + if (index >= d->applets.size()) { + index = 0; + } +#ifndef NDEBUG + kDebug() << "index" << index; +#endif + d->focusApplet(d->applets.at(index)); +} + +void Containment::focusPreviousApplet() +{ + if (d->applets.isEmpty()) { + return; + } + int index = d->focusedApplet ? d->applets.indexOf(d->focusedApplet) - 1 : -1; + if (index < 0) { + index = d->applets.size() - 1; + } +#ifndef NDEBUG + kDebug() << "index" << index; +#endif + d->focusApplet(d->applets.at(index)); +} + diff --git a/intoDeclarativeEngine/declarativecontainment.h b/intoDeclarativeEngine/declarativecontainment.h new file mode 100644 index 000000000..1bcc31b8a --- /dev/null +++ b/intoDeclarativeEngine/declarativecontainment.h @@ -0,0 +1,74 @@ +/* + * Copyright 2007 by Aaron Seigo + * Copyright 2008 by Ménard Alexis + * Copyright (c) 2009 Chani Armitage + * + * 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 PLASMA_CONTAINMENT_H +#define PLASMA_CONTAINMENT_H + +#include +#include + +#include +#include + +#include + + +namespace Plasma +{ + +class AccessAppletJob; +class AppletHandle; +class DataEngine; +class Package; +class Corona; +class View; +class Wallpaper; +class DeclarativeContainmentActions; +class DeclarativeContainmentPrivate; +class AbstractToolBox; + + +class PLASMA_EXPORT DeclarativeContainment : public Applet +{ + Q_OBJECT + + public: + + void focusNextApplet(); + void focusPreviousApplet(); + + private: + + + Q_PRIVATE_SLOT(d, void showDropZoneDelayed()) + Q_PRIVATE_SLOT(d, void remoteAppletReady(Plasma::AccessAppletJob *)) + /** + * This slot is called when the 'stat' after a job event has finished. + */ + Q_PRIVATE_SLOT(d, void mimeTypeRetrieved(KIO::Job *, const QString &)) + Q_PRIVATE_SLOT(d, void dropJobResult(KJob *)) + + DeclarativeContainmentPrivate *const d; +}; + +} // Plasma namespace + +#endif // multiple inclusion guard diff --git a/intoDeclarativeEngine/declarativecontainment_p.cpp b/intoDeclarativeEngine/declarativecontainment_p.cpp new file mode 100644 index 000000000..5615bfddc --- /dev/null +++ b/intoDeclarativeEngine/declarativecontainment_p.cpp @@ -0,0 +1,478 @@ +/* + * Copyright 2007 by Aaron Seigo + * Copyright 2008 by Ménard Alexis + * Copyright 2009 Chani Armitage + * Copyright 2012 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 "private/containment_p.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "config-plasma.h" + +#if !PLASMA_NO_KIO +#include "kio/jobclasses.h" // for KIO::JobFlags +#include "kio/job.h" +#include "kio/scheduler.h" +#endif + +#include "containmentactions.h" +#include "containmentactionspluginsconfig.h" +#include "corona.h" +#include "pluginloader.h" +#include "svg.h" +#include "wallpaper.h" + +#include "remote/accessappletjob.h" +#include "remote/accessmanager.h" + +#include "private/applet_p.h" +#include "private/containmentactionspluginsconfig_p.h" +#include "private/wallpaper_p.h" + + +namespace Plasma +{ + + +const char DeclarativeContainmentPrivate::defaultWallpaperMode[] = "SingleImage"; + + +void DeclarativeContainmentPrivate::showDropZoneDelayed() +{ + dropZoneStarted = true; + q->showDropZone(dropPoints.value(0).toPoint()); + dropPoints.remove(0); +} + +void DeclarativeContainmentPrivate::dropData(QPoint screenPos, QDropEvent *dropEvent) +{ + if (q->immutability() != Mutable) { + return; + } + + const QMimeData *mimeData = 0; + + if (dropEvent) { + mimeData = dropEvent->mimeData(); + } else { + QClipboard *clipboard = QApplication::clipboard(); + mimeData = clipboard->mimeData(QClipboard::Selection); + //TODO if that's not supported (ie non-linux) should we try clipboard instead of selection? + } + + if (!mimeData) { + //Selection is either empty or not supported on this OS +#ifndef NDEBUG + kDebug() << "no mime data"; +#endif + return; + } + + //kDebug() << event->mimeData()->text(); + + QString appletMimetype(q->corona() ? q->corona()->appletMimeType() : QString()); + + if (!appletMimetype.isEmpty() && mimeData->hasFormat(appletMimetype)) { + QString data = mimeData->data(appletMimetype); + const QStringList appletNames = data.split('\n', QString::SkipEmptyParts); + foreach (const QString &appletName, appletNames) { + //kDebug() << "doing" << appletName; + QRectF geom(screenPos, QSize(0, 0)); + q->addApplet(appletName, QVariantList(), geom); + } + if (dropEvent) { + dropEvent->acceptProposedAction(); + } + } else if (mimeData->hasUrls()) { + //TODO: collect the mimeTypes of available script engines and offer + // to create widgets out of the matching URLs, if any + const QList urls = KUrlMimeData::urlsFromMimeData(mimeData); + foreach (const QUrl &url, urls) { + if (AccessManager::supportedProtocols().contains(url.scheme())) { + AccessAppletJob *job = AccessManager::self()->accessRemoteApplet(url); + if (dropEvent) { + dropPoints[job] = dropEvent->pos(); + } else { + dropPoints[job] = screenPos; + } + QObject::connect(AccessManager::self(), SIGNAL(finished(Plasma::AccessAppletJob*)), + q, SLOT(remoteAppletReady(Plasma::AccessAppletJob*))); + } +#if !PLASMA_NO_KIO + else { + QMimeDatabase db; + QMimeType mime = db.mimeTypeForUrl(url); + QString mimeName = mime.name(); + QRectF geom(screenPos, QSize()); + QVariantList args; + args << url.toString(); +#ifndef NDEBUG + kDebug() << "can decode" << mimeName << args; +#endif + + // It may be a directory or a file, let's stat + KIO::JobFlags flags = KIO::HideProgressInfo; + KIO::MimetypeJob *job = KIO::mimetype(url, flags); + if (dropEvent) { + dropPoints[job] = dropEvent->pos(); + } else { + dropPoints[job] = screenPos; + } + + QObject::connect(job, SIGNAL(result(KJob*)), q, SLOT(dropJobResult(KJob*))); + QObject::connect(job, SIGNAL(mimetype(KIO::Job*,QString)), + q, SLOT(mimeTypeRetrieved(KIO::Job*,QString))); + + KMenu *choices = new KMenu("Content dropped"); + choices->addAction(KDE::icon("process-working"), i18n("Fetching file type...")); + if (dropEvent) { + choices->popup(dropEvent->pos()); + } else { + choices->popup(screenPos); + } + + dropMenus[job] = choices; + } +#endif + } + + if (dropEvent) { + dropEvent->acceptProposedAction(); + } + } else { + QStringList formats = mimeData->formats(); + QHash seenPlugins; + QHash pluginFormats; + + foreach (const QString &format, formats) { + KPluginInfo::List plugins = Applet::listAppletInfoForMimeType(format); + + foreach (const KPluginInfo &plugin, plugins) { + if (seenPlugins.contains(plugin.pluginName())) { + continue; + } + + seenPlugins.insert(plugin.pluginName(), plugin); + pluginFormats.insert(plugin.pluginName(), format); + } + } + //kDebug() << "Mimetype ..." << formats << seenPlugins.keys() << pluginFormats.values(); + + QString selectedPlugin; + + if (seenPlugins.isEmpty()) { + // do nothing + } else if (seenPlugins.count() == 1) { + selectedPlugin = seenPlugins.constBegin().key(); + } else { + KMenu choices; + QHash actionsToPlugins; + foreach (const KPluginInfo &info, seenPlugins) { + QAction *action; + if (!info.icon().isEmpty()) { + action = choices.addAction(KDE::icon(info.icon()), info.name()); + } else { + action = choices.addAction(info.name()); + } + + actionsToPlugins.insert(action, info.pluginName()); + } + + QAction *choice = choices.exec(screenPos); + if (choice) { + selectedPlugin = actionsToPlugins[choice]; + } + } + + if (!selectedPlugin.isEmpty()) { + if (!dropEvent) { + // since we may have entered an event loop up above with the menu, + // the clipboard item may no longer be valid, as QClipboard resets + // the object behind the back of the application with a zero timer + // so we fetch it again here + QClipboard *clipboard = QApplication::clipboard(); + mimeData = clipboard->mimeData(QClipboard::Selection); + } + + QTemporaryFile tempFile; + if (mimeData && tempFile.open()) { + //TODO: what should we do with files after the applet is done with them?? + tempFile.setAutoRemove(false); + + { + QDataStream stream(&tempFile); + QByteArray data = mimeData->data(pluginFormats[selectedPlugin]); + stream.writeRawData(data, data.size()); + } + + QRectF geom(screenPos, QSize()); + QVariantList args; + args << tempFile.fileName(); +#ifndef NDEBUG + kDebug() << args; +#endif + tempFile.close(); + + q->addApplet(selectedPlugin, args, geom); + } + } + } +} + +void DeclarativeContainmentPrivate::clearDataForMimeJob(KIO::Job *job) +{ +#if !PLASMA_NO_KIO + QObject::disconnect(job, 0, q, 0); + dropPoints.remove(job); + KMenu *choices = dropMenus.take(job); + delete choices; + job->kill(); +#endif // PLASMA_NO_KIO +} + +void DeclarativeContainmentPrivate::dropJobResult(KJob *job) +{ +#if !PLASMA_NO_KIO + KIO::TransferJob* tjob = dynamic_cast(job); + if (!tjob) { +#ifndef NDEBUG + kDebug() << "job is not a KIO::TransferJob, won't handle the drop..."; +#endif + clearDataForMimeJob(tjob); + return; + } + if (job->error()) { +#ifndef NDEBUG + kDebug() << "ERROR" << tjob->error() << ' ' << tjob->errorString(); +#endif + } + // We call mimeTypeRetrieved since there might be other mechanisms + // for finding suitable applets. Cleanup happens there as well. + mimeTypeRetrieved(qobject_cast(job), QString()); +#endif // PLASMA_NO_KIO +} + +void DeclarativeContainmentPrivate::mimeTypeRetrieved(KIO::Job *job, const QString &mimeType) +{ +#if !PLASMA_NO_KIO +#ifndef NDEBUG + kDebug() << "Mimetype Job returns." << mimeType; +#endif + KIO::TransferJob* tjob = dynamic_cast(job); + if (!tjob) { +#ifndef NDEBUG + kDebug() << "job should be a TransferJob, but isn't"; +#endif + clearDataForMimeJob(job); + return; + } + KPluginInfo::List appletList = Applet::listAppletInfoForUrl(tjob->url()); + if (mimeType.isEmpty() && !appletList.count()) { + clearDataForMimeJob(job); +#ifndef NDEBUG + kDebug() << "No applets found matching the url (" << tjob->url() << ") or the mimeType (" << mimeType << ")"; +#endif + return; + } else { + + QPointF posi; // will be overwritten with the event's position + if (dropPoints.keys().contains(tjob)) { + posi = dropPoints[tjob]; +#ifndef NDEBUG + kDebug() << "Received a suitable dropEvent at" << posi; +#endif + } else { +#ifndef NDEBUG + kDebug() << "Bailing out. Cannot find associated dropEvent related to the TransferJob"; +#endif + clearDataForMimeJob(job); + return; + } + + KMenu *choices = dropMenus.value(tjob); + if (!choices) { +#ifndef NDEBUG + kDebug() << "Bailing out. No QMenu found for this job."; +#endif + clearDataForMimeJob(job); + return; + } + + QVariantList args; + args << tjob->url().toString() << mimeType; + +#ifndef NDEBUG + kDebug() << "Creating menu for:" << mimeType << posi << args; +#endif + + appletList << Applet::listAppletInfoForMimeType(mimeType); + KPluginInfo::List wallpaperList; + if (drawWallpaper) { + if (wallpaper && wallpaper->supportsMimetype(mimeType)) { + wallpaperList << wallpaper->d->wallpaperDescription; + } else { + wallpaperList = Wallpaper::listWallpaperInfoForMimeType(mimeType); + } + } + + if (!appletList.isEmpty() || !wallpaperList.isEmpty()) { + choices->clear(); + QHash actionsToApplets; + choices->addTitle(i18n("Widgets")); + foreach (const KPluginInfo &info, appletList) { +#ifndef NDEBUG + kDebug() << info.name(); +#endif + QAction *action; + if (!info.icon().isEmpty()) { + action = choices->addAction(KDE::icon(info.icon()), info.name()); + } else { + action = choices->addAction(info.name()); + } + + actionsToApplets.insert(action, info.pluginName()); +#ifndef NDEBUG + kDebug() << info.pluginName(); +#endif + } + actionsToApplets.insert(choices->addAction(i18n("Icon")), "icon"); + + QHash actionsToWallpapers; + if (!wallpaperList.isEmpty()) { + choices->addTitle(i18n("Wallpaper")); + + QMap sorted; + foreach (const KPluginInfo &info, appletList) { + sorted.insert(info.name(), info); + } + + foreach (const KPluginInfo &info, wallpaperList) { + QAction *action; + if (!info.icon().isEmpty()) { + action = choices->addAction(KDE::icon(info.icon()), info.name()); + } else { + action = choices->addAction(info.name()); + } + + actionsToWallpapers.insert(action, info.pluginName()); + } + } + + QAction *choice = choices->exec(); + if (choice) { + // Put the job on hold so it can be recycled to fetch the actual content, + // which is to be expected when something's dropped onto the desktop and + // an applet is to be created with this URL + if (!mimeType.isEmpty() && !tjob->error()) { + tjob->putOnHold(); + KIO::Scheduler::publishSlaveOnHold(); + } + QString plugin = actionsToApplets.value(choice); + if (plugin.isEmpty()) { + //set wallpapery stuff + plugin = actionsToWallpapers.value(choice); + if (!wallpaper || plugin != wallpaper->pluginName()) { + //kDebug() << "Wallpaper dropped:" << tjob->url(); + q->setWallpaper(plugin); + } + + if (wallpaper) { + //kDebug() << "Wallpaper dropped:" << tjob->url(); + wallpaper->addUrls(QList() << tjob->url()); + } + } else { + addApplet(actionsToApplets[choice], args, QRectF(posi, QSize())); + } + + clearDataForMimeJob(job); + return; + } + } else { + // we can at least create an icon as a link to the URL + addApplet("icon", args, QRectF(posi, QSize())); + } + } + + clearDataForMimeJob(job); +#endif // PLASMA_NO_KIO +} + +void DeclarativeContainmentPrivate::focusApplet(Plasma::Applet *applet) +{ + if (focusedApplet == applet) { + return; + } + + QList widgets = actions()->associatedWidgets(); + if (focusedApplet) { + foreach (QWidget *w, widgets) { + focusedApplet->removeAssociatedWidget(w); + } + } + + if (applet && applets.contains(applet)) { + //kDebug() << "switching to" << applet->name(); + focusedApplet = applet; + foreach (QWidget *w, widgets) { + focusedApplet->addAssociatedWidget(w); + } + + if (!focusedApplet->hasFocus()) { + focusedApplet->setFocus(Qt::ShortcutFocusReason); + } + } else { + focusedApplet = 0; + } +} + +void DeclarativeContainmentPrivate::remoteAppletReady(Plasma::AccessAppletJob *job) +{ + QPointF pos = dropPoints.take(job); + if (job->error()) { + //TODO: nice user visible error handling (knotification probably?) +#ifndef NDEBUG + kDebug() << "remote applet access failed: " << job->errorText(); +#endif + return; + } + + if (!job->applet()) { +#ifndef NDEBUG + kDebug() << "how did we end up here? if applet is null, the job->error should be nonzero"; +#endif + return; + } + + q->addApplet(job->applet(), pos); +} + + +} diff --git a/intoDeclarativeEngine/declarativecontainment_p.h b/intoDeclarativeEngine/declarativecontainment_p.h new file mode 100644 index 000000000..8ad3f746e --- /dev/null +++ b/intoDeclarativeEngine/declarativecontainment_p.h @@ -0,0 +1,102 @@ +/* + * Copyright 2007 by Aaron Seigo + * Copyright 2008 by Ménard Alexis + * Copyright 2012 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 DECLARATIVECONTAINMENT_P_H +#define DECLARATIVECONTAINMENT_P_H + +#include +#include + +#include "plasma.h" +#include "applet.h" +#include "corona.h" + + +class KJob; + +namespace KIO +{ + class Job; +} + +namespace Plasma +{ + +class AccessAppletJob; +class Containment; + +class DeclarativeContainmentPrivate +{ +public: + DeclarativeContainmentPrivate(Containment *c) + : q(c), + focusedApplet(0), + wallpaper(0), + showDropZoneDelayTimer(0), + dropZoneStarted(false), + { + } + + ~DeclarativeContainmentPrivate() + { + qDeleteAll(dropMenus); + dropMenus.clear(); + } + + + void clearDataForMimeJob(KIO::Job *job); + void mimeTypeRetrieved(KIO::Job *job, const QString &mimetype); + void dropJobResult(KJob *); + void remoteAppletReady(Plasma::AccessAppletJob *job); + + + /** + * give keyboard focus to applet within this containment + */ + void focusApplet(Plasma::Applet *applet); + + /** + * Handles dropped/pasted mimetype data + * @param screenPos screen-relative position + * @param dropEvent the drop event (if null, the clipboard is used instead) + */ + void dropData(QPoint screenPos, QDropEvent *dropEvent = 0); + + /** + * Delayed drop zone display + */ + void showDropZoneDelayed(); + + DeclarativeContainment *q; + Applet *focusedApplet; + Plasma::Wallpaper *wallpaper; + QHash dropPoints; + QHash dropMenus; + QTimer *showDropZoneDelayTimer; + bool dropZoneStarted : 1; + + static const char defaultWallpaper[]; + static const char defaultWallpaperMode[]; +}; + +} // Plasma namespace + +#endif diff --git a/pluginloader.cpp b/pluginloader.cpp index 59be4d44a..78454cf3e 100644 --- a/pluginloader.cpp +++ b/pluginloader.cpp @@ -356,8 +356,6 @@ Package PluginLoader::loadPackage(const QString &packageFormat, const QString &s structure = new DataEnginePackage(); } else if (packageFormat.endsWith("/Runner")) { structure = new RunnerPackage(); - } else if (packageFormat.endsWith("/Wallpaper")) { - structure = new WallpaperPackage(); } else if (packageFormat.endsWith("/Theme")) { structure = new ThemePackage(); } else if (packageFormat.endsWith("/ContainmentActions")) { diff --git a/private/containment_p.cpp b/private/containment_p.cpp index 2119f9abf..695702c6a 100644 --- a/private/containment_p.cpp +++ b/private/containment_p.cpp @@ -48,7 +48,6 @@ #include "corona.h" #include "pluginloader.h" #include "svg.h" -#include "wallpaper.h" #include "remote/accessappletjob.h" #include "remote/accessmanager.h" @@ -302,420 +301,12 @@ void ContainmentPrivate::setScreen(int newScreen, int newDesktop, bool preventIn } } -void ContainmentPrivate::showDropZoneDelayed() -{ - dropZoneStarted = true; - q->showDropZone(dropPoints.value(0).toPoint()); - dropPoints.remove(0); -} - -void ContainmentPrivate::dropData(QPoint screenPos, QDropEvent *dropEvent) -{ - if (q->immutability() != Mutable) { - return; - } - - const QMimeData *mimeData = 0; - - if (dropEvent) { - mimeData = dropEvent->mimeData(); - } else { - QClipboard *clipboard = QApplication::clipboard(); - mimeData = clipboard->mimeData(QClipboard::Selection); - //TODO if that's not supported (ie non-linux) should we try clipboard instead of selection? - } - - if (!mimeData) { - //Selection is either empty or not supported on this OS -#ifndef NDEBUG - kDebug() << "no mime data"; -#endif - return; - } - - //kDebug() << event->mimeData()->text(); - - QString appletMimetype(q->corona() ? q->corona()->appletMimeType() : QString()); - - if (!appletMimetype.isEmpty() && mimeData->hasFormat(appletMimetype)) { - QString data = mimeData->data(appletMimetype); - const QStringList appletNames = data.split('\n', QString::SkipEmptyParts); - foreach (const QString &appletName, appletNames) { - //kDebug() << "doing" << appletName; - QRectF geom(screenPos, QSize(0, 0)); - q->addApplet(appletName, QVariantList(), geom); - } - if (dropEvent) { - dropEvent->acceptProposedAction(); - } - } else if (mimeData->hasUrls()) { - //TODO: collect the mimeTypes of available script engines and offer - // to create widgets out of the matching URLs, if any - const QList urls = KUrlMimeData::urlsFromMimeData(mimeData); - foreach (const QUrl &url, urls) { - if (AccessManager::supportedProtocols().contains(url.scheme())) { - AccessAppletJob *job = AccessManager::self()->accessRemoteApplet(url); - if (dropEvent) { - dropPoints[job] = dropEvent->pos(); - } else { - dropPoints[job] = screenPos; - } - QObject::connect(AccessManager::self(), SIGNAL(finished(Plasma::AccessAppletJob*)), - q, SLOT(remoteAppletReady(Plasma::AccessAppletJob*))); - } -#if !PLASMA_NO_KIO - else { - QMimeDatabase db; - QMimeType mime = db.mimeTypeForUrl(url); - QString mimeName = mime.name(); - QRectF geom(screenPos, QSize()); - QVariantList args; - args << url.toString(); -#ifndef NDEBUG - kDebug() << "can decode" << mimeName << args; -#endif - - // It may be a directory or a file, let's stat - KIO::JobFlags flags = KIO::HideProgressInfo; - KIO::MimetypeJob *job = KIO::mimetype(url, flags); - if (dropEvent) { - dropPoints[job] = dropEvent->pos(); - } else { - dropPoints[job] = screenPos; - } - - QObject::connect(job, SIGNAL(result(KJob*)), q, SLOT(dropJobResult(KJob*))); - QObject::connect(job, SIGNAL(mimetype(KIO::Job*,QString)), - q, SLOT(mimeTypeRetrieved(KIO::Job*,QString))); - - KMenu *choices = new KMenu("Content dropped"); - choices->addAction(KDE::icon("process-working"), i18n("Fetching file type...")); - if (dropEvent) { - choices->popup(dropEvent->pos()); - } else { - choices->popup(screenPos); - } - - dropMenus[job] = choices; - } -#endif - } - - if (dropEvent) { - dropEvent->acceptProposedAction(); - } - } else { - QStringList formats = mimeData->formats(); - QHash seenPlugins; - QHash pluginFormats; - - foreach (const QString &format, formats) { - KPluginInfo::List plugins = Applet::listAppletInfoForMimeType(format); - - foreach (const KPluginInfo &plugin, plugins) { - if (seenPlugins.contains(plugin.pluginName())) { - continue; - } - - seenPlugins.insert(plugin.pluginName(), plugin); - pluginFormats.insert(plugin.pluginName(), format); - } - } - //kDebug() << "Mimetype ..." << formats << seenPlugins.keys() << pluginFormats.values(); - - QString selectedPlugin; - - if (seenPlugins.isEmpty()) { - // do nothing - } else if (seenPlugins.count() == 1) { - selectedPlugin = seenPlugins.constBegin().key(); - } else { - KMenu choices; - QHash actionsToPlugins; - foreach (const KPluginInfo &info, seenPlugins) { - QAction *action; - if (!info.icon().isEmpty()) { - action = choices.addAction(KDE::icon(info.icon()), info.name()); - } else { - action = choices.addAction(info.name()); - } - - actionsToPlugins.insert(action, info.pluginName()); - } - - QAction *choice = choices.exec(screenPos); - if (choice) { - selectedPlugin = actionsToPlugins[choice]; - } - } - - if (!selectedPlugin.isEmpty()) { - if (!dropEvent) { - // since we may have entered an event loop up above with the menu, - // the clipboard item may no longer be valid, as QClipboard resets - // the object behind the back of the application with a zero timer - // so we fetch it again here - QClipboard *clipboard = QApplication::clipboard(); - mimeData = clipboard->mimeData(QClipboard::Selection); - } - - QTemporaryFile tempFile; - if (mimeData && tempFile.open()) { - //TODO: what should we do with files after the applet is done with them?? - tempFile.setAutoRemove(false); - - { - QDataStream stream(&tempFile); - QByteArray data = mimeData->data(pluginFormats[selectedPlugin]); - stream.writeRawData(data, data.size()); - } - - QRectF geom(screenPos, QSize()); - QVariantList args; - args << tempFile.fileName(); -#ifndef NDEBUG - kDebug() << args; -#endif - tempFile.close(); - - q->addApplet(selectedPlugin, args, geom); - } - } - } -} - -void ContainmentPrivate::clearDataForMimeJob(KIO::Job *job) -{ -#if !PLASMA_NO_KIO - QObject::disconnect(job, 0, q, 0); - dropPoints.remove(job); - KMenu *choices = dropMenus.take(job); - delete choices; - job->kill(); -#endif // PLASMA_NO_KIO -} - -void ContainmentPrivate::remoteAppletReady(Plasma::AccessAppletJob *job) -{ - QPointF pos = dropPoints.take(job); - if (job->error()) { - //TODO: nice user visible error handling (knotification probably?) -#ifndef NDEBUG - kDebug() << "remote applet access failed: " << job->errorText(); -#endif - return; - } - - if (!job->applet()) { -#ifndef NDEBUG - kDebug() << "how did we end up here? if applet is null, the job->error should be nonzero"; -#endif - return; - } - - q->addApplet(job->applet(), pos); -} - -void ContainmentPrivate::dropJobResult(KJob *job) -{ -#if !PLASMA_NO_KIO - KIO::TransferJob* tjob = dynamic_cast(job); - if (!tjob) { -#ifndef NDEBUG - kDebug() << "job is not a KIO::TransferJob, won't handle the drop..."; -#endif - clearDataForMimeJob(tjob); - return; - } - if (job->error()) { -#ifndef NDEBUG - kDebug() << "ERROR" << tjob->error() << ' ' << tjob->errorString(); -#endif - } - // We call mimeTypeRetrieved since there might be other mechanisms - // for finding suitable applets. Cleanup happens there as well. - mimeTypeRetrieved(qobject_cast(job), QString()); -#endif // PLASMA_NO_KIO -} - -void ContainmentPrivate::mimeTypeRetrieved(KIO::Job *job, const QString &mimeType) -{ -#if !PLASMA_NO_KIO -#ifndef NDEBUG - kDebug() << "Mimetype Job returns." << mimeType; -#endif - KIO::TransferJob* tjob = dynamic_cast(job); - if (!tjob) { -#ifndef NDEBUG - kDebug() << "job should be a TransferJob, but isn't"; -#endif - clearDataForMimeJob(job); - return; - } - KPluginInfo::List appletList = Applet::listAppletInfoForUrl(tjob->url()); - if (mimeType.isEmpty() && !appletList.count()) { - clearDataForMimeJob(job); -#ifndef NDEBUG - kDebug() << "No applets found matching the url (" << tjob->url() << ") or the mimeType (" << mimeType << ")"; -#endif - return; - } else { - - QPointF posi; // will be overwritten with the event's position - if (dropPoints.keys().contains(tjob)) { - posi = dropPoints[tjob]; -#ifndef NDEBUG - kDebug() << "Received a suitable dropEvent at" << posi; -#endif - } else { -#ifndef NDEBUG - kDebug() << "Bailing out. Cannot find associated dropEvent related to the TransferJob"; -#endif - clearDataForMimeJob(job); - return; - } - - KMenu *choices = dropMenus.value(tjob); - if (!choices) { -#ifndef NDEBUG - kDebug() << "Bailing out. No QMenu found for this job."; -#endif - clearDataForMimeJob(job); - return; - } - - QVariantList args; - args << tjob->url().toString() << mimeType; - -#ifndef NDEBUG - kDebug() << "Creating menu for:" << mimeType << posi << args; -#endif - - appletList << Applet::listAppletInfoForMimeType(mimeType); - KPluginInfo::List wallpaperList; - if (drawWallpaper) { - if (wallpaper && wallpaper->supportsMimetype(mimeType)) { - wallpaperList << wallpaper->d->wallpaperDescription; - } else { - wallpaperList = Wallpaper::listWallpaperInfoForMimeType(mimeType); - } - } - - if (!appletList.isEmpty() || !wallpaperList.isEmpty()) { - choices->clear(); - QHash actionsToApplets; - choices->addTitle(i18n("Widgets")); - foreach (const KPluginInfo &info, appletList) { -#ifndef NDEBUG - kDebug() << info.name(); -#endif - QAction *action; - if (!info.icon().isEmpty()) { - action = choices->addAction(KDE::icon(info.icon()), info.name()); - } else { - action = choices->addAction(info.name()); - } - - actionsToApplets.insert(action, info.pluginName()); -#ifndef NDEBUG - kDebug() << info.pluginName(); -#endif - } - actionsToApplets.insert(choices->addAction(i18n("Icon")), "icon"); - - QHash actionsToWallpapers; - if (!wallpaperList.isEmpty()) { - choices->addTitle(i18n("Wallpaper")); - - QMap sorted; - foreach (const KPluginInfo &info, appletList) { - sorted.insert(info.name(), info); - } - - foreach (const KPluginInfo &info, wallpaperList) { - QAction *action; - if (!info.icon().isEmpty()) { - action = choices->addAction(KDE::icon(info.icon()), info.name()); - } else { - action = choices->addAction(info.name()); - } - - actionsToWallpapers.insert(action, info.pluginName()); - } - } - - QAction *choice = choices->exec(); - if (choice) { - // Put the job on hold so it can be recycled to fetch the actual content, - // which is to be expected when something's dropped onto the desktop and - // an applet is to be created with this URL - if (!mimeType.isEmpty() && !tjob->error()) { - tjob->putOnHold(); - KIO::Scheduler::publishSlaveOnHold(); - } - QString plugin = actionsToApplets.value(choice); - if (plugin.isEmpty()) { - //set wallpapery stuff - plugin = actionsToWallpapers.value(choice); - if (!wallpaper || plugin != wallpaper->pluginName()) { - //kDebug() << "Wallpaper dropped:" << tjob->url(); - q->setWallpaper(plugin); - } - - if (wallpaper) { - //kDebug() << "Wallpaper dropped:" << tjob->url(); - wallpaper->addUrls(QList() << tjob->url()); - } - } else { - addApplet(actionsToApplets[choice], args, QRectF(posi, QSize())); - } - - clearDataForMimeJob(job); - return; - } - } else { - // we can at least create an icon as a link to the URL - addApplet("icon", args, QRectF(posi, QSize())); - } - } - - clearDataForMimeJob(job); -#endif // PLASMA_NO_KIO -} KActionCollection* ContainmentPrivate::actions() { return static_cast(q)->d->actions; } -void ContainmentPrivate::focusApplet(Plasma::Applet *applet) -{ - if (focusedApplet == applet) { - return; - } - - QList widgets = actions()->associatedWidgets(); - if (focusedApplet) { - foreach (QWidget *w, widgets) { - focusedApplet->removeAssociatedWidget(w); - } - } - - if (applet && applets.contains(applet)) { - //kDebug() << "switching to" << applet->name(); - focusedApplet = applet; - foreach (QWidget *w, widgets) { - focusedApplet->addAssociatedWidget(w); - } - - if (!focusedApplet->hasFocus()) { - focusedApplet->setFocus(Qt::ShortcutFocusReason); - } - } else { - focusedApplet = 0; - } -} - void ContainmentPrivate::configChanged() { if (drawWallpaper) { @@ -831,9 +422,6 @@ Applet *ContainmentPrivate::addApplet(const QString &name, const QVariantList &a void ContainmentPrivate::appletDeleted(Plasma::Applet *applet) { applets.removeAll(applet); - if (focusedApplet == applet) { - focusedApplet = 0; - } emit q->appletRemoved(applet); emit q->configNeedsSaving(); diff --git a/private/containment_p.h b/private/containment_p.h index fb5b4c394..baffad771 100644 --- a/private/containment_p.h +++ b/private/containment_p.h @@ -52,16 +52,12 @@ public: : q(c), formFactor(Planar), location(Floating), - focusedApplet(0), - wallpaper(0), screen(-1), // no screen lastScreen(-1), desktop(-1), // all desktops lastDesktop(-1), type(Containment::NoContainmentType), - showDropZoneDelayTimer(0), drawWallpaper(true), - dropZoneStarted(false), containmentActionsSource(Global) { } @@ -73,9 +69,6 @@ public: delete applets.first(); } applets.clear(); - - qDeleteAll(dropMenus); - dropMenus.clear(); } void triggerShowAddWidgets(); @@ -96,10 +89,6 @@ public: void setLockToolText(); void appletDeleted(Applet*); void appletAppeared(Applet*); - void clearDataForMimeJob(KIO::Job *job); - void remoteAppletReady(Plasma::AccessAppletJob *job); - void mimeTypeRetrieved(KIO::Job *job, const QString &mimetype); - void dropJobResult(KJob *); void addContainmentActions(KMenu &desktopMenu, QEvent *event); void addAppletActions(KMenu &desktopMenu, Applet *applet, QEvent *event); void checkRemoveAction(); @@ -116,18 +105,6 @@ public: */ static void addDefaultActions(KActionCollection *actions, Containment *c = 0); - /** - * give keyboard focus to applet within this containment - */ - void focusApplet(Plasma::Applet *applet); - - /** - * Handles dropped/pasted mimetype data - * @param screenPos screen-relative position - * @param dropEvent the drop event (if null, the clipboard is used instead) - */ - void dropData(QPoint screenPos, QDropEvent *dropEvent = 0); - /** * inits the containmentactions if necessary * if it needs configuring, this warns the user and returns false @@ -140,11 +117,8 @@ public: */ bool prepareContainmentActions(const QString &trigger, const QPoint &screenPos, KMenu *menu = 0); - /** - * Delayed drop zone display - */ - void showDropZoneDelayed(); + QHash *actionPlugins(); static bool s_positioningPanels; @@ -153,8 +127,8 @@ public: FormFactor formFactor; Location location; Applet::List applets; - Applet *focusedApplet; - Plasma::Wallpaper *wallpaper; + QString wallpaper; + QString wallpaperMode; QHash localActionPlugins; int screen; int lastScreen; @@ -163,11 +137,7 @@ public: QList toolBoxActions; QString activityId; Containment::Type type; - QHash dropPoints; - QHash dropMenus; - QTimer *showDropZoneDelayTimer; bool drawWallpaper : 1; - bool dropZoneStarted : 1; enum ContainmentActionsSource { Global = 0, diff --git a/private/packages.cpp b/private/packages.cpp index 9b1a68ff2..37c8644e7 100644 --- a/private/packages.cpp +++ b/private/packages.cpp @@ -267,145 +267,6 @@ void ThemePackage::initPackage(Package *package) package->setDefaultMimeTypes(mimetypes); } -WallpaperPackage::WallpaperPackage(Wallpaper *paper) - : PackageStructure(), - m_fullPackage(true), - m_targetSize(100000, 100000), - m_resizeMethod(Wallpaper::ScaledResize) -{ - if (paper) { - connect(paper, SIGNAL(renderHintsChanged()), this, SLOT(renderHintsChanged())); - } -} - -void WallpaperPackage::initPackage(Package *package) -{ - QStringList mimetypes; - mimetypes << "image/svg" << "image/png" << "image/jpeg" << "image/jpg"; - package->setDefaultMimeTypes(mimetypes); - - package->addDirectoryDefinition("images", "images/", i18n("Images")); - package->setRequired("images", true); - package->addFileDefinition("screenshot", "screenshot.png", i18n("Screenshot")); - package->setAllowExternalPaths(true); -} - -void WallpaperPackage::renderHintsChanged() -{ - Wallpaper *paper = qobject_cast(sender()); - if (!paper) { - return; - } - - if (m_fullPackage) { - //FIXME: findBestPaper(packages.value(paper)); - } -} - -void WallpaperPackage::pathChanged(Package *package) -{ - static bool guard = false; - - if (guard) { - return; - } - - guard = true; - - QFileInfo info(package->path()); - 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->setContentsPrefixPaths(QStringList()); - //kDebug() << "changing" << path() << "to" << info.path(); - package->setPath(info.path()); - } - - guard = false; -} - -QSize WallpaperPackage::resSize(const QString &str) const -{ - const int index = str.indexOf('x'); - if (index != -1) { - return QSize(str.left(index).toInt(), str.mid(index + 1).toInt()); - } - - return QSize(); -} - -void WallpaperPackage::findBestPaper(Package *package) -{ - QStringList images = package->entryList("images"); - if (images.empty()) { - return; - } - - //kDebug() << "wanted" << size; - - // choose the nearest resolution - float best = FLT_MAX; - - QString bestImage; - foreach (const QString &entry, images) { - const QSize candidate = resSize(QFileInfo(entry).baseName()); - if (candidate == QSize()) { - continue; - } - - double dist = distance(candidate, m_targetSize, m_resizeMethod); - //kDebug() << "candidate" << candidate << "distance" << dist; - if (bestImage.isEmpty() || dist < best) { - bestImage = entry; - best = dist; - //kDebug() << "best" << bestImage; - if (dist == 0) { - break; - } - } - } - - //kDebug() << "best image" << bestImage; - package->addFileDefinition("preferred", package->filePath("images") + bestImage, i18n("Recommended wallpaper file")); -} - -float WallpaperPackage::distance(const QSize& size, const QSize& desired, - Plasma::Wallpaper::ResizeMethod method) 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; - - - switch (method) { - case Plasma::Wallpaper::ScaledResize: { - // Consider first the difference in aspect ratio, - // then in areas. Prefer scaling down. - float deltaRatio = 1.0; - if (size.height() > 0 && desired.height() > 0) { - deltaRatio = float(size.width()) / float(size.height()) - - float(desired.width()) / float(desired.height()); - } - return fabs(deltaRatio) * 3.0 + (delta >= 0.0 ? delta : -delta + 5.0); - } - case Plasma::Wallpaper::ScaledAndCroppedResize: - // Difference of areas, slight preference to scale down - return delta >= 0.0 ? delta : -delta + 2.0; - default: - // Difference in areas - return fabs(delta); - } -} - void ContainmentActionsPackage::initPackage(Package *package) { ChangeableMainScriptPackage::initPackage(package); diff --git a/private/packages_p.h b/private/packages_p.h index 0fb11e453..ebba8c0bf 100644 --- a/private/packages_p.h +++ b/private/packages_p.h @@ -22,7 +22,6 @@ #include "packagestructure.h" #include "plasma.h" -#include "wallpaper.h" namespace Plasma { @@ -71,31 +70,6 @@ public: void initPackage(Package *package); }; -class WallpaperPackage : public PackageStructure -{ - Q_OBJECT - -public: - explicit WallpaperPackage(Wallpaper *paper = 0); - void initPackage(Package *package); - void pathChanged(Package *package); - -private: - QSize resSize(const QString &str) const; - void findBestPaper(Package *package); - float distance(const QSize& size, const QSize& desired, - Plasma::Wallpaper::ResizeMethod method) const; - -private Q_SLOTS: - void renderHintsChanged(); - -private: - Wallpaper *m_paper; - bool m_fullPackage; - QSize m_targetSize; - Wallpaper::ResizeMethod m_resizeMethod; -}; - class ContainmentActionsPackage : public ChangeableMainScriptPackage { public: diff --git a/private/wallpaper_p.h b/private/wallpaper_p.h index 6c55cfb63..7dfe9d417 100644 --- a/private/wallpaper_p.h +++ b/private/wallpaper_p.h @@ -42,12 +42,8 @@ public: int resizeMethod, const QColor &color) const; void initScript(); - bool findInCache(const QString &key, unsigned int lastModified = 0); - void newRenderCompleted(const WallpaperRenderRequest &render, const QImage &image); void setupScriptSupport(); - void renderWallpaper(const QString &sourceImagePath, const QImage &image, const QSize &size, - Wallpaper::ResizeMethod resizeMethod, const QColor &color); Wallpaper *q; KPluginInfo wallpaperDescription; @@ -69,20 +65,6 @@ public: bool needsPreviewDuringConfiguration : 1; }; -class LoadImageThread : public QObject, public QRunnable -{ - Q_OBJECT -public: - LoadImageThread(const QString &filePath); - void run(); - -Q_SIGNALS: - void done(const QImage &pixmap); - -private: - QString m_filePath; -}; - } // namespace Plasma #endif diff --git a/scripting/scriptengine.cpp b/scripting/scriptengine.cpp index b274de731..1970382a6 100644 --- a/scripting/scriptengine.cpp +++ b/scripting/scriptengine.cpp @@ -31,7 +31,6 @@ #include "scripting/appletscript.h" #include "scripting/dataenginescript.h" #include "scripting/runnerscript.h" -#include "scripting/wallpaperscript.h" namespace Plasma { @@ -94,14 +93,6 @@ QStringList knownLanguages(ComponentTypes types) constraint.append(constraintTemplate.arg("Runner")); } - if (types & WallpaperComponent) { - if (!constraint.isEmpty()) { - constraint.append(" or "); - } - - constraint.append(constraintTemplate.arg("Wallpaper")); - } - KService::List offers = KServiceTypeTrader::self()->query("Plasma/ScriptEngine", constraint); //kDebug() << "Applet::knownApplets constraint was '" << constraint // << "' which got us " << offers.count() << " matches"; @@ -142,9 +133,6 @@ KService::List engineOffers(const QString &language, ComponentType type) case RunnerComponent: component = "Runner"; break; - case WallpaperComponent: - component = "Wallpaper"; - break; default: return KService::List(); break; @@ -183,9 +171,6 @@ ScriptEngine *loadEngine(const QString &language, ComponentType type, QObject *p case RunnerComponent: engine = service->createInstance(parent, args, &error); break; - case WallpaperComponent: - engine = service->createInstance(parent, args, &error); - break; default: return 0; break; @@ -242,18 +227,6 @@ RunnerScript *loadScriptEngine(const QString &language, AbstractRunner *runner) return engine; } -WallpaperScript *loadScriptEngine(const QString &language, Wallpaper *wallpaper) -{ - WallpaperScript *engine = - static_cast(loadEngine(language, WallpaperComponent, wallpaper)); - - if (engine) { - engine->setWallpaper(wallpaper); - } - - return engine; -} - } // namespace Plasma #include "moc_scriptengine.cpp" diff --git a/scripting/wallpaperscript.cpp b/scripting/wallpaperscript.cpp index f8d9d85ff..46a689920 100644 --- a/scripting/wallpaperscript.cpp +++ b/scripting/wallpaperscript.cpp @@ -94,26 +94,6 @@ QWidget *WallpaperScript::createConfigurationInterface(QWidget *parent) return 0; } -void WallpaperScript::mouseMoveEvent(QMouseEvent *event) -{ - Q_UNUSED(event) -} - -void WallpaperScript::mousePressEvent(QMouseEvent *event) -{ - Q_UNUSED(event) -} - -void WallpaperScript::mouseReleaseEvent(QMouseEvent *event) -{ - Q_UNUSED(event) -} - -void WallpaperScript::wheelEvent(QWheelEvent *event) -{ - Q_UNUSED(event) -} - void WallpaperScript::addUrls(const QList & urls) { Q_UNUSED(urls) @@ -135,12 +115,6 @@ QRectF WallpaperScript::boundingRect() const return QRectF(); } -DataEngine *WallpaperScript::dataEngine(const QString &name) const -{ - Q_ASSERT(d->wallpaper); - return d->wallpaper->dataEngine(name); -} - void WallpaperScript::setResizeMethodHint(Wallpaper::ResizeMethod resizeMethod) { if (d->wallpaper) { @@ -162,37 +136,6 @@ void WallpaperScript::setConfigurationRequired(bool needsConfiguring, const QStr } } -void WallpaperScript::render(const QString &sourceImagePath, const QSize &size, - Wallpaper::ResizeMethod resizeMethod, const QColor &color) -{ - if (d->wallpaper) { - d->wallpaper->setWallpaperPath(sourceImagePath); - d->wallpaper->render(size, resizeMethod, color); - } -} - -void WallpaperScript::setUsingRenderingCache(bool useCache) -{ - if (d->wallpaper) { - d->wallpaper->setUsingRenderingCache(useCache); - } -} - -bool WallpaperScript::findInCache(const QString &key, QImage &image, unsigned int lastModified) -{ - if (d->wallpaper) { - return d->wallpaper->findInCache(key, image, lastModified); - } - return false; -} - -void WallpaperScript::insertIntoCache(const QString& key, const QImage &image) -{ - if (d->wallpaper) { - d->wallpaper->insertIntoCache(key, image); - } -} - void WallpaperScript::setContextualActions(const QList &actions) { if (d->wallpaper) { diff --git a/scripting/wallpaperscript.h b/scripting/wallpaperscript.h index 1dc293681..272f76875 100644 --- a/scripting/wallpaperscript.h +++ b/scripting/wallpaperscript.h @@ -104,38 +104,6 @@ public: */ virtual QWidget *createConfigurationInterface(QWidget *parent); - /** - * Mouse move event. To prevent further propagation of the event, - * the event must be accepted. - * - * @param event the mouse event object - */ - virtual void mouseMoveEvent(QMouseEvent *event); - - /** - * Mouse press event. To prevent further propagation of the even, - * and to receive mouseMoveEvents, the event must be accepted. - * - * @param event the mouse event object - */ - virtual void mousePressEvent(QMouseEvent *event); - - /** - * Mouse release event. To prevent further propagation of the event, - * the event must be accepted. - * - * @param event the mouse event object - */ - virtual void mouseReleaseEvent(QMouseEvent *event); - - /** - * Mouse wheel event. To prevent further propagation of the event, - * the event must be accepted. - * - * @param event the wheel event object - */ - virtual void wheelEvent(QWheelEvent *event); - /** * Adds urls (e.g. from a drop) */ @@ -161,16 +129,9 @@ protected: bool isInitialized() const; QRectF boundingRect() const; - DataEngine *dataEngine(const QString &name) const; void setResizeMethodHint(Wallpaper::ResizeMethod resizeMethod); void setTargetSizeHint(const QSizeF &targetSize); void setConfigurationRequired(bool needsConfiguring, const QString &reason = QString()); - void render(const QString &sourceImagePath, const QSize &size, - Wallpaper::ResizeMethod resizeMethod = Plasma::Wallpaper::ScaledResize, - const QColor &color = QColor(0, 0, 0)); - void setUsingRenderingCache(bool useCache); - bool findInCache(const QString &key, QImage &image, unsigned int lastModified = 0); - void insertIntoCache(const QString& key, const QImage &image); void setContextualActions(const QList &actions); void update(const QRectF &exposedArea); void configNeedsSaving(); diff --git a/wallpaper.cpp b/wallpaper.cpp index 1fc639b46..2f931313c 100644 --- a/wallpaper.cpp +++ b/wallpaper.cpp @@ -53,52 +53,6 @@ namespace Plasma { -class SaveImageThread : public QRunnable -{ - QImage m_image; - QString m_filePath; - - public: - SaveImageThread(const QImage &image, const QString &filePath) - { - m_image = image; - m_filePath = filePath; - } - - void run() - { - m_image.save(m_filePath); - } -}; - -LoadImageThread::LoadImageThread(const QString &filePath) -{ - m_filePath = filePath; -} - -void LoadImageThread::run() -{ - QImage image; - image.load(m_filePath); - emit done(image); -} - -class WallpaperWithPaint : public Wallpaper -{ -public: - WallpaperWithPaint(QObject *parent, const QVariantList &args) - : Wallpaper(parent, args) - { - } - - virtual void paint(QPainter *painter, const QRectF &exposedRect) - { - if (d->script) { - d->script->paint(painter, exposedRect); - } - } -}; - Wallpaper::Wallpaper(QObject * parentObject) : d(new WallpaperPrivate(KService::serviceByStorageId(QString()), this)) { @@ -188,7 +142,7 @@ Wallpaper *Wallpaper::load(const QString &wallpaperName, const QVariantList &arg kDebug() << "we have a script using the" << offer->property("X-Plasma-API").toString() << "API"; #endif - return new WallpaperWithPaint(0, allArgs); + return new Wallpaper(0, allArgs); } KPluginLoader plugin(*offer); @@ -318,6 +272,7 @@ void Wallpaper::restore(const KConfigGroup &config) d->initialized = true; } + void Wallpaper::init(const KConfigGroup &config) { if (d->script) { @@ -333,47 +288,6 @@ void Wallpaper::save(KConfigGroup &config) } } -QWidget *Wallpaper::createConfigurationInterface(QWidget *parent) -{ - if (d->script) { - return d->script->createConfigurationInterface(parent); - } else { - return 0; - } -} - -void Wallpaper::mouseMoveEvent(QMouseEvent *event) -{ - if (d->script) { - return d->script->mouseMoveEvent(event); - } -} - -void Wallpaper::mousePressEvent(QMouseEvent *event) -{ - if (d->script) { - return d->script->mousePressEvent(event); - } -} - -void Wallpaper::mouseReleaseEvent(QMouseEvent *event) -{ - if (d->script) { - return d->script->mouseReleaseEvent(event); - } -} - -void Wallpaper::wheelEvent(QWheelEvent *event) -{ - if (d->script) { - return d->script->wheelEvent(event); - } -} - -DataEngine *Wallpaper::dataEngine(const QString &name) const -{ - return d->dataEngine(name); -} bool Wallpaper::configurationRequired() const { @@ -394,16 +308,6 @@ void Wallpaper::setConfigurationRequired(bool needsConfig, const QString &reason emit configurationRequired(needsConfig); } -bool Wallpaper::isUsingRenderingCache() const -{ - return d->cacheRendering; -} - -void Wallpaper::setUsingRenderingCache(bool useCache) -{ - d->cacheRendering = useCache; -} - void Wallpaper::setResizeMethodHint(Wallpaper::ResizeMethod resizeMethod) { const ResizeMethod method = qBound(ScaledResize, resizeMethod, LastResizeMethod); @@ -431,51 +335,6 @@ QSizeF Wallpaper::targetSizeHint() const return d->targetSize; } -void Wallpaper::render(const QImage &image, const QSize &size, - Wallpaper::ResizeMethod resizeMethod, const QColor &color) -{ - if (image.isNull()) { - return; - } - - d->renderWallpaper(QString(), image, size, resizeMethod, color); -} - -void Wallpaper::render(const QSize &size, Wallpaper::ResizeMethod resizeMethod, - const QColor &color) -{ - d->renderWallpaper(d->wallpaperPath, QImage(), size, resizeMethod, color); -} - -void WallpaperPrivate::renderWallpaper(const QString &sourceImagePath, const QImage &image, const QSize &size, - Wallpaper::ResizeMethod resizeMethod, const QColor &color) -{ - resizeMethod = qBound(Wallpaper::ScaledResize, resizeMethod, Wallpaper::LastResizeMethod); - if (lastResizeMethod != resizeMethod) { - lastResizeMethod = resizeMethod; - emit q->renderHintsChanged(); - } - - if (cacheRendering) { - QFileInfo info(sourceImagePath); - QString cache = cacheKey(sourceImagePath, size, resizeMethod, color); - if (findInCache(cache, info.lastModified().toTime_t())) { - return; - } - } - - WallpaperRenderRequest request; - renderToken = request.token; - request.requester = q; - request.providedImage = image; - request.file = sourceImagePath; - request.size = size; - request.resizeMethod = resizeMethod; - request.color = color; - WallpaperRenderThread::render(request); - //kDebug() << "rendering" << sourceImagePath << ", token is" << d->renderToken; -} - WallpaperPrivate::WallpaperPrivate(KService::Ptr service, Wallpaper *wallpaper) : q(wallpaper), wallpaperDescription(service), @@ -529,24 +388,6 @@ QString WallpaperPrivate::cachePath(const QString &key) const return QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QLatin1Char('/') + "plasma-wallpapers/" + key + ".png"; } -void WallpaperPrivate::newRenderCompleted(const WallpaperRenderRequest &request, const QImage &image) -{ -#ifndef NDEBUG - kDebug() << request.token << renderToken; -#endif - if (request.token != renderToken) { - //kDebug() << "render token mismatch" << token << renderToken; - return; - } - - if (cacheRendering) { - q->insertIntoCache(cacheKey(request.file, request.size, request.resizeMethod, request.color), image); - } - - //kDebug() << "rendering complete!"; - emit q->renderCompleted(image); -} - // put all setup routines for script here. at this point we can assume that // package exists and that we have a script engine void WallpaperPrivate::setupScriptSupport() @@ -573,65 +414,6 @@ void WallpaperPrivate::initScript() } } -bool WallpaperPrivate::findInCache(const QString &key, unsigned int lastModified) -{ - if (cacheRendering) { - QString cache = cachePath(key); - if (QFile::exists(cache)) { - if (lastModified > 0) { - QFileInfo info(cache); - if (info.lastModified().toTime_t() < lastModified) { - return false; - } - } - - LoadImageThread *loadImageT = new LoadImageThread(cache); - q->connect(loadImageT, SIGNAL(done(QImage)), q, SIGNAL(renderCompleted(QImage))); - QThreadPool::globalInstance()->start(loadImageT); - - return true; - } - } - - return false; -} - -bool Wallpaper::findInCache(const QString &key, QImage &image, unsigned int lastModified) -{ - if (d->cacheRendering) { - QString cache = d->cachePath(key); - if (QFile::exists(cache)) { - if (lastModified > 0) { - QFileInfo info(cache); - if (info.lastModified().toTime_t() < lastModified) { - return false; - } - } - - image.load(cache); - return true; - } - } - - return false; -} - -void Wallpaper::insertIntoCache(const QString& key, const QImage &image) -{ - //TODO: cache limits? - if (key.isEmpty()) { - return; - } - - if (d->cacheRendering) { - if (image.isNull()) { - QFile::remove(d->cachePath(key)); - } else { - QThreadPool::globalInstance()->start(new SaveImageThread(image, d->cachePath(key))); - } - } -} - QList Wallpaper::contextualActions() const { return d->contextActions; diff --git a/wallpaper.h b/wallpaper.h index 234265590..97898c9ad 100644 --- a/wallpaper.h +++ b/wallpaper.h @@ -29,9 +29,6 @@ #include #include -class QMouseEvent; -class QWheelEvent; - namespace Plasma { @@ -59,13 +56,11 @@ class WallpaperPrivate; class PLASMA_EXPORT Wallpaper : public QObject { Q_OBJECT - Q_PROPERTY(QRectF boundingRect READ boundingRect WRITE setBoundingRect) Q_PROPERTY(QString name READ name) Q_PROPERTY(QString pluginName READ pluginName) Q_PROPERTY(QString icon READ icon) Q_PROPERTY(KServiceAction renderingMode READ renderingMode) Q_PROPERTY(QList listRenderingModes READ listRenderingModes) - Q_PROPERTY(bool usingRenderingCache READ isUsingRenderingCache WRITE setUsingRenderingCache) Q_PROPERTY(bool previewing READ isPreviewing WRITE setPreviewing) Q_PROPERTY(ResizeMethod resizeMethod READ resizeMethodHint WRITE setResizeMethodHint) Q_PROPERTY(QSizeF targetSize READ targetSizeHint WRITE setTargetSizeHint) @@ -209,14 +204,6 @@ class PLASMA_EXPORT Wallpaper : public QObject */ virtual void addUrls(const QList &urls); - /** - * This method is called when the wallpaper should be painted. - * - * @param painter the QPainter to use to do the painting - * @param exposedRect the rect to paint within - **/ - virtual void paint(QPainter *painter, const QRectF &exposedRect) = 0; - /** * This method should be called once the wallpaper is loaded or mode is changed. * @param config Config group to load settings @@ -230,77 +217,6 @@ class PLASMA_EXPORT Wallpaper : public QObject **/ virtual void save(KConfigGroup &config); - /** - * Returns a widget that can be used to configure the options (if any) - * associated with this wallpaper. It will be deleted by the caller - * when it complete. The default implementation returns a null pointer. - * - * To signal that settings have changed connect to - * settingsChanged(bool modified) in @p parent. - * - * @code connect(this, SIGNAL(settingsChanged(bool), parent, SLOT(settingsChanged(bool))) - * @endcode - * - * Emit settingsChanged(true) when the settings are changed and false when the original state is restored. - * - * Implementation detail note: for best visual results, use a QGridLayout with two columns, - * with the option labels in column 0 - */ - virtual QWidget *createConfigurationInterface(QWidget *parent); - - /** - * Mouse move event. To prevent further propagation of the event, - * the event must be accepted. - * - * @param event the mouse event object - */ - virtual void mouseMoveEvent(QMouseEvent *event); - - /** - * Mouse press event. To prevent further propagation of the even, - * and to receive mouseMoveEvents, the event must be accepted. - * - * @param event the mouse event object - */ - virtual void mousePressEvent(QMouseEvent *event); - - /** - * Mouse release event. To prevent further propagation of the event, - * the event must be accepted. - * - * @param event the mouse event object - */ - virtual void mouseReleaseEvent(QMouseEvent *event); - - /** - * Mouse wheel event. To prevent further propagation of the event, - * the event must be accepted. - * - * @param event the wheel event object - */ - virtual void wheelEvent(QWheelEvent *event); - - /** - * Loads the given DataEngine - * - * Tries to load the data engine given by @p name. Each engine is - * only loaded once, and that instance is re-used on all subsequent - * requests. - * - * If the data engine was not found, an invalid data engine is returned - * (see DataEngine::isValid()). - * - * Note that you should not delete the returned engine. - * - * @param name Name of the data engine to load - * @return pointer to the data engine if it was loaded, - * or an invalid data engine if the requested engine - * could not be loaded - * - * @since 4.3 - */ - Q_INVOKABLE DataEngine *dataEngine(const QString &name) const; - /** * @return true if the wallpaper currently needs to be configured, * otherwise, false @@ -308,12 +224,6 @@ class PLASMA_EXPORT Wallpaper : public QObject */ bool configurationRequired() const; - /** - * @return true if disk caching is turned on. - * @since 4.3 - */ - bool isUsingRenderingCache() const; - virtual void setWallpaperPath(const QString& path); /** @@ -403,12 +313,6 @@ class PLASMA_EXPORT Wallpaper : public QObject */ void configNeedsSaving(); - /** - * Emitted when a wallpaper image render is completed. - * @since 4.3 - */ - void renderCompleted(const QImage &image); - /** * @internal */ @@ -447,78 +351,6 @@ class PLASMA_EXPORT Wallpaper : public QObject */ void setConfigurationRequired(bool needsConfiguring, const QString &reason = QString()); - /** - * Renders the wallpaper asyncronously with the given parameters. When the rendering is - * complete, the renderCompleted signal is emitted. - * - * @param sourceImagePath the path to the image file on disk. Common image formats such as - * PNG, JPEG and SVG are supported - * @param size the size to render the image as - * @param resizeMethod the method to use when resizing the image to fit size, @see - * ResizeMethod - * @param color the color to use to pad the rendered image if it doesn't take up the - * entire size with the given ResizeMethod - * @since 4.3 - */ - void render(const QSize &size, Wallpaper::ResizeMethod resizeMethod = ScaledResize, - const QColor &color = QColor(0, 0, 0)); - - /** - * Renders the wallpaper asyncronously with the given parameters. When the rendering is - * complete, the renderCompleted signal is emitted. - * - * @param image the raw QImage - * @param size the size to render the image as - * @param resizeMethod the method to use when resizing the image to fit size, @see - * ResizeMethod - * @param color the color to use to pad the rendered image if it doesn't take up the - * entire size with the given ResizeMethod - * @since 4.7.4 - */ - void render(const QImage &image, const QSize &size, - Wallpaper::ResizeMethod resizeMethod = ScaledResize, - const QColor &color = QColor(0, 0, 0)); - - /** - * Sets whether or not to cache on disk the results of calls to render. If the wallpaper - * changes often or is innexpensive to render, then it's probably best not to cache them. - * - * The default is not to cache. - * - * @see render - * @param useCache true to cache rendered papers on disk, false not to cache - * @since 4.3 - */ - void setUsingRenderingCache(bool useCache); - - /** - * Tries to load pixmap with the specified key from cache. - * - * @param key the name to use in the cache for this image - * @param image the image object to populate with the resulting data if found - * @param lastModified if non-zero, the time stamp is also checked on the file, - * and must be newer than the timestamp to be loaded - * - * @return true when pixmap was found and loaded from cache, false otherwise - * @since 4.3 - **/ - bool findInCache(const QString &key, QImage &image, unsigned int lastModified = 0); - - /** - * Insert specified pixmap into the cache if usingRenderingCache. - * If the cache already contains pixmap with the specified key then it is - * overwritten. - * - * @param key the name use in the cache for this image; if the image is specific - * to this wallpaper plugin, consider including the name() as part of - * the cache key to avoid collisions with other plugins. - * @param image the image to store in the cache; passing in a null image will cause - * the cached image to be removed from the cache - * - * @since 4.3 - **/ - void insertIntoCache(const QString& key, const QImage &image); - /** * Sets the contextual actions for this wallpaper. * @@ -539,8 +371,6 @@ class PLASMA_EXPORT Wallpaper : public QObject void setPreviewDuringConfiguration(const bool preview); private: - Q_PRIVATE_SLOT(d, void newRenderCompleted(const WallpaperRenderRequest &request, - const QImage &image)) Q_PRIVATE_SLOT(d, void initScript()) friend class WallpaperPackage;