on bionic help sign in
unity8/plugins/GlobalShortcut/globalshortcutregistry.h
70 lines 1.9 kB history raw
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 */
17#ifndef GLOBALSHORTCUT_REGISTRY_H
18#define GLOBALSHORTCUT_REGISTRY_H
20#include <QObject>
21#include <QVariantList>
22#include <QPointer>
23#include <QWindow>
25#include "globalshortcut.h"
27typedef QMap<QVariant, QVector<QPointer<GlobalShortcut>>> GlobalShortcutList;
29/**
30 * @brief The GlobalShortcutRegistry class
31 *
32 * Serves as a central point for shortcut registration.
33 */
34class Q_DECL_EXPORT GlobalShortcutRegistry: public QObject
36 Q_OBJECT
37public:
38 GlobalShortcutRegistry(QObject * parent = nullptr);
39 ~GlobalShortcutRegistry() = default;
41 /**
42 * @return the list of shortcuts currently registered
43 */
44 GlobalShortcutList shortcuts() const;
45 /**
46 * @return whether shortcut @p seq is currently registered
47 */
48 bool hasShortcut(const QVariant &seq) const;
49 /**
50 * Adds a shortcut @p seq to the registry
51 */
52 void addShortcut(const QVariant &seq, GlobalShortcut * sc);
54 /**
55 * Sets up key events filtering on window @p wid
56 */
57 void setupFilterOnWindow(qulonglong wid);
59protected:
60 bool eventFilter(QObject *obj, QEvent *event) override;
62private Q_SLOTS:
63 void removeShortcut(QObject *obj);
65private:
66 GlobalShortcutList m_shortcuts;
67 QPointer<QWindow> m_filteredWindow = nullptr;
68};
70#endif