summaryrefslogtreecommitdiffstats
path: root/examples/widgets/widgets/shortcuteditor/actionmanager.h
diff options
context:
space:
mode:
authorLaszlo Papp <lpapp@kde.org>2022-07-09 20:57:14 +0100
committerLaszlo Papp <lpapp@kde.org>2022-10-25 14:38:46 +0100
commitfaeeb42b853426a211883d4885e01eb01f26eb7e (patch)
tree1559bf8b2f79f7f69b600d7339a5b3b36f1a732d /examples/widgets/widgets/shortcuteditor/actionmanager.h
parentf263211484f8d4f2bf706077cc911d1a76c5db36 (diff)
Add a shortcut editor example
Many applications offer shortcuts for quick interaction with the application. It is also common in such applications to offer a shortcut editor in the preferences or separately in a dialog. However, even though this is a fairly common use case for applications with more than a couple of shortcuts, there is no good and comprehensive official Qt example how this could be achieved. This change is an attempt to bridge the gap. Change-Id: Ic01a404e6157bda1b0a75a0b792cbfe5d910d48f Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'examples/widgets/widgets/shortcuteditor/actionmanager.h')
-rw-r--r--examples/widgets/widgets/shortcuteditor/actionmanager.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/examples/widgets/widgets/shortcuteditor/actionmanager.h b/examples/widgets/widgets/shortcuteditor/actionmanager.h
new file mode 100644
index 0000000000..da20cd8840
--- /dev/null
+++ b/examples/widgets/widgets/shortcuteditor/actionmanager.h
@@ -0,0 +1,33 @@
+// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef ACTIONMANAGER_H
+#define ACTIONMANAGER_H
+
+#include <QList>
+#include <QString>
+
+QT_BEGIN_NAMESPACE
+class QAction;
+QT_END_NAMESPACE
+
+class ActionManager
+{
+public:
+ ActionManager() = default;
+ ~ActionManager() = default;
+
+ QList<QAction*> registeredActions() const;
+
+ void registerAction(QAction *action);
+ void registerAction(QAction *action, const QString &context, const QString &category);
+ QAction *registerAction(const QString &name, const QString &shortcut, const QString &context, const QString &category);
+
+ QString contextForAction(QAction *action);
+ QString categoryForAction(QAction *action);
+
+private:
+ QList<QAction *> m_actions;
+};
+
+#endif