forked from uwerat/qskinny
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQskShortcutQml.h
94 lines (66 loc) · 2.29 KB
/
QskShortcutQml.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/******************************************************************************
* QSkinny - Copyright (C) The authors
* SPDX-License-Identifier: BSD-3-Clause
*****************************************************************************/
#ifndef QSK_SHORTCUT_QML_H
#define QSK_SHORTCUT_QML_H
#include "QskQmlGlobal.h"
#include <qnamespace.h>
#include <qobject.h>
#include <qqmlparserstatus.h>
#include <memory>
class QKeySequence;
/*
For QML, with C++ there is also QskShortcutMap that does
not need to create QObjects per shortcut
*/
class QskShortcutQml : public QObject, public QQmlParserStatus
{
Q_OBJECT
Q_INTERFACES( QQmlParserStatus )
Q_PROPERTY( QVariant sequence READ sequenceVariant
WRITE setSequenceVariant NOTIFY sequenceChanged FINAL)
Q_PROPERTY( Qt::ShortcutContext context READ context
WRITE setContext NOTIFY contextChanged )
Q_PROPERTY( bool enabled READ isEnabled
WRITE setEnabled NOTIFY enabledChanged )
Q_PROPERTY( bool autoRepeat READ autoRepeat
WRITE setAutoRepeat NOTIFY autoRepeatChanged )
Q_PROPERTY( int shortcutId READ shortcutId
NOTIFY shortcutIdChanged )
using Inherited = QObject;
public:
QskShortcutQml( QObject* parent = nullptr );
QskShortcutQml( const QKeySequence&, QObject* = nullptr );
QskShortcutQml( const QKeySequence&, Qt::ShortcutContext, QObject* = nullptr );
~QskShortcutQml() override;
int shortcutId() const;
void setSequence( const QKeySequence& );
QKeySequence sequence() const;
// for QML
void setSequenceVariant( const QVariant& );
QVariant sequenceVariant() const;
Qt::ShortcutContext context() const;
void setContext( Qt::ShortcutContext );
void setEnabled( bool );
bool isEnabled() const;
void setAutoRepeat( bool );
bool autoRepeat() const;
virtual bool isFocusInScope() const;
Q_SIGNALS:
void sequenceChanged();
void contextChanged();
void enabledChanged();
void autoRepeatChanged();
void activated();
void activatedAmbiguously();
void shortcutIdChanged( int );
protected:
bool event( QEvent* ) override;
void classBegin() override;
void componentComplete() override;
private:
class PrivateData;
std::unique_ptr< PrivateData > m_data;
};
#endif