Fri, 13 Dec 2019 21:35:59 +0200
things
16 | 1 | #include "uiutilities.h" |
2 | ||
3 | QVector<QAction*> uiutilities::collectActions(QObject* subject) | |
4 | { | |
5 | QVector<QAction*> actions; | |
6 | for (QAction* action : subject->findChildren<QAction*>()) | |
7 | { | |
8 | if (not action->text().isEmpty() | |
9 | and action->data().isNull() | |
10 | and not action->objectName().isEmpty()) | |
11 | { | |
12 | actions.push_back(action); | |
13 | } | |
14 | } | |
15 | return actions; | |
16 | } | |
17 | ||
18 | uiutilities::KeySequenceMap uiutilities::makeKeySequenceMap(const QVector<QAction*>& actions) | |
19 | { | |
20 | KeySequenceMap result; | |
21 | for (QAction* action : actions) | |
22 | { | |
23 | result[action->objectName()] = action->shortcut(); | |
24 | } | |
25 | return result; | |
26 | } |