Take translations into account when moving an applet.

Patch derived from work done by Thomas Coopman.
BUG: 153927

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=748642
This commit is contained in:
Jason Stubbs 2007-12-15 05:48:13 +00:00
parent c7bdfb5a1c
commit 82eae90414

View File

@ -257,9 +257,14 @@ void AppletHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
if (!m_applet) { if (!m_applet) {
QGraphicsItem::mouseMoveEvent(event); QGraphicsItem::mouseMoveEvent(event);
return;
} }
else if (m_pressedButton == MoveButton) {
QPointF delta = event->pos()-event->lastPos(); QPointF curPos = transform().map(event->pos());
QPointF lastPos = transform().map(event->lastPos());
QPointF delta = curPos-lastPos;
if (m_pressedButton == MoveButton) {
setPos(pos()+delta); setPos(pos()+delta);
// test for containment change // test for containment change
if (!m_containment->sceneBoundingRect().contains(event->scenePos())) { if (!m_containment->sceneBoundingRect().contains(event->scenePos())) {
@ -272,7 +277,7 @@ void AppletHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
// add the applet to the new containment // add the applet to the new containment
// and take it from the old one // and take it from the old one
QPointF scenePosition = scenePos(); QPointF scenePosition = scenePos();
kDebug() << "moving to other containment with position" << event->pos() << event->scenePos(); kDebug() << "moving to other containment with position" << pos() << event->scenePos();
kDebug() << "position before reparenting" << pos() << scenePos(); kDebug() << "position before reparenting" << pos() << scenePos();
m_containment = containments[i]; m_containment = containments[i];
//m_containment->addChild(m_applet); //m_containment->addChild(m_applet);
@ -288,7 +293,7 @@ void AppletHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
} }
} }
} else if (m_pressedButton == RotateButton) { } else if (m_pressedButton == RotateButton) {
if (_k_distanceForPoint(event->pos()-event->lastPos()) <= 1.0) { if (_k_distanceForPoint(delta) <= 1.0) {
return; return;
} }