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:
parent
faf75a95e5
commit
f89b86589f
@ -636,20 +636,27 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
foreach (QAction *a, m_containment->corona()->actions()->actions()) {
|
foreach (QAction *a, m_containment->corona()->actions()->actions()) {
|
||||||
if (a->objectName() == QStringLiteral("lock widgets") || a->menu()) {
|
if (a->objectName() == QStringLiteral("lock widgets") || a->menu()) {
|
||||||
//It is up to the Containment to decide if the user is allowed or not
|
//It is up to the Containment to decide if the user is allowed or not
|
||||||
//to lock/unluck the widgets, so corona should not add one when there is none
|
//to lock/unluck the widgets, so corona should not add one when there is none
|
||||||
@ -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--------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user