Debian Codegraph @

qt6/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 "fcitx5qt6widgetsaddons_export.h"
50
51 namespace fcitx {
52
53 class FcitxQtKeySequenceWidgetPrivate;
54
55 class FCITX5QT6WIDGETSADDONS_EXPORT FcitxQtKeySequenceWidget : public QWidget {
56 Q_OBJECT
57
58 Q_PROPERTY(bool multiKeyShortcutsAllowed READ multiKeyShortcutsAllowed WRITE
59 setMultiKeyShortcutsAllowed)
60
61 Q_PROPERTY(bool modifierlessAllowed READ isModifierlessAllowed WRITE
62 setModifierlessAllowed)
63
64 Q_PROPERTY(
65 bool modifierAllowed READ isModifierAllowed WRITE setModifierAllowed)
66
67 Q_PROPERTY(
68 bool keycodeAllowed READ isKeycodeAllowed WRITE setKeycodeAllowed)
69
70 Q_PROPERTY(bool modifierOnlyAllowed READ isModifierOnlyAllowed WRITE
71 setModifierOnlyAllowed)
72
73 public:
74 /**
75 * Constructor.
76 */
77 explicit FcitxQtKeySequenceWidget(QWidget *parent = 0);
78
79 /**
80 * Destructs the widget.
81 */
82 virtual ~FcitxQtKeySequenceWidget();
83
84 /**
85 * @brief Set whether allow multiple shortcuts.
86 *
87 * @param allow
88 */
89 void setMultiKeyShortcutsAllowed(bool allow);
90 bool multiKeyShortcutsAllowed() const;
91
92 /**
93 * @brief Set whether allow modifier less that produce text, such as just
94 * key A.
95 *
96 * @param allow
97 */
98 void setModifierlessAllowed(bool allow);
99 // FIXME: remove this
100 bool isModifierlessAllowed();
101 bool isModifierlessAllowed() const;
102
103 /**
104 * @brief Set whether allow key that has modifier.
105 *
106 * @param allow
107 * @since 5.0.12
108 */
109 void setModifierAllowed(bool allow);
110 bool isModifierAllowed() const;
111
112 /**
113 * @brief Set whether allow key to use key code.
114 *
115 * @param allow
116 * @since 5.0.12
117 */
118 void setKeycodeAllowed(bool allow);
119 bool isKeycodeAllowed() const;
120
121 /**
122 * @brief Set whether allow modifier only key, such as only left control.
123 *
124 * @param allow allow modifier only key to be captured.
125 */
126 void setModifierOnlyAllowed(bool allow);
127 // FIXME: remove this
128 bool isModifierOnlyAllowed();
129 bool isModifierOnlyAllowed() const;
130
131 void setClearButtonShown(bool show);
132 bool isClearButtonVisible() const;
133
134 const QList<Key> &keySequence() const;
135
136 Q_SIGNALS:
137 void keySequenceChanged(const QList<Key> &seq);
138
139 public Q_SLOTS:
140 void captureKeySequence();
141 void setKeySequence(const QList<Key> &seq);
142 void clearKeySequence();
143
144 private:
145 friend class FcitxQtKeySequenceWidgetPrivate;
146 FcitxQtKeySequenceWidgetPrivate *const d;
147
148 Q_DISABLE_COPY(FcitxQtKeySequenceWidget)
149 };
150 } // namespace fcitx
151
152 #endif // _WIDGETSADDONS_FCITXQTKEYSEQUENCEWIDGET_H_