* the drop position is always relative to the containment; don't need to do store the scene pos. this fixes drops on panels
* allow drops on the toolbox, this gives is a place to drop things on the panel at all times, similar to the context menu on toolbox * small delay on showing the drop zone indicator so that when dragging into the tasks widget, for example, we don't end up flickering as it crosses the panel containment edge svn path=/trunk/KDE/kdelibs/; revision=1039186
This commit is contained in:
parent
242868a972
commit
c765e808a7
@ -1167,21 +1167,44 @@ void Containment::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
if (event->isAccepted() && view()) {
|
||||
showDropZone(view()->mapFromScene(event->scenePos()));
|
||||
if (event->isAccepted()) {
|
||||
if (!d->showDropZoneDelayTimer) {
|
||||
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->showDropZoneDelayTimer->start();
|
||||
}
|
||||
}
|
||||
|
||||
void Containment::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
|
||||
{
|
||||
if (d->showDropZoneDelayTimer) {
|
||||
d->showDropZoneDelayTimer->stop();
|
||||
}
|
||||
}
|
||||
|
||||
void ContainmentPrivate::showDropZoneDelayed()
|
||||
{
|
||||
q->showDropZone(dropPoints.value(0).toPoint());
|
||||
dropPoints.remove(0);
|
||||
}
|
||||
|
||||
void Containment::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
|
||||
{
|
||||
QGraphicsItem *item = scene()->itemAt(event->scenePos());
|
||||
event->setAccepted(item == this || !item);
|
||||
Plasma::Containment *c = containment();
|
||||
if (c && c->immutability() == Plasma::Mutable &&
|
||||
(event->mimeData()->hasFormat(static_cast<Plasma::Corona*>(scene())->appletMimeType()) ||
|
||||
KUrl::List::canDecode(event->mimeData())) && view()) {
|
||||
showDropZone(view()->mapFromScene(event->scenePos()));
|
||||
}
|
||||
event->setAccepted(item == this || item == d->toolBox || !item);
|
||||
if (!event->isAccepted()) {
|
||||
if (d->showDropZoneDelayTimer) {
|
||||
d->showDropZoneDelayTimer->stop();
|
||||
}
|
||||
} else if (!d->showDropZoneDelayTimer->isActive() && immutability() == Plasma::Mutable) {
|
||||
kDebug() << event->pos().toPoint();
|
||||
showDropZone(event->pos().toPoint());
|
||||
}
|
||||
}
|
||||
|
||||
void Containment::dropEvent(QGraphicsSceneDragDropEvent *event)
|
||||
@ -1250,7 +1273,7 @@ void ContainmentPrivate::dropData(QPointF scenePos, QPoint screenPos, QGraphicsS
|
||||
foreach (const KUrl &url, urls) {
|
||||
if (AccessManager::supportedProtocols().contains(url.protocol())) {
|
||||
AccessAppletJob *job = AccessManager::self()->accessRemoteApplet(url);
|
||||
dropPoints[job] = dropEvent->scenePos();
|
||||
dropPoints[job] = dropEvent->pos();
|
||||
QObject::connect(AccessManager::self(), SIGNAL(finished(Plasma::AccessAppletJob*)),
|
||||
q, SLOT(remoteAppletReady(Plasma::AccessAppletJob*)));
|
||||
} else {
|
||||
@ -1270,7 +1293,7 @@ void ContainmentPrivate::dropData(QPointF scenePos, QPoint screenPos, QGraphicsS
|
||||
// It may be a directory or a file, let's stat
|
||||
KIO::JobFlags flags = KIO::HideProgressInfo;
|
||||
KIO::TransferJob *job = KIO::get(url, KIO::NoReload, flags);
|
||||
dropPoints[job] = dropEvent->scenePos();
|
||||
dropPoints[job] = dropEvent->pos();
|
||||
QObject::connect(job, SIGNAL(result(KJob*)), q, SLOT(dropJobResult(KJob*)));
|
||||
QObject::connect(job, SIGNAL(mimetype(KIO::Job *, const QString&)),
|
||||
q, SLOT(mimeTypeRetrieved(KIO::Job *, const QString&)));
|
||||
|
@ -547,6 +547,12 @@ class PLASMA_EXPORT Containment : public Applet
|
||||
*/
|
||||
void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
|
||||
|
||||
/**
|
||||
* @reimp
|
||||
* @sa QGraphicsItem::dragLeaveEvent()
|
||||
*/
|
||||
void dragLeaveEvent(QGraphicsSceneDragDropEvent *event);
|
||||
|
||||
/**
|
||||
* @reimp
|
||||
* @sa QGraphicsItem::dragMoveEvent()
|
||||
@ -597,7 +603,7 @@ class PLASMA_EXPORT Containment : public Applet
|
||||
Q_PRIVATE_SLOT(d, void zoomOut())
|
||||
Q_PRIVATE_SLOT(d, void requestConfiguration())
|
||||
Q_PRIVATE_SLOT(d, void updateToolBoxVisibility())
|
||||
|
||||
Q_PRIVATE_SLOT(d, void showDropZoneDelayed())
|
||||
Q_PRIVATE_SLOT(d, void remoteAppletReady(Plasma::AccessAppletJob *))
|
||||
/**
|
||||
* This slot is called when the 'stat' after a job event has finished.
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
toolBox(0),
|
||||
con(0),
|
||||
type(Containment::NoContainmentType),
|
||||
showDropZoneDelayTimer(0),
|
||||
drawWallpaper(true)
|
||||
{
|
||||
}
|
||||
@ -138,6 +139,13 @@ public:
|
||||
*/
|
||||
bool showAppletContextMenu(Applet *applet, const QPoint &screenPos);
|
||||
|
||||
/**
|
||||
* Delayed drop zone display
|
||||
*/
|
||||
void showDropZoneDelayed();
|
||||
|
||||
static bool s_positioning;
|
||||
|
||||
Containment *q;
|
||||
FormFactor formFactor;
|
||||
Location location;
|
||||
@ -151,10 +159,10 @@ public:
|
||||
AbstractToolBox *toolBox;
|
||||
Context *con;
|
||||
Containment::Type type;
|
||||
static bool s_positioning;
|
||||
bool drawWallpaper;
|
||||
QHash<KJob*, QPointF> dropPoints;
|
||||
QHash<KJob*, KMenu*> dropMenus;
|
||||
QTimer *showDropZoneDelayTimer;
|
||||
bool drawWallpaper;
|
||||
};
|
||||
|
||||
} // Plasma namespace
|
||||
|
Loading…
x
Reference in New Issue
Block a user