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
33 static const char *hardKeyProperty;
34 static const char *displayProperty;
35 static const char *defaultKey1Property;
36 static const char *defaultKey2Property;
37 static const char *defaultToolTipProperty;
38
39 static ShotcutActions &singleton();
40 explicit ShotcutActions() : QObject() {}
41
42 void add(const QString &name, QAction *action, QString group = "");
43 void loadFromMenu(QMenu *menu, const QString group = "");
44 QAction *operator [](const QString &key);
45 QList<QString> keys();
46 void overrideShortcuts(const QString &key, QList<QKeySequence> shortcuts);
47 void initializeShortcuts();
48
49private:
50 void addShortcutToToolTip(QAction *action);
51 QHash<QString, QAction *> m_actions;
52};
53
54#define Actions ShotcutActions::singleton()
55
56#endif // ACTIONS_H