src/uiutilities.cpp

Wed, 01 Jan 2020 17:45:56 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Wed, 01 Jan 2020 17:45:56 +0200
changeset 21
0133e565e072
parent 16
aeb5f203b3eb
child 24
1a0faaaceb84
permissions
-rw-r--r--

things

#include "uiutilities.h"

QVector<QAction*> uiutilities::collectActions(QObject* subject)
{
	QVector<QAction*> actions;
	for (QAction* action : subject->findChildren<QAction*>())
	{
		if (not action->text().isEmpty()
			and action->data().isNull()
			and not action->objectName().isEmpty())
		{
			actions.push_back(action);
		}
	}
	return actions;
}

uiutilities::KeySequenceMap uiutilities::makeKeySequenceMap(const QVector<QAction*>& actions)
{
	KeySequenceMap result;
	for (QAction* action : actions)
	{
		result[action->objectName()] = action->shortcut();
	}
	return result;
}

mercurial