src/uiutilities.cpp

Sat, 14 Dec 2019 23:00:01 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sat, 14 Dec 2019 23:00:01 +0200
changeset 20
cef43609a374
parent 16
aeb5f203b3eb
child 24
1a0faaaceb84
permissions
-rw-r--r--

fixed build

16
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1 #include "uiutilities.h"
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
2
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
3 QVector<QAction*> uiutilities::collectActions(QObject* subject)
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
4 {
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
5 QVector<QAction*> actions;
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
6 for (QAction* action : subject->findChildren<QAction*>())
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
7 {
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
8 if (not action->text().isEmpty()
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
9 and action->data().isNull()
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
10 and not action->objectName().isEmpty())
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
11 {
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
12 actions.push_back(action);
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
13 }
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
14 }
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
15 return actions;
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
16 }
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
17
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
18 uiutilities::KeySequenceMap uiutilities::makeKeySequenceMap(const QVector<QAction*>& actions)
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
19 {
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
20 KeySequenceMap result;
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
21 for (QAction* action : actions)
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
22 {
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
23 result[action->objectName()] = action->shortcut();
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
24 }
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
25 return result;
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
26 }

mercurial