src/uiutilities.cpp

Sun, 19 Jan 2020 02:54:48 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 19 Jan 2020 02:54:48 +0200
changeset 22
6da867fa5429
parent 16
aeb5f203b3eb
child 24
1a0faaaceb84
permissions
-rw-r--r--

commit work on GL rendering

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