Move the showing of the dropzone from panelview to containment. Leads to less code duplication and makes showing dropzones when dragging extenderitems to the panel work. Also don't hide the extenderapplet and panel when detaching the last item from an extenderapplet, and move extenderitems off screen before creating the pixmap to avoid other items appearing in the pixmap.
svn path=/trunk/KDE/kdelibs/; revision=938242
This commit is contained in:
parent
9af884bad7
commit
e1730c4704
@ -917,12 +917,22 @@ void Containment::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event->isAccepted() && view()) {
|
||||
showDropZone(view()->mapFromScene(event->scenePos()));
|
||||
}
|
||||
}
|
||||
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
void Containment::dropEvent(QGraphicsSceneDragDropEvent *event)
|
||||
|
@ -276,10 +276,12 @@ void Extender::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
|
||||
//Hide empty internal extender containers when we drag the last item away. Avoids having
|
||||
//an ugly empty applet on the desktop temporarily.
|
||||
ExtenderApplet *extenderApplet = qobject_cast<ExtenderApplet*>(d->applet);
|
||||
if (extenderApplet && sourceExtender == this && (attachedItems().count() < 2)) {
|
||||
if (extenderApplet && sourceExtender == this && attachedItems().count() < 2 &&
|
||||
extenderApplet->formFactor() != Plasma::Horizontal &&
|
||||
extenderApplet->formFactor() != Plasma::Vertical) {
|
||||
kDebug() << "leaving the internal extender container, so hide the applet and it's handle.";
|
||||
extenderApplet->hide();
|
||||
AppletHandle *handle = qgraphicsitem_cast<AppletHandle*>(extenderApplet->parentItem());
|
||||
AppletHandle *handle = dynamic_cast<AppletHandle*>(extenderApplet->parentItem());
|
||||
if (handle) {
|
||||
handle->hide();
|
||||
}
|
||||
|
@ -466,8 +466,15 @@ void ExtenderItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
|
||||
//Start the drag:
|
||||
d->dragStarted = true;
|
||||
QPointF curPos = pos();
|
||||
|
||||
//first update the borders.
|
||||
//remove item from the layout, and add it somewhere off screen so we can render it to a pixmap,
|
||||
//without other widgets interefing.
|
||||
d->extender->itemRemovedEvent(this);
|
||||
Corona *corona = qobject_cast<Corona*>(scene());
|
||||
corona->addOffscreenWidget(this);
|
||||
|
||||
//update the borders, since while dragging, we want all of theme.
|
||||
d->themeChanged();
|
||||
|
||||
//create a view to render the ExtenderItem and it's contents to a pixmap and set up a painter on
|
||||
@ -489,8 +496,6 @@ void ExtenderItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
view.setSceneRect(sceneBoundingRect());
|
||||
view.render(&p, QRectF(QPointF(0, 0), pixmap.size()), QRect(QPoint(0, 0), screenSize));
|
||||
|
||||
hide();
|
||||
|
||||
//create the necesarry mimedata.
|
||||
ExtenderItemMimeData *mimeData = new ExtenderItemMimeData();
|
||||
mimeData->setExtenderItem(this);
|
||||
@ -498,10 +503,12 @@ void ExtenderItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
//Hide empty internal extender containers when we drag the last item away. Avoids having
|
||||
//an ugly empty applet on the desktop temporarily.
|
||||
ExtenderApplet *extenderApplet = qobject_cast<ExtenderApplet*>(d->extender->d->applet);
|
||||
if (extenderApplet && d->extender->attachedItems().count() < 2) {
|
||||
if (extenderApplet && d->extender->attachedItems().count() < 2 &&
|
||||
extenderApplet->formFactor() != Plasma::Horizontal &&
|
||||
extenderApplet->formFactor() != Plasma::Vertical) {
|
||||
kDebug() << "leaving the internal extender container, so hide the applet and it's handle.";
|
||||
extenderApplet->hide();
|
||||
AppletHandle *handle = qgraphicsitem_cast<AppletHandle*>(extenderApplet->parentItem());
|
||||
AppletHandle *handle = dynamic_cast<AppletHandle*>(extenderApplet->parentItem());
|
||||
if (handle) {
|
||||
handle->hide();
|
||||
}
|
||||
@ -513,10 +520,13 @@ void ExtenderItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
drag->setPixmap(pixmap);
|
||||
drag->setMimeData(mimeData);
|
||||
drag->setHotSpot(d->mousePos);
|
||||
drag->exec();
|
||||
Qt::DropAction action = drag->exec();
|
||||
|
||||
show();
|
||||
d->widget->show();
|
||||
corona->removeOffscreenWidget(this);
|
||||
|
||||
if (!action) { //we weren't moved, so reinsert the item in our current layout.
|
||||
d->extender->itemAddedEvent(this, curPos);
|
||||
}
|
||||
|
||||
d->dragStarted = false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user