From 23b50f2deeee12c451ceed432bcba67f332f744b Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Fri, 27 Apr 2012 16:02:18 +0100 Subject: [PATCH 1/8] Allow QML items to be associated with operations in Plasma::Service QML items derive from QGraphicsObject, but not QGraphicsWidget. We actually only need QGraphicsObject (for the enabled property). This allows calling (dis)associateWidget from QML (eg: in javascript plasmoids) and passing in a QML item. --- private/service_p.h | 4 ++-- service.cpp | 21 +++++++++++++++++---- service.h | 22 ++++++++++++++++++---- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/private/service_p.h b/private/service_p.h index 8afef0b6f..c6fb77cd7 100644 --- a/private/service_p.h +++ b/private/service_p.h @@ -23,7 +23,7 @@ #include "servicejob.h" #include "service.h" -#include +#include #include #include #include @@ -114,7 +114,7 @@ public: DNSSD::PublicService *publicService; ServiceProvider *serviceProvider; QMultiHash associatedWidgets; - QMultiHash associatedGraphicsWidgets; + QMultiHash associatedGraphicsWidgets; QSet disabledOperations; }; diff --git a/service.cpp b/service.cpp index 84378dbf9..6268f7049 100644 --- a/service.cpp +++ b/service.cpp @@ -26,6 +26,7 @@ #include "config-plasma.h" #include +#include #include #include @@ -93,7 +94,7 @@ void ServicePrivate::associatedWidgetDestroyed(QObject *obj) void ServicePrivate::associatedGraphicsWidgetDestroyed(QObject *obj) { - associatedGraphicsWidgets.remove(static_cast(obj)); + associatedGraphicsWidgets.remove(static_cast(obj)); } void ServicePrivate::publish(AnnouncementMethods methods, const QString &name, const PackageMetadata &metadata) @@ -275,6 +276,18 @@ void Service::disassociateWidget(QWidget *widget) } void Service::associateWidget(QGraphicsWidget *widget, const QString &operation) +{ + QGraphicsObject *obj = widget; + associateWidget(obj, operation); +} + +void Service::disassociateWidget(QGraphicsWidget *widget) +{ + QGraphicsObject *obj = widget; + disassociateWidget(obj); +} + +void Service::associateWidget(QGraphicsObject *widget, const QString &operation) { if (!widget) { return; @@ -288,7 +301,7 @@ void Service::associateWidget(QGraphicsWidget *widget, const QString &operation) widget->setEnabled(!d->disabledOperations.contains(operation)); } -void Service::disassociateWidget(QGraphicsWidget *widget) +void Service::disassociateWidget(QGraphicsObject *widget) { if (!widget) { return; @@ -343,7 +356,7 @@ void Service::setOperationEnabled(const QString &operation, bool enable) } { - QHashIterator it(d->associatedGraphicsWidgets); + QHashIterator it(d->associatedGraphicsWidgets); while (it.hasNext()) { it.next(); if (it.value() == operation) { @@ -380,7 +393,7 @@ void Service::setOperationsScheme(QIODevice *xml) } { - QHashIterator it(d->associatedGraphicsWidgets); + QHashIterator it(d->associatedGraphicsWidgets); while (it.hasNext()) { it.next(); it.key()->setEnabled(d->config->hasGroup(it.value())); diff --git a/service.h b/service.h index 314909ba8..5c6fbe1a2 100644 --- a/service.h +++ b/service.h @@ -30,7 +30,7 @@ #include #include "packagemetadata.h" -class QGraphicsWidget; +class QGraphicsObject; class QIODevice; class QWidget; @@ -200,6 +200,20 @@ public: */ Q_INVOKABLE void disassociateWidget(QWidget *widget); + /** + * This method only exists to maintain binary compatibility. + * + * @see associateWidget(QGraphicsObject*,QString) + */ + Q_INVOKABLE void associateWidget(QGraphicsWidget *widget, const QString &operation); + + /** + * This method only exists to maintain binary compatibility. + * + * @see disassociateWidget(QGraphicsObject*) + */ + Q_INVOKABLE void disassociateWidget(QGraphicsWidget *widget); + /** * Assoicates a widget with an operation, which allows the service to * automatically manage, for example, the enabled state of a widget. @@ -210,7 +224,7 @@ public: * @param widget the QGraphicsItem to associate with the service * @param operation the operation to associate the widget with */ - Q_INVOKABLE void associateWidget(QGraphicsWidget *widget, const QString &operation); + Q_INVOKABLE void associateWidget(QGraphicsObject *widget, const QString &operation); /** * Disassociates a widget if it has been associated with an operation @@ -218,9 +232,9 @@ public: * * This will not change the enabled state of the widget. * - * @param widget the QGraphicsWidget to disassociate. + * @param widget the QGraphicsObject to disassociate. */ - Q_INVOKABLE void disassociateWidget(QGraphicsWidget *widget); + Q_INVOKABLE void disassociateWidget(QGraphicsObject *widget); /** * @return a parameter map for the given description From c4c2e8ee49ade21fb43f89793f59736e65eb0dcd Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Fri, 27 Apr 2012 21:33:18 +0100 Subject: [PATCH 2/8] Rename new Plasma::Service method to avoid clashes Having overloaded Q_INVOKABLE methods where one takes a superclass of another is a Bad Idea(TM), since the script engine cannot disambiguate the methods. associateItem is more accurate than associateWidget for these methods, anyway. REVIEW: 104760 --- service.cpp | 12 +++++------- service.h | 24 ++++++++++++------------ 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/service.cpp b/service.cpp index 6268f7049..a860813c2 100644 --- a/service.cpp +++ b/service.cpp @@ -277,23 +277,21 @@ void Service::disassociateWidget(QWidget *widget) void Service::associateWidget(QGraphicsWidget *widget, const QString &operation) { - QGraphicsObject *obj = widget; - associateWidget(obj, operation); + associateItem(widget, operation); } void Service::disassociateWidget(QGraphicsWidget *widget) { - QGraphicsObject *obj = widget; - disassociateWidget(obj); + disassociateItem(widget); } -void Service::associateWidget(QGraphicsObject *widget, const QString &operation) +void Service::associateItem(QGraphicsObject *widget, const QString &operation) { if (!widget) { return; } - disassociateWidget(widget); + disassociateItem(widget); d->associatedGraphicsWidgets.insert(widget, operation); connect(widget, SIGNAL(destroyed(QObject*)), this, SLOT(associatedGraphicsWidgetDestroyed(QObject*))); @@ -301,7 +299,7 @@ void Service::associateWidget(QGraphicsObject *widget, const QString &operation) widget->setEnabled(!d->disabledOperations.contains(operation)); } -void Service::disassociateWidget(QGraphicsObject *widget) +void Service::disassociateItem(QGraphicsObject *widget) { if (!widget) { return; diff --git a/service.h b/service.h index 5c6fbe1a2..db8956035 100644 --- a/service.h +++ b/service.h @@ -203,38 +203,38 @@ public: /** * This method only exists to maintain binary compatibility. * - * @see associateWidget(QGraphicsObject*,QString) + * @see associateItem */ Q_INVOKABLE void associateWidget(QGraphicsWidget *widget, const QString &operation); /** * This method only exists to maintain binary compatibility. * - * @see disassociateWidget(QGraphicsObject*) + * @see disassociateItem */ Q_INVOKABLE void disassociateWidget(QGraphicsWidget *widget); /** - * Assoicates a widget with an operation, which allows the service to - * automatically manage, for example, the enabled state of a widget. + * Associates a graphics item with an operation, which allows the service to + * automatically manage, for example, the enabled state of the item. * - * This will remove any previous associations the widget had with + * This will remove any previous associations the item had with * operations on this engine. * - * @param widget the QGraphicsItem to associate with the service - * @param operation the operation to associate the widget with + * @param item the QGraphicsObject to associate with the service + * @param operation the operation to associate the item with */ - Q_INVOKABLE void associateWidget(QGraphicsObject *widget, const QString &operation); + Q_INVOKABLE void associateItem(QGraphicsObject *item, const QString &operation); /** - * Disassociates a widget if it has been associated with an operation + * Disassociates a graphics item if it has been associated with an operation * on this service. * - * This will not change the enabled state of the widget. + * This will not change the enabled state of the item. * - * @param widget the QGraphicsObject to disassociate. + * @param widget the QGraphicsItem to disassociate. */ - Q_INVOKABLE void disassociateWidget(QGraphicsObject *widget); + Q_INVOKABLE void disassociateItem(QGraphicsObject *widget); /** * @return a parameter map for the given description From d68f439477dbc4cbdd42934fa8d4075fe5a64891 Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Fri, 11 May 2012 15:12:49 +0200 Subject: [PATCH 3/8] SVN_SILENT made messages (.desktop file) --- data/servicetypes/plasma-runner.desktop | 2 +- .../plasma-containmentactions-test.desktop | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/servicetypes/plasma-runner.desktop b/data/servicetypes/plasma-runner.desktop index d4dd2474a..1e3f1be40 100644 --- a/data/servicetypes/plasma-runner.desktop +++ b/data/servicetypes/plasma-runner.desktop @@ -56,7 +56,7 @@ Comment[nn]=KRunner-tillegg Comment[pa]=ਕੇਰਨਰ ਪਲੱਗਇਨ Comment[pl]=Wtyczka KRunnera Comment[pt]='Plugin' do KRunner -Comment[pt_BR]=Plug-in do KRunner +Comment[pt_BR]=Plugin do KRunner Comment[ro]=Modul KRunner Comment[ru]=Расширение KRunner Comment[se]=KRunner-lassemodula diff --git a/tests/testcontainmentactionsplugin/plasma-containmentactions-test.desktop b/tests/testcontainmentactionsplugin/plasma-containmentactions-test.desktop index 36a85ec8f..f935444b8 100644 --- a/tests/testcontainmentactionsplugin/plasma-containmentactions-test.desktop +++ b/tests/testcontainmentactionsplugin/plasma-containmentactions-test.desktop @@ -100,7 +100,7 @@ Comment[nl]=Een dummy plugin voor testen Comment[pa]=ਟੈਸਟ ਕਰਨ ਲਈ ਫਰਜ਼ੀ ਪਲੱਗਇਨ Comment[pl]=Prosta wtyczka testowa Comment[pt]=Um 'plugin' de exemplo para testes -Comment[pt_BR]=Um plug-in fictício para testes +Comment[pt_BR]=Um plugin fictício para testes Comment[ro]=Modul fictiv pentru testare Comment[ru]=Расширение для тестирования Comment[se]=Geahččalanlassemodula From f75b1e7d10e37bb7d702f30203bf6c3d5d0960d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20G=C3=A2teau?= Date: Fri, 11 May 2012 15:46:29 +0200 Subject: [PATCH 4/8] Add operator != to Plasma::QueryMatch --- querymatch.cpp | 5 +++++ querymatch.h | 1 + 2 files changed, 6 insertions(+) diff --git a/querymatch.cpp b/querymatch.cpp index 2723c0574..0ba9b5676 100644 --- a/querymatch.cpp +++ b/querymatch.cpp @@ -265,6 +265,11 @@ bool QueryMatch::operator==(const QueryMatch &other) const return (d == other.d); } +bool QueryMatch::operator!=(const QueryMatch &other) const +{ + return (d != other.d); +} + void QueryMatch::run(const RunnerContext &context) const { //kDebug() << "we run the term" << context->query() << "whose type is" << context->mimetype(); diff --git a/querymatch.h b/querymatch.h index 7e3133c30..366767345 100644 --- a/querymatch.h +++ b/querymatch.h @@ -84,6 +84,7 @@ class PLASMA_EXPORT QueryMatch ~QueryMatch(); QueryMatch &operator=(const QueryMatch &other); bool operator==(const QueryMatch &other) const; + bool operator!=(const QueryMatch &other) const; bool operator<(const QueryMatch &other) const; From 162456d04ad464302cb5c15cd0cab426b359e018 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20G=C3=A2teau?= Date: Thu, 17 May 2012 15:00:13 +0200 Subject: [PATCH 5/8] Only dequeue our ThreadWeaver jobs REVIEW-IN: 104973 --- runnermanager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runnermanager.cpp b/runnermanager.cpp index 49569a303..dc32d2ae2 100644 --- a/runnermanager.cpp +++ b/runnermanager.cpp @@ -811,7 +811,9 @@ void RunnerManager::reset() qDeleteAll(d->oldSearchJobs); d->oldSearchJobs.clear(); } else { - Weaver::instance()->dequeue(); + Q_FOREACH(FindMatchesJob *job, d->searchJobs) { + Weaver::instance()->dequeue(job); + } d->oldSearchJobs += d->searchJobs; } From 1808be9d38dc6266f90e93115c77cace89f443c7 Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Mon, 28 May 2012 19:42:25 +0200 Subject: [PATCH 6/8] clear the single runner pointer when loading runners; it may have been deleted on us --- runnermanager.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/runnermanager.cpp b/runnermanager.cpp index dc32d2ae2..845fe224c 100644 --- a/runnermanager.cpp +++ b/runnermanager.cpp @@ -252,6 +252,11 @@ public: } } + if (!singleRunnerWasLoaded) { + // in case we deleted it up above + clearSingleRunner(); + } + kDebug() << "All runners loaded, total:" << runners.count(); } From 46a60a4fe8bb52a463f10c6fa9847d434523bc2b Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Thu, 31 May 2012 14:58:18 +0200 Subject: [PATCH 7/8] Package operates locally only as it is, so no point in using KIO here. this also happens to allow plasmapkg to work outside a kde session. --- package.cpp | 57 +++++++++++------------------------------------------ 1 file changed, 11 insertions(+), 46 deletions(-) diff --git a/package.cpp b/package.cpp index 9d05a8dd9..1a4953153 100644 --- a/package.cpp +++ b/package.cpp @@ -33,12 +33,6 @@ #include #include #include -#ifndef PLASMA_NO_KIO -#include -#include -#include -#include -#endif #include #include #include @@ -58,8 +52,6 @@ namespace Plasma { -#ifdef PLASMA_NO_KIO // Provide some convenience for dealing with folders - bool copyFolder(QString sourcePath, QString targetPath) { QDir source(sourcePath); @@ -118,9 +110,6 @@ bool removeFolder(QString folderPath) return folder.rmdir(folderName); } -#endif // PLASMA_NO_KIO - - Package::Package() : d(new PackagePrivate(PackageStructure::Ptr(0), QString())) { @@ -569,32 +558,20 @@ bool Package::installPackage(const QString &package, if (archivedPackage) { // it's in a temp dir, so just move it over. -#ifndef PLASMA_NO_KIO - KIO::CopyJob *job = KIO::move(KUrl(path), KUrl(targetName), KIO::HideProgressInfo); - const bool ok = job->exec(); - const QString errorString = job->errorString(); -#else const bool ok = copyFolder(path, targetName); removeFolder(path); - const QString errorString("unknown"); -#endif if (!ok) { - kWarning() << "Could not move package to destination:" << targetName << " : " << errorString; + kWarning() << "Could not move package to destination:" << targetName; return false; } } else { + kDebug() << "************************** 12"; // it's a directory containing the stuff, so copy the contents rather // than move them -#ifndef PLASMA_NO_KIO - KIO::CopyJob *job = KIO::copy(KUrl(path), KUrl(targetName), KIO::HideProgressInfo); - const bool ok = job->exec(); - const QString errorString = job->errorString(); -#else const bool ok = copyFolder(path, targetName); - const QString errorString("unknown"); -#endif + kDebug() << "************************** 13"; if (!ok) { - kWarning() << "Could not copy package to destination:" << targetName << " : " << errorString; + kWarning() << "Could not copy package to destination:" << targetName; return false; } } @@ -606,9 +583,12 @@ bool Package::installPackage(const QString &package, if (!servicePrefix.isEmpty()) { // and now we register it as a service =) + kDebug() << "************************** 1"; QString metaPath = targetName + "/metadata.desktop"; + kDebug() << "************************** 2"; KDesktopFile df(metaPath); KConfigGroup cg = df.desktopGroup(); + kDebug() << "************************** 3"; // Q: should not installing it as a service disqualify it? // Q: i don't think so since KServiceTypeTrader may not be @@ -620,14 +600,9 @@ bool Package::installPackage(const QString &package, QString serviceName = servicePrefix + meta.pluginName(); QString service = KStandardDirs::locateLocal("services", serviceName + ".desktop"); -#ifndef PLASMA_NO_KIO - KIO::FileCopyJob *job = KIO::file_copy(metaPath, service, -1, KIO::HideProgressInfo); - const bool ok = job->exec(); - const QString errorString = job->errorString(); -#else + kDebug() << "************************** 4"; const bool ok = QFile::copy(metaPath, service); - const QString errorString("unknown"); -#endif + kDebug() << "************************** 5"; if (ok) { // the icon in the installed file needs to point to the icon in the // installation dir! @@ -639,8 +614,9 @@ bool Package::installPackage(const QString &package, cg.writeEntry("Icon", iconPath); } } else { - kWarning() << "Could not register package as service (this is not necessarily fatal):" << serviceName << " : " << errorString; + kWarning() << "Could not register package as service (this is not necessarily fatal):" << serviceName; } + kDebug() << "************************** 7"; } return true; @@ -669,14 +645,8 @@ bool Package::uninstallPackage(const QString &pluginName, kWarning() << "Unable to remove " << service; } -#ifndef PLASMA_NO_KIO - KIO::DeleteJob *job = KIO::del(KUrl(targetName)); - ok = job->exec(); - const QString errorString = job->errorString(); -#else ok = removeFolder(targetName); const QString errorString("unknown"); -#endif if (!ok) { kWarning() << "Could not delete package from:" << targetName << " : " << errorString; return false; @@ -711,12 +681,7 @@ bool Package::registerPackage(const PackageMetadata &data, const QString &iconPa iconPath.right(iconPath.length() - iconPath.lastIndexOf("/"))); cg.writeEntry("Icon", installedIcon); installedIcon = KStandardDirs::locateLocal("icon", installedIcon); -#ifndef PLASMA_NO_KIO - KIO::FileCopyJob *job = KIO::file_copy(iconPath, installedIcon, -1, KIO::HideProgressInfo); - job->exec(); -#else QFile::copy(iconPath, installedIcon); -#endif } return true; From 222674d3ab1484b9a80dd2971123d9cd38205773 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 7 Jun 2012 12:50:05 +0200 Subject: [PATCH 8/8] save KCM settings on ok ar apply clicked BUG:300840 --- applet.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/applet.cpp b/applet.cpp index 0e1a3c85b..ccab40ebd 100644 --- a/applet.cpp +++ b/applet.cpp @@ -1923,6 +1923,10 @@ void Applet::showConfigurationInterface() KCModuleProxy *module = new KCModuleProxy(kcm); if (module->realModule()) { connect(module, SIGNAL(changed(bool)), dialog, SLOT(settingsModified(bool))); + connect(dialog, SIGNAL(okClicked()), + module->realModule(), SLOT(save())); + connect(dialog, SIGNAL(applyClicked()), + module->realModule(), SLOT(save())); dialog->addPage(module, module->moduleInfo().moduleName(), module->moduleInfo().icon()); hasPages = true; } else { @@ -1935,6 +1939,10 @@ void Applet::showConfigurationInterface() KCModule *module = service->createInstance(dialog, QVariantList(), &error); if (module) { connect(module, SIGNAL(changed(bool)), dialog, SLOT(settingsModified(bool))); + connect(dialog, SIGNAL(okClicked()), + module, SLOT(save())); + connect(dialog, SIGNAL(applyClicked()), + module, SLOT(save())); dialog->addPage(module, service->name(), service->icon()); hasPages = true; } else {