Unity 8
globalshortcutregistry.h
1 /*
2  * Copyright (C) 2015 Canonical, Ltd.
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; version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef GLOBALSHORTCUT_REGISTRY_H
18 #define GLOBALSHORTCUT_REGISTRY_H
19 
20 #include <QObject>
21 #include <QVariantList>
22 #include <QPointer>
23 #include <QWindow>
24 
25 #include "globalshortcut.h"
26 
27 typedef QMap<QVariant, QVector<QPointer<GlobalShortcut>>> GlobalShortcutList;
28 
34 class Q_DECL_EXPORT GlobalShortcutRegistry: public QObject
35 {
36  Q_OBJECT
37 public:
38  GlobalShortcutRegistry(QObject * parent = nullptr);
39  ~GlobalShortcutRegistry() = default;
40 
44  GlobalShortcutList shortcuts() const;
48  bool hasShortcut(const QVariant &seq) const;
52  void addShortcut(const QVariant &seq, GlobalShortcut * sc);
53 
57  void setupFilterOnWindow(qulonglong wid);
58 
59 protected:
60  bool eventFilter(QObject *obj, QEvent *event) override;
61 
62 private Q_SLOTS:
63  void removeShortcut(QObject *obj);
64 
65 private:
66  GlobalShortcutList m_shortcuts;
67  QPointer<QWindow> m_filteredWindow = nullptr;
68 };
69 
70 #endif
The GlobalShortcutRegistry class.
The GlobalShortcut class.