forked from jahnf/Projecteur
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qglobalshortcutx11.h
32 lines (25 loc) · 901 Bytes
/
qglobalshortcutx11.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// This file is part of Projecteur - https://github.com/jahnf/projecteur - See LICENSE.md and README.md
#pragma once
#include <QObject>
#include <QAbstractNativeEventFilter>
#include <QKeySequence>
class QGlobalShortcutX11 final : public QObject, public QAbstractNativeEventFilter
{
Q_OBJECT
Q_PROPERTY(QKeySequence key READ key WRITE setKey)
public:
explicit QGlobalShortcutX11(QObject* parent = nullptr);
explicit QGlobalShortcutX11(const QKeySequence& keyseq, QObject* parent = nullptr);
virtual ~QGlobalShortcutX11() override;
bool nativeEventFilter(const QByteArray& event_type, void* message, long* result) override;
QKeySequence key() const;
void setKey(const QKeySequence& keyseq);
signals:
void activated();
private:
bool m_enabled = false;
QKeySequence m_keySeq;
quint8 m_keyCode = 0;
quint16 m_keyMods = 0;
void unsetKey();
};