the destroy action is now accessible with action("close")

svn path=/trunk/KDE/kdelibs/; revision=1047295
This commit is contained in:
Marco Martin 2009-11-10 22:13:00 +00:00
parent 22d9d97acc
commit 76c1377ed9
3 changed files with 22 additions and 23 deletions

View File

@ -445,10 +445,6 @@ void ExtenderItem::destroy()
d->extender->d->removeExtenderItem(this); d->extender->d->removeExtenderItem(this);
emit d->extender->itemDetached(this); emit d->extender->itemDetached(this);
if (sender() == d->destroyAction) {
emit destroyActionTriggered();
}
deleteLater(); deleteLater();
} }
@ -694,7 +690,7 @@ ExtenderItemPrivate::ExtenderItemPrivate(ExtenderItem *extenderItem, Extender *h
dragger(new FrameSvg(extenderItem)), dragger(new FrameSvg(extenderItem)),
background(new FrameSvg(extenderItem)), background(new FrameSvg(extenderItem)),
collapseIcon(0), collapseIcon(0),
destroyAction(0), destroyButton(0),
title(QString()), title(QString()),
mouseOver(false), mouseOver(false),
dragStarted(false), dragStarted(false),
@ -754,7 +750,9 @@ void ExtenderItemPrivate::updateToolBox()
QSizeF size = icon->sizeFromIconSize(iconSize); QSizeF size = icon->sizeFromIconSize(iconSize);
icon->setMinimumSize(size); icon->setMinimumSize(size);
icon->setMaximumSize(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. //add the close icon if desired.
if (destroyActionVisibility) { if (destroyActionVisibility) {
destroyAction = new IconWidget(q); destroyButton = new IconWidget(q);
destroyAction->setSvg("widgets/configuration-icons", "close"); if (!actions.contains("close")) {
QSizeF size = destroyAction->sizeFromIconSize(iconSize); QAction *destroyAction = new QAction(q);
destroyAction->setMinimumSize(size); actions["close"] = destroyAction;
destroyAction->setMaximumSize(size); }
destroyButton->setAction(actions["close"]);
destroyButton->setSvg("widgets/configuration-icons", "close");
QSizeF size = destroyButton->sizeFromIconSize(iconSize);
destroyButton->setMinimumSize(size);
destroyButton->setMaximumSize(size);
toolboxLayout->addItem(destroyAction); toolboxLayout->addItem(destroyButton);
QObject::connect(destroyAction, SIGNAL(clicked()), q, SLOT(destroy()));
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(); toolboxLayout->updateGeometry();

View File

@ -254,15 +254,6 @@ class PLASMA_EXPORT ExtenderItem : public QGraphicsWidget
*/ */
void hideCloseButton(); 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: protected:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);

View File

@ -78,7 +78,7 @@ class ExtenderItemPrivate
QHash<QString, QAction*> actions; QHash<QString, QAction*> actions;
QList<QAction*> actionsInOrder; QList<QAction*> actionsInOrder;
Plasma::IconWidget *destroyAction; Plasma::IconWidget *destroyButton;
QString title; QString title;
QString name; QString name;