only insert a delay before moving the drop zone the first time its shown; be sure to also reset the drop point

svn path=/trunk/KDE/kdelibs/; revision=1045332
This commit is contained in:
Aaron J. Seigo 2009-11-05 20:27:08 +00:00
parent 5789ff1883
commit 75e482fae2
2 changed files with 25 additions and 10 deletions

View File

@ -1179,27 +1179,39 @@ void Containment::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
} }
if (event->isAccepted()) { if (event->isAccepted()) {
if (!d->showDropZoneDelayTimer) { if (d->dropZoneStarted) {
d->showDropZoneDelayTimer = new QTimer(this); showDropZone(event->pos().toPoint());
d->showDropZoneDelayTimer->setInterval(300); } else {
d->showDropZoneDelayTimer->setSingleShot(true); if (!d->showDropZoneDelayTimer) {
connect(d->showDropZoneDelayTimer, SIGNAL(timeout()), this, SLOT(showDropZoneDelayed())); d->showDropZoneDelayTimer = new QTimer(this);
} d->showDropZoneDelayTimer->setInterval(300);
d->showDropZoneDelayTimer->setSingleShot(true);
connect(d->showDropZoneDelayTimer, SIGNAL(timeout()), this, SLOT(showDropZoneDelayed()));
}
d->dropPoints.insert(0, event->pos()); d->dropPoints.insert(0, event->pos());
d->showDropZoneDelayTimer->start(); d->showDropZoneDelayTimer->start();
}
} }
} }
void Containment::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) void Containment::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
{ {
//kDebug() << event->pos() << size().height() << size().width();
if (d->showDropZoneDelayTimer) { if (d->showDropZoneDelayTimer) {
d->showDropZoneDelayTimer->stop(); d->showDropZoneDelayTimer->stop();
} }
if (event->pos().y() < 1 || event->pos().y() > size().height() ||
event->pos().x() < 1 || event->pos().x() > size().width()) {
showDropZone(QPoint());
d->dropZoneStarted = false;
}
} }
void ContainmentPrivate::showDropZoneDelayed() void ContainmentPrivate::showDropZoneDelayed()
{ {
dropZoneStarted = true;
q->showDropZone(dropPoints.value(0).toPoint()); q->showDropZone(dropPoints.value(0).toPoint());
dropPoints.remove(0); dropPoints.remove(0);
} }
@ -1208,6 +1220,7 @@ void Containment::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
{ {
QGraphicsItem *item = scene()->itemAt(event->scenePos()); QGraphicsItem *item = scene()->itemAt(event->scenePos());
event->setAccepted(item == this || item == d->toolBox || !item); event->setAccepted(item == this || item == d->toolBox || !item);
//kDebug() << event->isAccepted() << d->showDropZoneDelayTimer->isActive();
if (!event->isAccepted()) { if (!event->isAccepted()) {
if (d->showDropZoneDelayTimer) { if (d->showDropZoneDelayTimer) {
d->showDropZoneDelayTimer->stop(); d->showDropZoneDelayTimer->stop();

View File

@ -52,7 +52,8 @@ public:
con(0), con(0),
type(Containment::NoContainmentType), type(Containment::NoContainmentType),
showDropZoneDelayTimer(0), showDropZoneDelayTimer(0),
drawWallpaper(true) drawWallpaper(true),
dropZoneStarted(false)
{ {
} }
@ -162,7 +163,8 @@ public:
QHash<KJob*, QPointF> dropPoints; QHash<KJob*, QPointF> dropPoints;
QHash<KJob*, KMenu*> dropMenus; QHash<KJob*, KMenu*> dropMenus;
QTimer *showDropZoneDelayTimer; QTimer *showDropZoneDelayTimer;
bool drawWallpaper; bool drawWallpaper : 1;
bool dropZoneStarted : 1;
}; };
} // Plasma namespace } // Plasma namespace