FEATURE: allow to add actions with only text in the extender titlebar, they will appear as push buttons
svn path=/trunk/KDE/kdelibs/; revision=1177247
This commit is contained in:
parent
83a9fc7f21
commit
ec9a6ad1ba
@ -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<QAction*> shownActions = actionsInOrder.toSet();
|
||||
QHash<QAction *, IconWidget *> actionIcons;
|
||||
|
||||
QHash<QAction *, QGraphicsWidget *> actionWidgets;
|
||||
for (int index = startingIndex; index < toolboxLayout->count(); ++index) {
|
||||
IconWidget *widget = dynamic_cast<IconWidget*>(toolboxLayout->itemAt(index));
|
||||
QGraphicsWidget *widget = dynamic_cast<QGraphicsWidget*>(toolboxLayout->itemAt(index));
|
||||
QAction *widgetAction = 0;
|
||||
|
||||
if (!widget) {
|
||||
continue;
|
||||
} else if (qobject_cast<IconWidget*>(widget)) {
|
||||
widgetAction = static_cast<IconWidget*>(widget)->action();
|
||||
} else if (qobject_cast<PushButton*>(widget)) {
|
||||
widgetAction = static_cast<PushButton*>(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<IconWidget*>(actionWidgets.value(action));
|
||||
PushButton *button = qobject_cast<PushButton*>(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<QPair<ExtenderItem *, QPointF> > pendingItems;
|
||||
};
|
||||
|
||||
} // namespace Plasma
|
||||
|
Loading…
x
Reference in New Issue
Block a user