TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
qglobalshortcut_p.h
Go to the documentation of this file.
1 #ifndef QGLOBALSHORTCUT_P_H
2 #define QGLOBALSHORTCUT_P_H
3 
4 /***************************************************************************
5  * This file is part of the TTK Music Player project
6  * Copyright (C) 2015 - 2024 Greedysky Studio
7 
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17 
18  * You should have received a copy of the GNU General Public License along
19  * with this program; If not, see <http://www.gnu.org/licenses/>.
20  ***************************************************************************/
21 
22 #include "qglobalshortcut.h"
23 #include <QHash>
24 #include <QAbstractEventDispatcher>
25 #if TTK_QT_VERSION_CHECK(5,0,0)
26 # include <QAbstractNativeEventFilter>
27 #endif
28 
32 class TTK_MODULE_EXPORT QGlobalShortcutPrivate : public TTKPrivate<QGlobalShortcut>
33 #if TTK_QT_VERSION_CHECK(5,0,0)
34  , public QAbstractNativeEventFilter
35 #endif
36 {
37 public:
41 
42  bool m_enabled;
43  Qt::Key m_key;
44  Qt::KeyboardModifiers m_mods;
45 
46  bool setShortcut(const QKeySequence &shortcut);
47  bool unsetShortcut();
48 
49  static int m_ref;
50  static bool m_error;
51 #if !TTK_QT_VERSION_CHECK(5,0,0)
52  static QAbstractEventDispatcher::EventFilter m_prevEventFilter;
53  static bool eventFilter(void* message);
54 #else
55  virtual bool nativeEventFilter(const QByteArray &type, void *message, qint *result) override final;
56 #endif
57 
58 private:
59  static quint32 nativeKeycode(Qt::Key keycode);
60  static quint32 nativeModifiers(Qt::KeyboardModifiers modifiers);
61  static bool registerShortcut(quint32 nativeKey, quint32 nativeMods);
62  static bool unregisterShortcut(quint32 nativeKey, quint32 nativeMods);
63  static void activateShortcut(quint32 nativeKey, quint32 nativeMods);
64 
65  static QHash<QPair<quint32, quint32>, QGlobalShortcut*> m_shortcuts;
66 };
67 
68 #endif // QGLOBALSHORTCUT_P_H
#define TTK_MODULE_EXPORT
Qt::KeyboardModifiers m_mods
static QAbstractEventDispatcher::EventFilter m_prevEventFilter
#define TTK_DECLARE_PUBLIC(Class)
Definition: ttkprivate.h:30
The class of the qglobal shortcut private.
#define qint
Definition: ttkqtglobal.h:168
The class of the qglobal shortcut.
The class of the ttk private base.
Definition: ttkprivate.h:48
static QHash< QPair< quint32, quint32 >, QGlobalShortcut * > m_shortcuts