almost same order as the context menu

the leave action is still fixed as the last one by the toolbox

CCBUG:338585
This commit is contained in:
Marco Martin 2014-08-29 17:59:16 +02:00
parent faf75a95e5
commit f89b86589f

View File

@ -636,16 +636,23 @@ QList<QObject *> ContainmentInterface::actions() const
{
//FIXME: giving directly a QList<QAction*> crashes
QStringList actionOrder;
actionOrder << "add widgets" << "manage activities" << "remove" << "lock widgets" << "run associated application" << "configure";
QHash<QString, QAction *> orderedActions;
//use a multimap to sort by action type
QMultiMap<int, QObject *> actions;
int i = 0;
foreach (QAction *a, m_containment->actions()->actions()) {
if (!actionOrder.contains(a->objectName())) {
//FIXME QML visualizations don't support menus for now, *and* there is no way to
//distinguish them on QML side
if (!a->menu()) {
actions.insert(a->data().toInt()*100 + i, a);
++i;
}
} else {
orderedActions[a->objectName()] = a;
}
}
i = 0;
@ -657,10 +664,25 @@ QList<QObject *> ContainmentInterface::actions() const
//one
continue;
}
if (!actionOrder.contains(a->objectName())) {
actions.insert(a->data().toInt()*100 + i, a);
} else {
orderedActions[a->objectName()] = a;
}
++i;
}
return actions.values();
QList<QObject *> actionList = actions.values();
foreach (const QString &name, actionOrder) {
QAction *a = orderedActions.value(name);
if (a && a->isVisible() && !a->menu()) {
actionList << a;
}
++i;
}
return actionList;
}
//PROTECTED--------------------