diff --git a/extenders/extenderitem.cpp b/extenders/extenderitem.cpp index e9b8a8f18..0f6944f7a 100644 --- a/extenders/extenderitem.cpp +++ b/extenders/extenderitem.cpp @@ -445,10 +445,6 @@ void ExtenderItem::destroy() d->extender->d->removeExtenderItem(this); emit d->extender->itemDetached(this); - if (sender() == d->destroyAction) { - emit destroyActionTriggered(); - } - deleteLater(); } @@ -694,7 +690,7 @@ ExtenderItemPrivate::ExtenderItemPrivate(ExtenderItem *extenderItem, Extender *h dragger(new FrameSvg(extenderItem)), background(new FrameSvg(extenderItem)), collapseIcon(0), - destroyAction(0), + destroyButton(0), title(QString()), mouseOver(false), dragStarted(false), @@ -754,7 +750,9 @@ void ExtenderItemPrivate::updateToolBox() QSizeF size = icon->sizeFromIconSize(iconSize); icon->setMinimumSize(size); icon->setMaximumSize(size); - toolboxLayout->addItem(icon); + if (action != actions.value("close")) { + toolboxLayout->addItem(icon); + } } } @@ -772,14 +770,24 @@ void ExtenderItemPrivate::updateToolBox() //add the close icon if desired. if (destroyActionVisibility) { - destroyAction = new IconWidget(q); - destroyAction->setSvg("widgets/configuration-icons", "close"); - QSizeF size = destroyAction->sizeFromIconSize(iconSize); - destroyAction->setMinimumSize(size); - destroyAction->setMaximumSize(size); + destroyButton = new IconWidget(q); + if (!actions.contains("close")) { + QAction *destroyAction = new QAction(q); + actions["close"] = destroyAction; + } + destroyButton->setAction(actions["close"]); + destroyButton->setSvg("widgets/configuration-icons", "close"); + QSizeF size = destroyButton->sizeFromIconSize(iconSize); + destroyButton->setMinimumSize(size); + destroyButton->setMaximumSize(size); - toolboxLayout->addItem(destroyAction); - QObject::connect(destroyAction, SIGNAL(clicked()), q, SLOT(destroy())); + toolboxLayout->addItem(destroyButton); + + QObject::connect(actions["close"], SIGNAL(triggered()), q, SLOT(destroy())); + } else if (actions.contains("close")) { + QAction *destroyAction = actions["close"]; + actions.remove("close"); + destroyAction->deleteLater(); } toolboxLayout->updateGeometry(); diff --git a/extenders/extenderitem.h b/extenders/extenderitem.h index 1388831f4..5cfdcdac3 100644 --- a/extenders/extenderitem.h +++ b/extenders/extenderitem.h @@ -254,15 +254,6 @@ class PLASMA_EXPORT ExtenderItem : public QGraphicsWidget */ void hideCloseButton(); - Q_SIGNALS: - /** - * Emitted when the user closes the extender item with the destroy icon, - * not when the item is destroyed programmatically. - * - * @since 4.4 - */ - void destroyActionTriggered(); - protected: void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); diff --git a/private/extenderitem_p.h b/private/extenderitem_p.h index 5ea709488..da31a3944 100644 --- a/private/extenderitem_p.h +++ b/private/extenderitem_p.h @@ -78,7 +78,7 @@ class ExtenderItemPrivate QHash actions; QList actionsInOrder; - Plasma::IconWidget *destroyAction; + Plasma::IconWidget *destroyButton; QString title; QString name;