* record where the mouse was in drag
* get the parenting right, prevents crashes BUG:229566 svn path=/trunk/KDE/kdelibs/; revision=1099727
This commit is contained in:
parent
f261f87e6f
commit
f9027d26fa
@ -566,7 +566,7 @@ void ExtenderPrivate::addExtenderItem(ExtenderItem *item, const QPointF &pos)
|
|||||||
|
|
||||||
void ExtenderPrivate::removeExtenderItem(ExtenderItem *item)
|
void ExtenderPrivate::removeExtenderItem(ExtenderItem *item)
|
||||||
{
|
{
|
||||||
attachedExtenderItems.removeOne(item);
|
attachedExtenderItems.removeAll(item);
|
||||||
|
|
||||||
//collapse the popupapplet if the last item is removed.
|
//collapse the popupapplet if the last item is removed.
|
||||||
if (!q->attachedItems().count()) {
|
if (!q->attachedItems().count()) {
|
||||||
|
@ -263,10 +263,11 @@ void ExtenderItem::setExtender(Extender *extender, const QPointF &pos)
|
|||||||
//and notify the applet of the item being detached, after the config has been moved.
|
//and notify the applet of the item being detached, after the config has been moved.
|
||||||
emit d->extender->itemDetached(this);
|
emit d->extender->itemDetached(this);
|
||||||
|
|
||||||
|
setParentItem(extender);
|
||||||
|
setParent(extender);
|
||||||
d->extender = extender;
|
d->extender = extender;
|
||||||
|
|
||||||
//change parent.
|
//change parent.
|
||||||
setParentItem(extender);
|
|
||||||
extender->d->addExtenderItem(this, pos);
|
extender->d->addExtenderItem(this, pos);
|
||||||
|
|
||||||
//cancel the timer.
|
//cancel the timer.
|
||||||
@ -465,6 +466,7 @@ void ExtenderItem::returnToSource()
|
|||||||
if (!d || !d->sourceApplet) {
|
if (!d || !d->sourceApplet) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d->sourceApplet->d) {
|
if (d->sourceApplet->d) {
|
||||||
setExtender(d->sourceApplet->extender());
|
setExtender(d->sourceApplet->extender());
|
||||||
}
|
}
|
||||||
@ -601,6 +603,7 @@ void ExtenderItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
//create the necesarry mimedata.
|
//create the necesarry mimedata.
|
||||||
ExtenderItemMimeData *mimeData = new ExtenderItemMimeData();
|
ExtenderItemMimeData *mimeData = new ExtenderItemMimeData();
|
||||||
mimeData->setExtenderItem(this);
|
mimeData->setExtenderItem(this);
|
||||||
|
mimeData->setPointerOffset(d->mousePos);
|
||||||
|
|
||||||
//Hide empty internal extender containers when we drag the last item away. Avoids having
|
//Hide empty internal extender containers when we drag the last item away. Avoids having
|
||||||
//an ugly empty applet on the desktop temporarily.
|
//an ugly empty applet on the desktop temporarily.
|
||||||
@ -610,10 +613,6 @@ void ExtenderItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
extenderApplet->formFactor() != Plasma::Vertical) {
|
extenderApplet->formFactor() != Plasma::Vertical) {
|
||||||
kDebug() << "leaving the internal extender container, so hide the applet and it's handle.";
|
kDebug() << "leaving the internal extender container, so hide the applet and it's handle.";
|
||||||
extenderApplet->hide();
|
extenderApplet->hide();
|
||||||
AppletHandle *handle = dynamic_cast<AppletHandle*>(extenderApplet->parentItem());
|
|
||||||
if (handle) {
|
|
||||||
handle->hide();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtenderGroup *group = qobject_cast<ExtenderGroup*>(this);
|
ExtenderGroup *group = qobject_cast<ExtenderGroup*>(this);
|
||||||
@ -632,17 +631,21 @@ void ExtenderItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
Qt::DropAction action = drag->exec();
|
Qt::DropAction action = drag->exec();
|
||||||
|
|
||||||
corona->removeOffscreenWidget(this);
|
corona->removeOffscreenWidget(this);
|
||||||
|
d->dragStarted = false;
|
||||||
|
|
||||||
if (!action || !drag->target()) {
|
if (!action || !drag->target()) {
|
||||||
//we weren't moved, so reinsert the item in our current layout.
|
//we weren't moved, so reinsert the item in our current layout.
|
||||||
|
//TODO: make it into a stand-alone window?
|
||||||
|
d->themeChanged();
|
||||||
d->extender->itemAddedEvent(this, curPos);
|
d->extender->itemAddedEvent(this, curPos);
|
||||||
|
if (extenderApplet) {
|
||||||
|
extenderApplet->show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isGroup() && !collapsedGroup) {
|
if (isGroup() && !collapsedGroup) {
|
||||||
group->expandGroup();
|
group->expandGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
d->dragStarted = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExtenderItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
void ExtenderItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||||
@ -845,14 +848,12 @@ void ExtenderItemPrivate::themeChanged()
|
|||||||
{
|
{
|
||||||
if (dragStarted) {
|
if (dragStarted) {
|
||||||
background->setImagePath("opaque/widgets/extender-background");
|
background->setImagePath("opaque/widgets/extender-background");
|
||||||
} else {
|
|
||||||
background->setImagePath("widgets/extender-background");
|
|
||||||
}
|
|
||||||
if (dragStarted) {
|
|
||||||
background->setEnabledBorders(FrameSvg::AllBorders);
|
background->setEnabledBorders(FrameSvg::AllBorders);
|
||||||
} else {
|
} else {
|
||||||
|
background->setImagePath("widgets/extender-background");
|
||||||
background->setEnabledBorders(extender->enabledBordersForItem(q));
|
background->setEnabledBorders(extender->enabledBordersForItem(q));
|
||||||
}
|
}
|
||||||
|
|
||||||
background->getMargins(bgLeft, bgTop, bgRight, bgBottom);
|
background->getMargins(bgLeft, bgTop, bgRight, bgBottom);
|
||||||
|
|
||||||
dragger->setImagePath("widgets/extender-dragger");
|
dragger->setImagePath("widgets/extender-dragger");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user