Debian Codegraph @

qt5/widgetsaddons/fcitxqtkeysequencewidget.h

raw
1 /*
2 * SPDX-FileCopyrightText: 2013~2017 CSSlayer <[email protected]>
3 *
4 * This library is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; see the file COPYING. If not,
16 * see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef _WIDGETSADDONS_FCITXQTKEYSEQUENCEWIDGET_H_
19 #define _WIDGETSADDONS_FCITXQTKEYSEQUENCEWIDGET_H_
20
21 /* this is forked from kdelibs/kdeui/kkeysequencewidget.h */
22
23 /*
24 Original Copyright header
25 This file is part of the KDE libraries
26 SPDX-FileCopyrightText: 2001, 2002 Ellis Whitehead <[email protected]>
27 SPDX-FileCopyrightText: 2007 Andreas Hartmetz <[email protected]>
28
29 This library is free software; you can redistribute it and/or
30 modify it under the terms of the GNU Library General Public
31 License as published by the Free Software Foundation; either
32 version 2 of the License, or (at your option) any later version.
33
34 This library is distributed in the hope that it will be useful,
35 but WITHOUT ANY WARRANTY; without even the implied warranty of
36 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
37 Library General Public License for more details.
38
39 You should have received a copy of the GNU Library General Public License
40 along with this library; see the file COPYING.LIB. If not, write to
41 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
42 Boston, MA 02110-1301, USA.
43 */
44
45 #include <QList>
46 #include <QPushButton>
47 #include <fcitx-utils/key.h>
48
49 #include "fcitx5qt5widgetsaddons_export.h"
50
51 namespace fcitx {
52
53 enum FcitxQtModifierSide { MS_Unknown = 0, MS_Left = 1, MS_Right = 2 };
54
55 class FcitxQtKeySequenceWidgetPrivate;
56
57 class FCITX5QT5WIDGETSADDONS_EXPORT FcitxQtKeySequenceWidget : public QWidget {
58 Q_OBJECT
59
60 Q_PROPERTY(bool multiKeyShortcutsAllowed READ multiKeyShortcutsAllowed WRITE
61 setMultiKeyShortcutsAllowed)
62
63 Q_PROPERTY(bool modifierlessAllowed READ isModifierlessAllowed WRITE
64 setModifierlessAllowed)
65
66 Q_PROPERTY(
67 bool modifierAllowed READ isModifierAllowed WRITE setModifierAllowed)
68
69 Q_PROPERTY(
70 bool keycodeAllowed READ isKeycodeAllowed WRITE setKeycodeAllowed)
71
72 Q_PROPERTY(bool modifierOnlyAllowed READ isModifierOnlyAllowed WRITE
73 setModifierOnlyAllowed)
74
75 public:
76 /**
77 * Constructor.
78 */
79 explicit FcitxQtKeySequenceWidget(QWidget *parent = 0);
80
81 /**
82 * Destructs the widget.
83 */
84 virtual ~FcitxQtKeySequenceWidget();
85
86 /**
87 * @brief Set whether allow multiple shortcuts.
88 *
89 * @param allow
90 */
91 void setMultiKeyShortcutsAllowed(bool allow);
92 bool multiKeyShortcutsAllowed() const;
93
94 /**
95 * @brief Set whether allow modifier less that produce text, such as just
96 * key A.
97 *
98 * @param allow
99 */
100 void setModifierlessAllowed(bool allow);
101 // FIXME: remove this
102 bool isModifierlessAllowed();
103 bool isModifierlessAllowed() const;
104
105 /**
106 * @brief Set whether allow key that has modifier.
107 *
108 * @param allow
109 * @since 5.0.12
110 */
111 void setModifierAllowed(bool allow);
112 bool isModifierAllowed() const;
113
114 /**
115 * @brief Set whether allow key to use key code.
116 *
117 * @param allow
118 * @since 5.0.12
119 */
120 void setKeycodeAllowed(bool allow);
121 bool isKeycodeAllowed() const;
122
123 /**
124 * @brief Set whether allow modifier only key, such as only left control.
125 *
126 * @param allow allow modifier only key to be captured.
127 */
128 void setModifierOnlyAllowed(bool allow);
129 // FIXME: remove this
130 bool isModifierOnlyAllowed();
131 bool isModifierOnlyAllowed() const;
132
133 void setClearButtonShown(bool show);
134 bool isClearButtonVisible() const;
135
136 const QList<Key> &keySequence() const;
137
138 Q_SIGNALS:
139 void keySequenceChanged(const QList<Key> &seq);
140
141 public Q_SLOTS:
142 void captureKeySequence();
143 void setKeySequence(const QList<Key> &seq);
144 void clearKeySequence();
145
146 private:
147 friend class FcitxQtKeySequenceWidgetPrivate;
148 FcitxQtKeySequenceWidgetPrivate *const d;
149
150 Q_DISABLE_COPY(FcitxQtKeySequenceWidget)
151 };
152 } // namespace fcitx
153
154 #endif // _WIDGETSADDONS_FCITXQTKEYSEQUENCEWIDGET_H_