| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#ifndef KSNIP_KEYSEQUENCELINEEDIT_H |
| 21 |
#define KSNIP_KEYSEQUENCELINEEDIT_H |
| 22 |
|
| 23 |
#include <QLineEdit> |
| 24 |
#include <QKeySequence> |
| 25 |
#include <QKeyEvent> |
| 26 |
#include <QApplication> |
| 27 |
|
| 28 |
#include "src/gui/globalHotKeys/keyHandler/KeyHandlerFactory.h" |
| 29 |
#include "src/gui/globalHotKeys/NativeKeyEventFilter.h" |
| 30 |
|
| 31 |
class KeySequenceLineEdit : public QLineEdit |
| 32 |
{ |
| 33 |
Q_OBJECT |
| 34 |
public: |
| 35 |
explicit KeySequenceLineEdit(QWidget *widget, const QList<Qt::Key> &allowedKeys, const QSharedPointer<IPlatformChecker> &platformChecker); |
| 36 |
~KeySequenceLineEdit() override; |
| 37 |
QKeySequence value() const; |
| 38 |
void setValue(const QKeySequence &keySequence); |
| 39 |
void clear(); |
| 40 |
|
| 41 |
protected: |
| 42 |
void keyPressEvent(QKeyEvent *event) override; |
| 43 |
void keyReleaseEvent(QKeyEvent *event) override; |
| 44 |
void focusInEvent(QFocusEvent *event) override; |
| 45 |
void focusOutEvent(QFocusEvent *event) override; |
| 46 |
|
| 47 |
private: |
| 48 |
QKeySequence mKeySequence; |
| 49 |
Qt::KeyboardModifiers mModifiers; |
| 50 |
Qt::Key mKey; |
| 51 |
QList<Qt::Key> mAllowedKeys; |
| 52 |
QList<QSharedPointer<NativeKeyEventFilter>> mSpecialKeyFilters; |
| 53 |
QSharedPointer<IPlatformChecker> mPlatformChecker; |
| 54 |
|
| 55 |
void updateText(); |
| 56 |
void keyPressed(Qt::Key key); |
| 57 |
void setupSpecialKeyHandling(); |
| 58 |
void updateKeySequence(); |
| 59 |
void addSpecialKeyHandler(const QKeySequence &keySequence, Qt::Key key); |
| 60 |
Qt::Key getAllowedKey(const QKeyEvent *event) const; |
| 61 |
void removeSpecialKeyHandler(); |
| 62 |
}; |
| 63 |
|
| 64 |
|
| 65 |
#endif |