From bea090680660bba1802213710d9323fc111c892c Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Sat, 24 May 2008 07:47:20 +0000 Subject: [PATCH] finish yet another 4.1 feature gap: allow the user to select what to do on drop. the text is a bit lame for icon, it should be "link to file" or something similar but that string doesn't seem to be handy and we're in a string freeze =/ at least it works =) svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=811949 --- applet.cpp | 2 +- containment.cpp | 21 +++++++++++++++++++-- servicetypes/plasma-applet.desktop | 3 +++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/applet.cpp b/applet.cpp index e636ddb21..b55548384 100644 --- a/applet.cpp +++ b/applet.cpp @@ -1139,7 +1139,7 @@ KPluginInfo::List Applet::listAppletInfo(const QString &category, KPluginInfo::List Applet::listAppletInfoForMimetype(const QString &mimetype) { - QString constraint = QString("'%1' in MimeTypes").arg(mimetype); + QString constraint = QString("'%1' in [X-Plasma-DropMimeTypes]").arg(mimetype); //kDebug() << "listAppletInfoForMimetype with" << mimetype << constraint; KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint); return KPluginInfo::fromServices(offers); diff --git a/containment.cpp b/containment.cpp index 80aec9adb..3ecce7a05 100644 --- a/containment.cpp +++ b/containment.cpp @@ -676,7 +676,7 @@ KPluginInfo::List Containment::listContainments(const QString &category, KPluginInfo::List Containment::listContainmentsForMimetype(const QString &mimetype) { - QString constraint = QString("'%1' in MimeTypes").arg(mimetype); + QString constraint = QString("'%1' in [X-Plasma-DropMimeTypes]").arg(mimetype); //kDebug() << mimetype << constraint; KService::List offers = KServiceTypeTrader::self()->query("Plasma/Containment", constraint); return KPluginInfo::fromServices(offers); @@ -713,7 +713,24 @@ void Containment::dropEvent(QGraphicsSceneDragDropEvent *event) } else { //TODO: should we show a dialog here to choose which plasmoid load if //!appletList.isEmpty() - addApplet(appletList.first().pluginName(), args, geom); + QMenu choices; + QHash actionsToPlugins; + foreach (const KPluginInfo &info, appletList) { + QAction *action; + if (!info.icon().isEmpty()) { + action = choices.addAction(KIcon(info.icon()), info.name()); + } else { + action = choices.addAction(info.name()); + } + + actionsToPlugins.insert(action, info.pluginName()); + } + + actionsToPlugins.insert(choices.addAction(i18n("Icon")), "icon"); + QAction *choice = choices.exec(event->screenPos()); + if (choice) { + addApplet(actionsToPlugins[choice], args, geom); + } } } event->acceptProposedAction(); diff --git a/servicetypes/plasma-applet.desktop b/servicetypes/plasma-applet.desktop index ea59221b5..3f9bf0ef1 100644 --- a/servicetypes/plasma-applet.desktop +++ b/servicetypes/plasma-applet.desktop @@ -59,3 +59,6 @@ Comment[zh_TW]=Plasma 小程式 [PropertyDef::X-Plasma-API] Type=QString +[PropertyDef::X-Plasma-DropMimeTypes] +Type=QStringList +