Sayonara Player
ShortcutHandler.h
1 /* ShortcutHandler.h */
2 
3 /* Copyright (C) 2011-2019 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef SHORTCUTHANDLER_H
22 #define SHORTCUTHANDLER_H
23 
24 
25 #include "ShortcutIdentifier.h"
26 #include "Utils/Singleton.h"
27 #include "Utils/Pimpl.h"
28 
29 #include <QShortcut>
30 #include <QObject>
31 
32 class Shortcut;
33 
34 #define ShortcutPrivate private
35 
41  public QObject
42 {
43  Q_OBJECT
44  SINGLETON(ShortcutHandler)
45  PIMPL(ShortcutHandler)
46 
47  friend class Shortcut;
48 ShortcutPrivate:
49  void qt_shortcuts_added(ShortcutIdentifier db_key, const QList<QShortcut*>& qt_shortcuts);
50 
51 signals:
52  void sig_shortcut_changed(ShortcutIdentifier db_key);
53 
54 public:
60  Shortcut shortcut(ShortcutIdentifier db_key) const;
61 
67  void set_shortcut(ShortcutIdentifier db_key, const QStringList& shortcut);
68 
74 
75  QString db_key(ShortcutIdentifier id) const;
76  QString shortcut_text(ShortcutIdentifier id) const;
77 
78 private slots:
79  void qt_shortcut_destroyed();
80 };
81 
82 #endif // SHORTCUTHANDLER_H
void set_shortcut(ShortcutIdentifier db_key, const QStringList &shortcut)
set the shortcut by its unique identifier
Shortcut shortcut(ShortcutIdentifier db_key) const
get a shortcut by its unique identifier
A singleton class for retrieving shortcuts.
Definition: ShortcutHandler.h:40
QList< ShortcutIdentifier > all_identifiers() const
get all shortcuts
A single shortcut managed by ShortcutHandler. This class holds information about the default shortcut...
Definition: Shortcut.h:41