CuteLogger
Fast and simple logging solution for Qt based applications
actions.h
1/*
2 * Copyright (c) 2022 Meltytech, LLC
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef ACTIONS_H
19#define ACTIONS_H
20
21#include <QHash>
22#include <QObject>
23
24class QAction;
25class QMenu;
26
27class ShotcutActions : public QObject
28{
29 Q_OBJECT
30
31public:
32 static const char *hardKeyProperty;
33 static const char *displayProperty;
34 static const char *defaultKey1Property;
35 static const char *defaultKey2Property;
36 static const char *defaultToolTipProperty;
37
38 static ShotcutActions &singleton();
39 explicit ShotcutActions()
40 : QObject()
41 {}
42
43 void add(const QString &name, QAction *action, QString group = "");
44 void loadFromMenu(QMenu *menu, const QString group = "");
45 QAction *operator[](const QString &key);
46 QList<QString> keys();
47 void overrideShortcuts(const QString &key, QList<QKeySequence> shortcuts);
48 void initializeShortcuts();
49
50private:
51 void addShortcutToToolTip(QAction *action);
52 QHash<QString, QAction *> m_actions;
53};
54
55#define Actions ShotcutActions::singleton()
56
57#endif // ACTIONS_H