adjust processMimeData to work with paste plugin

This commit is contained in:
Marco Martin 2013-08-30 12:50:35 +02:00
parent 5fd1d5d0de
commit 087bc4d8fe

View File

@ -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;
}