clear this bit of code up

svn path=/trunk/KDE/kdelibs/; revision=1104111
This commit is contained in:
Aaron J. Seigo 2010-03-16 18:35:07 +00:00
parent 786913a995
commit 813f6a088f

View File

@ -772,18 +772,17 @@ void ExtenderItemPrivate::updateToolBox()
} }
//add the actions that are actually set to visible. //add the actions that are actually set to visible.
QAction *closeAction = actions.value("close");
foreach (QAction *action, actionsInOrder) { foreach (QAction *action, actionsInOrder) {
if (action->isVisible()) { if (action->isVisible() && action != closeAction) {
IconWidget *icon = new IconWidget(q); IconWidget *icon = new IconWidget(q);
icon->setAction(action); icon->setAction(action);
QSizeF size = icon->sizeFromIconSize(iconSize); QSizeF size = icon->sizeFromIconSize(iconSize);
icon->setMinimumSize(size); icon->setMinimumSize(size);
icon->setMaximumSize(size); icon->setMaximumSize(size);
if (action != actions.value("close")) {
toolboxLayout->addItem(icon); toolboxLayout->addItem(icon);
} }
} }
}
//add the returntosource icon if we are detached, and have a source applet. //add the returntosource icon if we are detached, and have a source applet.
if (q->isDetached() && sourceApplet) { if (q->isDetached() && sourceApplet) {
@ -800,23 +799,21 @@ void ExtenderItemPrivate::updateToolBox()
//add the close icon if desired. //add the close icon if desired.
if (destroyActionVisibility) { if (destroyActionVisibility) {
destroyButton = new IconWidget(q); destroyButton = new IconWidget(q);
if (!actions.contains("close")) { if (!closeAction) {
QAction *destroyAction = new QAction(q); closeAction = new QAction(q);
actions["close"] = destroyAction; actions.insert("close", closeAction);
QObject::connect(closeAction, SIGNAL(triggered()), q, SLOT(destroy()));
} }
destroyButton->setAction(actions["close"]); destroyButton->setAction(closeAction);
destroyButton->setSvg("widgets/configuration-icons", "close"); destroyButton->setSvg("widgets/configuration-icons", "close");
QSizeF size = destroyButton->sizeFromIconSize(iconSize); QSizeF size = destroyButton->sizeFromIconSize(iconSize);
destroyButton->setMinimumSize(size); destroyButton->setMinimumSize(size);
destroyButton->setMaximumSize(size); destroyButton->setMaximumSize(size);
toolboxLayout->addItem(destroyButton); toolboxLayout->addItem(destroyButton);
} else if (closeAction) {
QObject::connect(actions["close"], SIGNAL(triggered()), q, SLOT(destroy()));
} else if (actions.contains("close")) {
QAction *destroyAction = actions["close"];
actions.remove("close"); actions.remove("close");
destroyAction->deleteLater(); closeAction->deleteLater();
closeAction = 0;
} }
toolboxLayout->updateGeometry(); toolboxLayout->updateGeometry();