myproject 0.0.0
%%description%%
Loading...
Searching...
No Matches
keysequenceeditor.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtQmlIntegration/qqmlintegration.h>
4#include <qtmetamacros.h>
5
6#include <QKeySequence>
7#include <QQuickItem>
8#include <QString>
9#include <QVector>
10
11class QKeyEvent;
12class QFocusEvent;
13
14class KeySequenceEditor : public QQuickItem {
15 Q_OBJECT
16 // The sequence that is current in the settings (e.g. is current when the
17 // settings dialog was opened).
18 Q_PROPERTY(QString originalSequence READ originalSequence WRITE
20 // The last sequence that was successfully entered.
21 Q_PROPERTY(QString newSequence READ newSequence NOTIFY newSequenceChanged)
22 Q_PROPERTY(QString displaySequence READ displaySequence NOTIFY
24 Q_PROPERTY(bool hasChanged READ hasChanged NOTIFY hasChangedChanged)
25 QML_ELEMENT
26
27 public:
29
30 [[nodiscard]] QString originalSequence() const;
31 void setOriginalSequence(const QString &originalSequence);
32
33 [[nodiscard]] QString newSequence() const;
34
35 [[nodiscard]] QString displaySequence() const;
36
37 [[nodiscard]] bool hasChanged() const;
38
39 public slots:
40 void reset();
41
42 signals:
47
48 protected:
49 void keyPressEvent(QKeyEvent *event) override;
50 void keyReleaseEvent(QKeyEvent *event) override;
51 void focusInEvent(QFocusEvent *event) override;
52 void focusOutEvent(QFocusEvent *event) override;
53
54 private:
55 void setCurrentSequence(const QString &currentSequence);
56 void setNewSequence(const QString &newSequence);
57
58 void resetKeysPressed();
59
60 void accept();
61 void cancel();
62 [[nodiscard]] bool validate(const QKeySequence &sequence) const;
63
64 QKeySequence m_OriginalSequence;
65 QKeySequence m_CurrentSequence;
66 QKeySequence m_NewSequence;
67 int m_CurrentKeyIndex{0};
68 QVector<int> m_KeysPressed;
69};
Definition keysequenceeditor.h:14
bool hasChanged
Definition keysequenceeditor.h:24
void focusOutEvent(QFocusEvent *event) override
Definition keysequenceeditor.cpp:125
void hasChangedChanged()
void newSequenceChanged()
void reset()
Definition keysequenceeditor.cpp:64
QString originalSequence
Definition keysequenceeditor.h:19
void setOriginalSequence(const QString &originalSequence)
Definition keysequenceeditor.cpp:15
void displaySequenceChanged()
QString newSequence
Definition keysequenceeditor.h:21
void focusInEvent(QFocusEvent *event) override
Definition keysequenceeditor.cpp:118
void keyPressEvent(QKeyEvent *event) override
Definition keysequenceeditor.cpp:79
void originalSequenceChanged()
void keyReleaseEvent(QKeyEvent *event) override
Definition keysequenceeditor.cpp:116
QString displaySequence
Definition keysequenceeditor.h:23