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,15 +636,22 @@ QList<QObject *> ContainmentInterface::actions() const
{ {
//FIXME: giving directly a QList<QAction*> crashes //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 //use a multimap to sort by action type
QMultiMap<int, QObject *> actions; QMultiMap<int, QObject *> actions;
int i = 0; int i = 0;
foreach (QAction *a, m_containment->actions()->actions()) { foreach (QAction *a, m_containment->actions()->actions()) {
//FIXME QML visualizations don't support menus for now, *and* there is no way to if (!actionOrder.contains(a->objectName())) {
//distinguish them on QML side //FIXME QML visualizations don't support menus for now, *and* there is no way to
if (!a->menu()) { //distinguish them on QML side
actions.insert(a->data().toInt()*100 + i, a); if (!a->menu()) {
++i; actions.insert(a->data().toInt()*100 + i, a);
++i;
}
} else {
orderedActions[a->objectName()] = a;
} }
} }
@ -657,10 +664,25 @@ QList<QObject *> ContainmentInterface::actions() const
//one //one
continue; continue;
} }
actions.insert(a->data().toInt()*100 + i, a);
if (!actionOrder.contains(a->objectName())) {
actions.insert(a->data().toInt()*100 + i, a);
} else {
orderedActions[a->objectName()] = a;
}
++i; ++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-------------------- //PROTECTED--------------------