emit a signal when the user clicks the close button.

would perhaps be better to bind it with an action and make it accessible
with action("close")?
CCMAIL: plasma-devel@kde.org

svn path=/trunk/KDE/kdelibs/; revision=1047062
This commit is contained in:
Marco Martin 2009-11-10 11:30:25 +00:00
parent 71fa982797
commit a56c4c381a
2 changed files with 16 additions and 1 deletions

View File

@ -444,6 +444,11 @@ void ExtenderItem::destroy()
d->hostApplet()->config("ExtenderItems").deleteGroup(QString::number(d->extenderItemId)); d->hostApplet()->config("ExtenderItems").deleteGroup(QString::number(d->extenderItemId));
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();
} }
@ -689,6 +694,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),
title(QString()), title(QString()),
mouseOver(false), mouseOver(false),
dragStarted(false), dragStarted(false),
@ -766,7 +772,7 @@ void ExtenderItemPrivate::updateToolBox()
//add the close icon if desired. //add the close icon if desired.
if (destroyActionVisibility) { if (destroyActionVisibility) {
IconWidget *destroyAction = new IconWidget(q); destroyAction = new IconWidget(q);
destroyAction->setSvg("widgets/configuration-icons", "close"); destroyAction->setSvg("widgets/configuration-icons", "close");
QSizeF size = destroyAction->sizeFromIconSize(iconSize); QSizeF size = destroyAction->sizeFromIconSize(iconSize);
destroyAction->setMinimumSize(size); destroyAction->setMinimumSize(size);

View File

@ -254,6 +254,15 @@ 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);