[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [plasma-framework] src/scriptengines/qml/plasmoid: adjust processMimeData to work with paste plugin
From: Marco Martin <notmart () gmail ! com>
Date: 2013-08-30 10:51:23
Message-ID: E1VFMIV-0004mP-Hu () scm ! kde ! org
[Download RAW message or body]
Git commit 087bc4d8fe4f3aeb41238aba9cedc9422401c140 by Marco Martin.
Committed on 30/08/2013 at 10:50.
Pushed by mart into branch 'master'.
adjust processMimeData to work with paste plugin
M +21 -10 src/scriptengines/qml/plasmoid/containmentinterface.cpp
http://commits.kde.org/plasma-framework/087bc4d8fe4f3aeb41238aba9cedc9422401c140
diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp \
b/src/scriptengines/qml/plasmoid/containmentinterface.cpp index 4ef1f91..fed562d \
100644
--- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp
+++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp
@@ -153,16 +153,14 @@ QVariantList ContainmentInterface::availableScreenRegion(int \
id) const return regVal;
}
-void ContainmentInterface::processMimeData(QMimeData *data, int x, int y)
+void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y)
{
- const QMimeData *mimeData = data;
-
if (!mimeData) {
- QClipboard *clipboard = QGuiApplication::clipboard();
- mimeData = clipboard->mimeData(QClipboard::Selection);
- //TODO if that's not supported (ie non-linux) should we try clipboard \
instead of selection? + return;
}
+ //const QMimeData *mimeData = data;
+
qDebug() << "Arrived mimeData" << mimeData->urls() << mimeData->formats() << \
"at" << x << ", " << y;
if (mimeData->hasFormat("text/x-plasmoidservicename")) {
@@ -275,12 +273,25 @@ void ContainmentInterface::mousePressEvent(QMouseEvent *event)
void ContainmentInterface::mouseReleaseEvent(QMouseEvent *event)
{
- if (!containment()->containmentActions().contains(Plasma::ContainmentActions::eventToString(event))) \
{ + const QString trigger = Plasma::ContainmentActions::eventToString(event);
+ Plasma::ContainmentActions *plugin = \
containment()->containmentActions().value(trigger); +
+ if (!plugin || plugin->contextualActions().isEmpty()) {
event->setAccepted(false);
return;
}
- QMenu desktopMenu;
+
+ //the plugin can be a single action or a context menu
+ //Don't have an action list? execute as single action
+ //and set the event position as action data
+ if (plugin->contextualActions().length() == 1) {
+ QAction *action = plugin->contextualActions().first();
+ action->setData(event->pos());
+ action->trigger();
+ event->accept();
+ return;
+ }
//FIXME: very inefficient appletAt() implementation
Plasma::Applet *applet = 0;
@@ -296,6 +307,8 @@ void ContainmentInterface::mouseReleaseEvent(QMouseEvent *event)
}
qDebug() << "Invoking menu for applet" << applet;
+ QMenu desktopMenu;
+
if (applet) {
addAppletActions(desktopMenu, applet, event);
} else {
@@ -398,8 +411,6 @@ void ContainmentInterface::addContainmentActions(QMenu \
&desktopMenu, QEvent *eve
Plasma::ContainmentActions *plugin = \
containment()->containmentActions().value(trigger);
if (!plugin) {
- //FIXME: this action is here only for testing purposes, remove it when \
plugins work
- desktopMenu.addAction(containment()->actions()->action("configure"));
return;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic