DtkWidget
DTK Widget module
载入中...
搜索中...
未找到
dshortcutedit.h
1// SPDX-FileCopyrightText: 2015 - 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DSHORTCUTEDIT_H
6#define DSHORTCUTEDIT_H
7
8#include <QFrame>
9#include <QLabel>
10#include <QString>
11#include <QRegularExpression>
12#include <QColor>
13#include <QWidget>
14#include <QMap>
15
16#include <dtkwidget_global.h>
17
18DWIDGET_BEGIN_NAMESPACE
19
20class DShortcutEditLabel;
21
22#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
23
24class D_DECL_DEPRECATED_X("Use DKeySequenceEdit instead.") LIBDTKWIDGETSHARED_EXPORT DShortcutEdit : public QFrame
25{
26 Q_OBJECT
27
28public:
29 DShortcutEdit(QWidget *parent = Q_NULLPTR);
30
31 QSize sizeHint() const;
32 bool eventFilter(QObject *o, QEvent *e);
33 bool isValidShortcutKey(const QString & key);
34 const QMap<QString, QString> &getKeyMapping() const;
35 const QList<QRegularExpression> &getBlockShortcutKeysList() const;
36
37Q_SIGNALS:
38 void shortcutKeysChanged(const QString & shortcutKeys);
39 void shortcutKeysFinished(const QString & shortcutKeys);
40 void invalidShortcutKey(const QString & shortcutKeys);
41
42public Q_SLOTS:
43 void clearShortcutKey();
44 void setShortcutKey(const QString & key);
45 void setKeyMapping(const QMap<QString, QString> & mapping);
46 void setBlockShortcutKeysList(const QList<QRegularExpression> & kList);
47 void setInValidState() const;
48 void setNormalState() const;
49
50private Q_SLOTS:
51 void toEchoMode();
52 void toInputMode() const;
53 void shortcutKeyPress(QKeyEvent *e);
54
55private:
56 QString convertShortcutKeys(const QString & keys);
57
58private:
59 DShortcutEditLabel *m_keysLabel;
60 QLabel *m_keysEdit;
61
62 QString m_shortcutKeys;
63 QList<QRegularExpression> m_blockedShortcutKeys;
64 QMap<QString, QString> m_keyMapping;
65
66 static const QString DefaultTips;
67};
68
69#endif
70
71class DShortcutEditLabel : public QLabel
72{
73 Q_OBJECT
74 Q_PROPERTY(QColor echoNormal MEMBER m_colorNormal NOTIFY colorSettingChange DESIGNABLE true SCRIPTABLE true)
75 Q_PROPERTY(QColor echoHover MEMBER m_colorHover NOTIFY colorSettingChange DESIGNABLE true SCRIPTABLE true)
76 Q_PROPERTY(QColor echoInvalid MEMBER m_colorInvalid NOTIFY colorSettingChange DESIGNABLE true SCRIPTABLE true)
77
78public:
79 enum EchoState {Normal = 1, Hover, Invalid};
80
81public:
82 DShortcutEditLabel(QWidget * parent = 0);
83
84 void setEchoState(const EchoState state);
85
86Q_SIGNALS:
87 void colorSettingChange();
88
89private:
90 void enterEvent(QEvent *);
91 void leaveEvent(QEvent *);
92
93private:
94 QColor m_colorNormal;
95 QColor m_colorHover;
96 QColor m_colorInvalid;
97
98 EchoState m_state = Normal;
99};
100
101DWIDGET_END_NAMESPACE
102
103#endif // DSHORTCUTEDIT_H
Definition dshortcutedit.h:72