/src/qtbase/src/gui/kernel/qkeysequence.h
Line | Count | Source |
1 | | // Copyright (C) 2016 The Qt Company Ltd. |
2 | | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | | // Qt-Security score:significant reason:default |
4 | | |
5 | | #ifndef QKEYSEQUENCE_H |
6 | | #define QKEYSEQUENCE_H |
7 | | |
8 | | #include <QtGui/qtguiglobal.h> |
9 | | #include <QtCore/qstring.h> |
10 | | #include <QtCore/qobjectdefs.h> |
11 | | |
12 | | QT_REQUIRE_CONFIG(shortcut); |
13 | | |
14 | | QT_BEGIN_NAMESPACE |
15 | | |
16 | | class QKeySequence; |
17 | | |
18 | | /***************************************************************************** |
19 | | QKeySequence stream functions |
20 | | *****************************************************************************/ |
21 | | #if !defined(QT_NO_DATASTREAM) || defined(Q_QDOC) |
22 | | Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks); |
23 | | Q_GUI_EXPORT QDataStream &operator>>(QDataStream &out, QKeySequence &ks); |
24 | | #endif |
25 | | |
26 | | #if defined(Q_QDOC) |
27 | | void qt_set_sequence_auto_mnemonic(bool b); |
28 | | #endif |
29 | | |
30 | | class QVariant; |
31 | | class QKeySequencePrivate; |
32 | | |
33 | | Q_GUI_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(const QKeySequence &key, size_t seed = 0) noexcept; |
34 | | |
35 | | class Q_GUI_EXPORT QKeySequence |
36 | | { |
37 | | Q_GADGET |
38 | | |
39 | | public: |
40 | | enum StandardKey { |
41 | | UnknownKey, |
42 | | HelpContents, |
43 | | WhatsThis, |
44 | | Open, |
45 | | Close, |
46 | | Save, |
47 | | New, |
48 | | Delete, |
49 | | Cut, |
50 | | Copy, |
51 | | Paste, |
52 | | Undo, |
53 | | Redo, |
54 | | Back, |
55 | | Forward, |
56 | | Refresh, |
57 | | ZoomIn, |
58 | | ZoomOut, |
59 | | Print, |
60 | | AddTab, |
61 | | NextChild, |
62 | | PreviousChild, |
63 | | Find, |
64 | | FindNext, |
65 | | FindPrevious, |
66 | | Replace, |
67 | | SelectAll, |
68 | | Bold, |
69 | | Italic, |
70 | | Underline, |
71 | | MoveToNextChar, |
72 | | MoveToPreviousChar, |
73 | | MoveToNextWord, |
74 | | MoveToPreviousWord, |
75 | | MoveToNextLine, |
76 | | MoveToPreviousLine, |
77 | | MoveToNextPage, |
78 | | MoveToPreviousPage, |
79 | | MoveToStartOfLine, |
80 | | MoveToEndOfLine, |
81 | | MoveToStartOfBlock, |
82 | | MoveToEndOfBlock, |
83 | | MoveToStartOfDocument, |
84 | | MoveToEndOfDocument, |
85 | | SelectNextChar, |
86 | | SelectPreviousChar, |
87 | | SelectNextWord, |
88 | | SelectPreviousWord, |
89 | | SelectNextLine, |
90 | | SelectPreviousLine, |
91 | | SelectNextPage, |
92 | | SelectPreviousPage, |
93 | | SelectStartOfLine, |
94 | | SelectEndOfLine, |
95 | | SelectStartOfBlock, |
96 | | SelectEndOfBlock, |
97 | | SelectStartOfDocument, |
98 | | SelectEndOfDocument, |
99 | | DeleteStartOfWord, |
100 | | DeleteEndOfWord, |
101 | | DeleteEndOfLine, |
102 | | InsertParagraphSeparator, |
103 | | InsertLineSeparator, |
104 | | SaveAs, |
105 | | Preferences, |
106 | | Quit, |
107 | | FullScreen, |
108 | | Deselect, |
109 | | DeleteCompleteLine, |
110 | | Backspace, |
111 | | Cancel |
112 | | }; |
113 | | Q_ENUM(StandardKey) |
114 | | |
115 | | enum SequenceFormat { |
116 | | NativeText, |
117 | | PortableText |
118 | | }; |
119 | | Q_ENUM(SequenceFormat) |
120 | | |
121 | | QKeySequence(); |
122 | | QKeySequence(const QString &key, SequenceFormat format = NativeText); |
123 | | QKeySequence(int k1, int k2 = 0, int k3 = 0, int k4 = 0); |
124 | | QKeySequence(QKeyCombination k1, |
125 | | QKeyCombination k2 = QKeyCombination::fromCombined(0), |
126 | | QKeyCombination k3 = QKeyCombination::fromCombined(0), |
127 | | QKeyCombination k4 = QKeyCombination::fromCombined(0)); |
128 | | QKeySequence(const QKeySequence &ks); |
129 | | QKeySequence(StandardKey key); |
130 | | ~QKeySequence(); |
131 | | |
132 | | int count() const; |
133 | | bool isEmpty() const; |
134 | | |
135 | | enum SequenceMatch { |
136 | | NoMatch, |
137 | | PartialMatch, |
138 | | ExactMatch |
139 | | }; |
140 | | Q_ENUM(SequenceMatch) |
141 | | |
142 | | QString toString(SequenceFormat format = PortableText) const; |
143 | | static QKeySequence fromString(const QString &str, SequenceFormat format = PortableText); |
144 | | |
145 | | static QList<QKeySequence> listFromString(const QString &str, SequenceFormat format = PortableText); |
146 | | static QString listToString(const QList<QKeySequence> &list, SequenceFormat format = PortableText); |
147 | | |
148 | | SequenceMatch matches(const QKeySequence &seq) const; |
149 | | static QKeySequence mnemonic(const QString &text); |
150 | | static QList<QKeySequence> keyBindings(StandardKey key); |
151 | | |
152 | | operator QVariant() const; |
153 | | QKeyCombination operator[](uint i) const; |
154 | | QKeySequence &operator=(const QKeySequence &other); |
155 | | QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QKeySequence) |
156 | 0 | void swap(QKeySequence &other) noexcept { qt_ptr_swap(d, other.d); } |
157 | | |
158 | | bool operator==(const QKeySequence &other) const; |
159 | | inline bool operator!= (const QKeySequence &other) const |
160 | 0 | { return !(*this == other); } |
161 | | bool operator< (const QKeySequence &ks) const; |
162 | | inline bool operator> (const QKeySequence &other) const |
163 | 0 | { return other < *this; } |
164 | | inline bool operator<= (const QKeySequence &other) const |
165 | 0 | { return !(other < *this); } |
166 | | inline bool operator>= (const QKeySequence &other) const |
167 | 0 | { return !(*this < other); } |
168 | | |
169 | | bool isDetached() const; |
170 | | private: |
171 | | int assign(const QString &str); |
172 | | int assign(const QString &str, SequenceFormat format); |
173 | | void setKey(QKeyCombination key, int index); |
174 | | |
175 | | QKeySequencePrivate *d; |
176 | | |
177 | | friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks); |
178 | | friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QKeySequence &ks); |
179 | | friend Q_GUI_EXPORT size_t qHash(const QKeySequence &key, size_t seed) noexcept; |
180 | | friend class QShortcutMap; |
181 | | friend class QShortcut; |
182 | | |
183 | | public: |
184 | | typedef QKeySequencePrivate * DataPtr; |
185 | 0 | inline DataPtr &data_ptr() { return d; } |
186 | | }; |
187 | | |
188 | | Q_DECLARE_SHARED(QKeySequence) |
189 | | |
190 | | #if !defined(QT_NO_DEBUG_STREAM) || defined(Q_QDOC) |
191 | | Q_GUI_EXPORT QDebug operator<<(QDebug, const QKeySequence &); |
192 | | #endif |
193 | | |
194 | | QT_END_NAMESPACE |
195 | | |
196 | | #endif // QKEYSEQUENCE_H |