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
This commit is contained in:
parent
e32ed254f1
commit
bea0906806
@ -1139,7 +1139,7 @@ KPluginInfo::List Applet::listAppletInfo(const QString &category,
|
|||||||
|
|
||||||
KPluginInfo::List Applet::listAppletInfoForMimetype(const QString &mimetype)
|
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;
|
//kDebug() << "listAppletInfoForMimetype with" << mimetype << constraint;
|
||||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint);
|
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint);
|
||||||
return KPluginInfo::fromServices(offers);
|
return KPluginInfo::fromServices(offers);
|
||||||
|
@ -676,7 +676,7 @@ KPluginInfo::List Containment::listContainments(const QString &category,
|
|||||||
|
|
||||||
KPluginInfo::List Containment::listContainmentsForMimetype(const QString &mimetype)
|
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;
|
//kDebug() << mimetype << constraint;
|
||||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Containment", constraint);
|
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Containment", constraint);
|
||||||
return KPluginInfo::fromServices(offers);
|
return KPluginInfo::fromServices(offers);
|
||||||
@ -713,7 +713,24 @@ void Containment::dropEvent(QGraphicsSceneDragDropEvent *event)
|
|||||||
} else {
|
} else {
|
||||||
//TODO: should we show a dialog here to choose which plasmoid load if
|
//TODO: should we show a dialog here to choose which plasmoid load if
|
||||||
//!appletList.isEmpty()
|
//!appletList.isEmpty()
|
||||||
addApplet(appletList.first().pluginName(), args, geom);
|
QMenu choices;
|
||||||
|
QHash<QAction*, QString> 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();
|
event->acceptProposedAction();
|
||||||
|
@ -59,3 +59,6 @@ Comment[zh_TW]=Plasma 小程式
|
|||||||
[PropertyDef::X-Plasma-API]
|
[PropertyDef::X-Plasma-API]
|
||||||
Type=QString
|
Type=QString
|
||||||
|
|
||||||
|
[PropertyDef::X-Plasma-DropMimeTypes]
|
||||||
|
Type=QStringList
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user