diff --git a/extenders/extenderitem.cpp b/extenders/extenderitem.cpp index d7d5d82bb..9c21303df 100644 --- a/extenders/extenderitem.cpp +++ b/extenders/extenderitem.cpp @@ -48,6 +48,7 @@ #include "view.h" #include "widgets/iconwidget.h" +#include "widgets/pushbutton.h" #include "private/applethandle_p.h" #include "private/extender_p.h" @@ -808,28 +809,37 @@ void ExtenderItemPrivate::updateToolBox() const QSizeF widgetSize = collapseIcon->sizeFromIconSize(toolbox->iconSize()); QSet shownActions = actionsInOrder.toSet(); - QHash actionIcons; + + QHash actionWidgets; for (int index = startingIndex; index < toolboxLayout->count(); ++index) { - IconWidget *widget = dynamic_cast(toolboxLayout->itemAt(index)); + QGraphicsWidget *widget = dynamic_cast(toolboxLayout->itemAt(index)); + QAction *widgetAction = 0; if (!widget) { continue; + } else if (qobject_cast(widget)) { + widgetAction = static_cast(widget)->action(); + } else if (qobject_cast(widget)) { + widgetAction = static_cast(widget)->action(); + } else { + continue; } + if (closeIndex == -1 && destroyActionVisibility && - closeAction && widget->action() == closeAction) { + closeAction && widgetAction == closeAction) { closeIndex = index; continue; } if (returnToSourceIndex == -1 && returnToSourceVisibility && - returnToSourceAction && widget->action() == returnToSourceAction) { + returnToSourceAction && widgetAction == returnToSourceAction) { returnToSourceIndex = index; continue; } - if (shownActions.contains(widget->action())) { - actionIcons.insert(widget->action(), widget); + if (shownActions.contains(widgetAction)) { + actionWidgets.insert(widgetAction, widget); continue; } @@ -837,6 +847,7 @@ void ExtenderItemPrivate::updateToolBox() widget->deleteLater(); } + // ensure the collapseIcon is the correct size. collapseIcon->setMinimumSize(widgetSize); collapseIcon->setMaximumSize(widgetSize); @@ -844,16 +855,33 @@ void ExtenderItemPrivate::updateToolBox() //add the actions that are actually set to visible. foreach (QAction *action, actionsInOrder) { if (action->isVisible() && action != closeAction) { - IconWidget *icon = actionIcons.value(action); - if (!icon) { - icon = new IconWidget(q); - icon->setAction(action); - } + IconWidget *icon = qobject_cast(actionWidgets.value(action)); + PushButton *button = qobject_cast(actionWidgets.value(action)); - icon->setMinimumSize(widgetSize); - icon->setMaximumSize(widgetSize); - icon->setCursor(Qt::ArrowCursor); - toolboxLayout->insertItem(startingIndex, icon); + if (action->icon().isNull() && !action->text().isNull()) { + if (!button) { + button = new PushButton(q); + button->setAction(action); + } + + button->setMinimumHeight(widgetSize.height()); + button->setMaximumHeight(widgetSize.height()); + button->setCursor(Qt::ArrowCursor); + toolboxLayout->insertItem(startingIndex, button); + } else { + if (!icon) { + icon = new IconWidget(q); + icon->setAction(action); + } + + if (action->icon().isNull()) { + icon->setText(action->text()); + } + icon->setMinimumSize(widgetSize); + icon->setMaximumSize(widgetSize); + icon->setCursor(Qt::ArrowCursor); + toolboxLayout->insertItem(startingIndex, icon); + } } } diff --git a/private/extender_p.h b/private/extender_p.h index 03a49ade0..e226e41cf 100644 --- a/private/extender_p.h +++ b/private/extender_p.h @@ -71,6 +71,7 @@ class ExtenderPrivate void delayItemAddedEvent(); void loadExtenderItems(); void updateBorders(); + void delayItemAddedEvent(); void updateEmptyExtenderLabel(); ExtenderGroup *findGroup(const QString &name) const; @@ -94,6 +95,8 @@ class ExtenderPrivate static QGraphicsGridLayout *s_popupLayout; bool destroying; + + QList > pendingItems; }; } // namespace Plasma