paste is triggered by a plugin now.
also, clean up the drop/paste handling a bit svn path=/trunk/KDE/kdelibs/; revision=1012643
This commit is contained in:
parent
464df207d1
commit
69365ddada
@ -241,8 +241,7 @@ void Containment::init()
|
|||||||
switch (d->type) {
|
switch (d->type) {
|
||||||
case DesktopContainment:
|
case DesktopContainment:
|
||||||
defaults.insert("wheel:Vertical;NoModifier", "switchdesktop");
|
defaults.insert("wheel:Vertical;NoModifier", "switchdesktop");
|
||||||
defaults.insert("wheel:Horizontal;ControlModifier", "test");
|
defaults.insert("MiddleButton;NoModifier", "paste");
|
||||||
defaults.insert("LeftButton;NoModifier", "switchdesktop");
|
|
||||||
defaults.insert("RightButton;NoModifier", "contextmenu");
|
defaults.insert("RightButton;NoModifier", "contextmenu");
|
||||||
break;
|
break;
|
||||||
case PanelContainment:
|
case PanelContainment:
|
||||||
@ -542,9 +541,6 @@ void Containment::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
|
|
||||||
if (event->isAccepted()) {
|
if (event->isAccepted()) {
|
||||||
setFocus(Qt::MouseFocusReason);
|
setFocus(Qt::MouseFocusReason);
|
||||||
} else if (event->button() == Qt::MidButton) {
|
|
||||||
//middle-click = paste
|
|
||||||
event->accept();
|
|
||||||
} else {
|
} else {
|
||||||
event->accept();
|
event->accept();
|
||||||
Applet::mousePressEvent(event);
|
Applet::mousePressEvent(event);
|
||||||
@ -574,10 +570,6 @@ void Containment::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
|
|
||||||
if (event->isAccepted() || !isContainment()) {
|
if (event->isAccepted() || !isContainment()) {
|
||||||
//do nothing
|
//do nothing
|
||||||
} else if (event->button() == Qt::MidButton) {
|
|
||||||
//middle-click = paste
|
|
||||||
d->dropData(event);
|
|
||||||
event->accept();
|
|
||||||
} else {
|
} else {
|
||||||
event->accept();
|
event->accept();
|
||||||
Applet::mouseReleaseEvent(event);
|
Applet::mouseReleaseEvent(event);
|
||||||
@ -1127,41 +1119,27 @@ void Containment::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
|
|||||||
void Containment::dropEvent(QGraphicsSceneDragDropEvent *event)
|
void Containment::dropEvent(QGraphicsSceneDragDropEvent *event)
|
||||||
{
|
{
|
||||||
if (isContainment()) {
|
if (isContainment()) {
|
||||||
d->dropData(event);
|
d->dropData(event->scenePos(), event->screenPos(), event);
|
||||||
} else {
|
} else {
|
||||||
Applet::dropEvent(event);
|
Applet::dropEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContainmentPrivate::dropData(QGraphicsSceneEvent *event)
|
void ContainmentPrivate::dropData(QPointF scenePos, QPoint screenPos, QGraphicsSceneDragDropEvent *dropEvent)
|
||||||
{
|
{
|
||||||
if (q->immutability() != Mutable) {
|
if (q->immutability() != Mutable) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QGraphicsSceneDragDropEvent *dropEvent = dynamic_cast<QGraphicsSceneDragDropEvent*>(event);
|
QPointF pos = q->mapFromScene(scenePos);
|
||||||
QGraphicsSceneMouseEvent *mouseEvent = dynamic_cast<QGraphicsSceneMouseEvent*>(event);
|
|
||||||
//kDebug() << "Something dropped mimetype, -data: " << appletMimetype << event->mimeData()->text();
|
|
||||||
|
|
||||||
QPointF pos;
|
|
||||||
QPointF scenePos;
|
|
||||||
QPoint screenPos;
|
|
||||||
const QMimeData *mimeData = 0;
|
const QMimeData *mimeData = 0;
|
||||||
|
|
||||||
if (dropEvent) {
|
if (dropEvent) {
|
||||||
pos = dropEvent->pos();
|
|
||||||
scenePos = dropEvent->scenePos();
|
|
||||||
screenPos = dropEvent->screenPos();
|
|
||||||
mimeData = dropEvent->mimeData();
|
mimeData = dropEvent->mimeData();
|
||||||
} else if (mouseEvent) {
|
} else {
|
||||||
pos = mouseEvent->pos();
|
|
||||||
scenePos = mouseEvent->scenePos();
|
|
||||||
screenPos = mouseEvent->screenPos();
|
|
||||||
QClipboard *clipboard = QApplication::clipboard();
|
QClipboard *clipboard = QApplication::clipboard();
|
||||||
mimeData = clipboard->mimeData(QClipboard::Selection);
|
mimeData = clipboard->mimeData(QClipboard::Selection);
|
||||||
//TODO if that's not supported (ie non-linux) should we try clipboard instead of selection?
|
//TODO if that's not supported (ie non-linux) should we try clipboard instead of selection?
|
||||||
} else {
|
|
||||||
kDebug() << "unexpected event";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mimeData) {
|
if (!mimeData) {
|
||||||
@ -1179,7 +1157,7 @@ void ContainmentPrivate::dropData(QGraphicsSceneEvent *event)
|
|||||||
const QStringList appletNames = data.split('\n', QString::SkipEmptyParts);
|
const QStringList appletNames = data.split('\n', QString::SkipEmptyParts);
|
||||||
foreach (const QString &appletName, appletNames) {
|
foreach (const QString &appletName, appletNames) {
|
||||||
//kDebug() << "doing" << appletName;
|
//kDebug() << "doing" << appletName;
|
||||||
QRectF geom(q->mapFromScene(scenePos), QSize(0, 0));
|
QRectF geom(pos, QSize(0, 0));
|
||||||
q->addApplet(appletName, QVariantList(), geom);
|
q->addApplet(appletName, QVariantList(), geom);
|
||||||
}
|
}
|
||||||
if (dropEvent) {
|
if (dropEvent) {
|
||||||
|
@ -588,6 +588,7 @@ class PLASMA_EXPORT Containment : public Applet
|
|||||||
friend class AppletPrivate;
|
friend class AppletPrivate;
|
||||||
friend class CoronaPrivate;
|
friend class CoronaPrivate;
|
||||||
friend class ContainmentPrivate;
|
friend class ContainmentPrivate;
|
||||||
|
friend class ContextAction;
|
||||||
ContainmentPrivate *const d;
|
ContainmentPrivate *const d;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,6 +21,10 @@
|
|||||||
#include "contextaction.h"
|
#include "contextaction.h"
|
||||||
#include "containment.h"
|
#include "containment.h"
|
||||||
|
|
||||||
|
#include "private/packages_p.h"
|
||||||
|
#include "private/contextaction_p.h"
|
||||||
|
#include "private/containment_p.h"
|
||||||
|
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
@ -34,9 +38,6 @@
|
|||||||
|
|
||||||
#include <version.h>
|
#include <version.h>
|
||||||
|
|
||||||
#include "plasma/private/packages_p.h"
|
|
||||||
#include "plasma/private/contextaction_p.h"
|
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -271,6 +272,14 @@ QString ContextAction::eventToString(QEvent *event)
|
|||||||
return trigger;
|
return trigger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContextAction::paste(QPointF scenePos, QPoint screenPos)
|
||||||
|
{
|
||||||
|
Containment *c = containment();
|
||||||
|
if (c) {
|
||||||
|
c->d->dropData(scenePos, screenPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
||||||
|
|
||||||
#include "contextaction.moc"
|
#include "contextaction.moc"
|
||||||
|
@ -218,6 +218,12 @@ class PLASMA_EXPORT ContextAction : public QObject
|
|||||||
*/
|
*/
|
||||||
Containment *containment();
|
Containment *containment();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pastes the clipboard at a given location
|
||||||
|
* this is here specially for the paste plugin.
|
||||||
|
*/
|
||||||
|
void paste(QPointF scenePos, QPoint screenPos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class ContextActionPackage;
|
friend class ContextActionPackage;
|
||||||
friend class ContextActionPrivate;
|
friend class ContextActionPrivate;
|
||||||
|
@ -109,9 +109,11 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles dropped/pasted mimetype data
|
* Handles dropped/pasted mimetype data
|
||||||
* @param event the drop or mouse event
|
* @param scenePos scene-relative position
|
||||||
|
* @param screenPos screen-relative position
|
||||||
|
* @param dropEvent the drop event (if null, the clipboard is used instead)
|
||||||
*/
|
*/
|
||||||
void dropData(QGraphicsSceneEvent *event);
|
void dropData(QPointF scenePos, QPoint screenPos, QGraphicsSceneDragDropEvent *dropEvent = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* inits the contextaction if necessary
|
* inits the contextaction if necessary
|
||||||
|
Loading…
Reference in New Issue
Block a user