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