qkeysequence.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qkeysequence.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtGui module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qkeysequence.h"-
41#include "qkeysequence_p.h"-
42#include <qpa/qplatformtheme.h>-
43#include "private/qguiapplication_p.h"-
44-
45#ifndef QT_NO_SHORTCUT-
46-
47#include "qdebug.h"-
48#include <QtCore/qhashfunctions.h>-
49#ifndef QT_NO_REGEXP-
50# include "qregexp.h"-
51#endif-
52#ifndef QT_NO_DATASTREAM-
53# include "qdatastream.h"-
54#endif-
55#include "qvariant.h"-
56-
57#if defined(Q_OS_MACX)-
58#include <QtCore/private/qcore_mac_p.h>-
59#include <Carbon/Carbon.h>-
60#endif-
61-
62#include <algorithm>-
63-
64QT_BEGIN_NAMESPACE-
65-
66#if defined(Q_OS_MACX)-
67static bool qt_sequence_no_mnemonics = true;-
68struct MacSpecialKey {-
69 int key;-
70 ushort macSymbol;-
71};-
72-
73static const int NumEntries = 21;-
74static const MacSpecialKey entries[NumEntries] = {-
75 { Qt::Key_Escape, 0x238B },-
76 { Qt::Key_Tab, 0x21E5 },-
77 { Qt::Key_Backtab, 0x21E4 },-
78 { Qt::Key_Backspace, 0x232B },-
79 { Qt::Key_Return, 0x21B5 },-
80 { Qt::Key_Enter, 0x2324 },-
81 { Qt::Key_Delete, 0x2326 },-
82 { Qt::Key_Home, 0x2196 },-
83 { Qt::Key_End, 0x2198 },-
84 { Qt::Key_Left, 0x2190 },-
85 { Qt::Key_Up, 0x2191 },-
86 { Qt::Key_Right, 0x2192 },-
87 { Qt::Key_Down, 0x2193 },-
88 { Qt::Key_PageUp, 0x21DE },-
89 { Qt::Key_PageDown, 0x21DF },-
90 { Qt::Key_Shift, kShiftUnicode },-
91 { Qt::Key_Control, kCommandUnicode },-
92 { Qt::Key_Meta, kControlUnicode },-
93 { Qt::Key_Alt, kOptionUnicode },-
94 { Qt::Key_CapsLock, 0x21EA },-
95};-
96-
97static bool operator<(const MacSpecialKey &entry, int key)-
98{-
99 return entry.key < key;-
100}-
101-
102static bool operator<(int key, const MacSpecialKey &entry)-
103{-
104 return key < entry.key;-
105}-
106-
107static const MacSpecialKey * const MacSpecialKeyEntriesEnd = entries + NumEntries;-
108-
109QChar qt_macSymbolForQtKey(int key)-
110{-
111 const MacSpecialKey *i = std::lower_bound(entries, MacSpecialKeyEntriesEnd, key);-
112 if ((i == MacSpecialKeyEntriesEnd) || (key < *i))-
113 return QChar();-
114 ushort macSymbol = i->macSymbol;-
115 if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)-
116 && (macSymbol == kControlUnicode || macSymbol == kCommandUnicode)) {-
117 if (macSymbol == kControlUnicode)-
118 macSymbol = kCommandUnicode;-
119 else-
120 macSymbol = kControlUnicode;-
121 }-
122-
123 return QChar(macSymbol);-
124}-
125-
126static int qtkeyForMacSymbol(const QChar ch)-
127{-
128 const ushort unicode = ch.unicode();-
129 for (int i = 0; i < NumEntries; ++i) {-
130 const MacSpecialKey &entry = entries[i];-
131 if (entry.macSymbol == unicode) {-
132 int key = entry.key;-
133 if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)-
134 && (unicode == kControlUnicode || unicode == kCommandUnicode)) {-
135 if (unicode == kControlUnicode)-
136 key = Qt::Key_Control;-
137 else-
138 key = Qt::Key_Meta;-
139 }-
140 return key;-
141 }-
142 }-
143 return -1;-
144}-
145-
146#else-
147static bool qt_sequence_no_mnemonics = false;-
148#endif-
149-
150/*!-
151 \fn void qt_set_sequence_auto_mnemonic(bool b)-
152 \relates QKeySequence-
153-
154 Specifies whether mnemonics for menu items, labels, etc., should-
155 be honored or not. On Windows and X11, this feature is-
156 on by default; on \macos, it is off. When this feature is off-
157 (that is, when \a b is false), QKeySequence::mnemonic() always-
158 returns an empty string.-
159-
160 \note This function is not declared in any of Qt's header files.-
161 To use it in your application, declare the function prototype-
162 before calling it.-
163-
164 \sa QShortcut-
165*/-
166void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b) { qt_sequence_no_mnemonics = !b; }
never executed: end of block
0
167-
168/*!-
169 \class QKeySequence-
170 \brief The QKeySequence class encapsulates a key sequence as used-
171 by shortcuts.-
172-
173 \ingroup shared-
174 \inmodule QtGui-
175-
176-
177 In its most common form, a key sequence describes a combination of-
178 keys that must be used together to perform some action. Key sequences-
179 are used with QAction objects to specify which keyboard shortcuts can-
180 be used to trigger actions.-
181-
182 Key sequences can be constructed for use as keyboard shortcuts in-
183 three different ways:-
184-
185 \list-
186 \li For standard shortcuts, a \l{QKeySequence::StandardKey}{standard key}-
187 can be used to request the platform-specific key sequence associated-
188 with each shortcut.-
189 \li For custom shortcuts, human-readable strings such as "Ctrl+X" can-
190 be used, and these can be translated into the appropriate shortcuts-
191 for users of different languages. Translations are made in the-
192 "QShortcut" context.-
193 \li For hard-coded shortcuts, integer key codes can be specified with-
194 a combination of values defined by the Qt::Key and Qt::Modifier enum-
195 values. Each key code consists of a single Qt::Key value and zero or-
196 more modifiers, such as Qt::SHIFT, Qt::CTRL, Qt::ALT and Qt::META.-
197 \endlist-
198-
199 For example, \uicontrol{Ctrl P} might be a sequence used as a shortcut for-
200 printing a document, and can be specified in any of the following-
201 ways:-
202-
203 \snippet code/src_gui_kernel_qkeysequence.cpp 0-
204-
205 Note that, for letters, the case used in the specification string-
206 does not matter. In the above examples, the user does not need to-
207 hold down the \uicontrol{Shift} key to activate a shortcut specified-
208 with "Ctrl+P". However, for other keys, the use of \uicontrol{Shift} as-
209 an unspecified extra modifier key can lead to confusion for users-
210 of an application whose keyboards have different layouts to those-
211 used by the developers. See the \l{Keyboard Layout Issues} section-
212 below for more details.-
213-
214 It is preferable to use standard shortcuts where possible.-
215 When creating key sequences for non-standard shortcuts, you should use-
216 human-readable strings in preference to hard-coded integer values.-
217-
218 QKeySequence objects can be cast to a QString to obtain a human-readable-
219 translated version of the sequence. Similarly, the toString() function-
220 produces human-readable strings for use in menus. On \macos, the-
221 appropriate symbols are used to describe keyboard shortcuts using special-
222 keys on the Macintosh keyboard.-
223-
224 An alternative way to specify hard-coded key codes is to use the Unicode-
225 code point of the character; for example, 'A' gives the same key sequence-
226 as Qt::Key_A.-
227-
228 \note On \macos, references to "Ctrl", Qt::CTRL, Qt::Key_Control-
229 and Qt::ControlModifier correspond to the \uicontrol Command keys on the-
230 Macintosh keyboard, and references to "Meta", Qt::META, Qt::Key_Meta and-
231 Qt::MetaModifier correspond to the \uicontrol Control keys. Developers on-
232 \macos can use the same shortcut descriptions across all platforms,-
233 and their applications will automatically work as expected on \macos.-
234-
235 \section1 Standard Shortcuts-
236-
237 QKeySequence defines many \l{QKeySequence::StandardKey} {standard-
238 keyboard shortcuts} to reduce the amount of effort required when-
239 setting up actions in a typical application. The table below shows-
240 some common key sequences that are often used for these standard-
241 shortcuts by applications on four widely-used platforms. Note-
242 that on \macos, the \uicontrol Ctrl value corresponds to the \uicontrol-
243 Command keys on the Macintosh keyboard, and the \uicontrol Meta value-
244 corresponds to the \uicontrol Control keys.-
245-
246 \table-
247 \header \li StandardKey \li Windows \li \macos \li KDE \li GNOME-
248 \row \li HelpContents \li F1 \li Ctrl+? \li F1 \li F1-
249 \row \li WhatsThis \li Shift+F1 \li Shift+F1 \li Shift+F1 \li Shift+F1-
250 \row \li Open \li Ctrl+O \li Ctrl+O \li Ctrl+O \li Ctrl+O-
251 \row \li Close \li Ctrl+F4, Ctrl+W \li Ctrl+W, Ctrl+F4 \li Ctrl+W \li Ctrl+W-
252 \row \li Save \li Ctrl+S \li Ctrl+S \li Ctrl+S \li Ctrl+S-
253 \row \li Quit \li \li Ctrl+Q \li Ctrl+Q \li Ctrl+Q-
254 \row \li SaveAs \li \li Ctrl+Shift+S \li \li Ctrl+Shift+S-
255 \row \li New \li Ctrl+N \li Ctrl+N \li Ctrl+N \li Ctrl+N-
256 \row \li Delete \li Del \li Del, Meta+D \li Del, Ctrl+D \li Del, Ctrl+D-
257 \row \li Cut \li Ctrl+X, Shift+Del \li Ctrl+X, Meta+K \li Ctrl+X, F20, Shift+Del \li Ctrl+X, F20, Shift+Del-
258 \row \li Copy \li Ctrl+C, Ctrl+Ins \li Ctrl+C \li Ctrl+C, F16, Ctrl+Ins \li Ctrl+C, F16, Ctrl+Ins-
259 \row \li Paste \li Ctrl+V, Shift+Ins \li Ctrl+V, Meta+Y \li Ctrl+V, F18, Shift+Ins \li Ctrl+V, F18, Shift+Ins-
260 \row \li Preferences \li \li Ctrl+, \li \li-
261 \row \li Undo \li Ctrl+Z, Alt+Backspace \li Ctrl+Z \li Ctrl+Z, F14 \li Ctrl+Z, F14-
262 \row \li Redo \li Ctrl+Y, Shift+Ctrl+Z, Alt+Shift+Backspace \li Ctrl+Shift+Z \li Ctrl+Shift+Z \li Ctrl+Shift+Z-
263 \row \li Back \li Alt+Left, Backspace \li Ctrl+[ \li Alt+Left \li Alt+Left-
264 \row \li Forward \li Alt+Right, Shift+Backspace \li Ctrl+] \li Alt+Right \li Alt+Right-
265 \row \li Refresh \li F5 \li F5 \li F5 \li Ctrl+R, F5-
266 \row \li ZoomIn \li Ctrl+Plus \li Ctrl+Plus \li Ctrl+Plus \li Ctrl+Plus-
267 \row \li ZoomOut \li Ctrl+Minus \li Ctrl+Minus \li Ctrl+Minus \li Ctrl+Minus-
268 \row \li FullScreen \li F11, Alt+Enter \li Ctrl+Meta+F \li F11, Ctrl+Shift+F \li Ctrl+F11-
269 \row \li Print \li Ctrl+P \li Ctrl+P \li Ctrl+P \li Ctrl+P-
270 \row \li AddTab \li Ctrl+T \li Ctrl+T \li Ctrl+Shift+N, Ctrl+T \li Ctrl+T-
271 \row \li NextChild \li Ctrl+Tab, Forward, Ctrl+F6 \li Ctrl+}, Forward, Ctrl+Tab \li Ctrl+Tab, Forward, Ctrl+Comma \li Ctrl+Tab, Forward-
272 \row \li PreviousChild \li Ctrl+Shift+Tab, Back, Ctrl+Shift+F6 \li Ctrl+{, Back, Ctrl+Shift+Tab \li Ctrl+Shift+Tab, Back, Ctrl+Period \li Ctrl+Shift+Tab, Back-
273 \row \li Find \li Ctrl+F \li Ctrl+F \li Ctrl+F \li Ctrl+F-
274 \row \li FindNext \li F3, Ctrl+G \li Ctrl+G \li F3 \li Ctrl+G, F3-
275 \row \li FindPrevious \li Shift+F3, Ctrl+Shift+G \li Ctrl+Shift+G \li Shift+F3 \li Ctrl+Shift+G, Shift+F3-
276 \row \li Replace \li Ctrl+H \li (none) \li Ctrl+R \li Ctrl+H-
277 \row \li SelectAll \li Ctrl+A \li Ctrl+A \li Ctrl+A \li Ctrl+A-
278 \row \li Deselect \li \li \li Ctrl+Shift+A \li Ctrl+Shift+A-
279 \row \li Bold \li Ctrl+B \li Ctrl+B \li Ctrl+B \li Ctrl+B-
280 \row \li Italic \li Ctrl+I \li Ctrl+I \li Ctrl+I \li Ctrl+I-
281 \row \li Underline \li Ctrl+U \li Ctrl+U \li Ctrl+U \li Ctrl+U-
282 \row \li MoveToNextChar \li Right \li Right, Meta+F \li Right \li Right-
283 \row \li MoveToPreviousChar \li Left \li Left, Meta+B \li Left \li Left-
284 \row \li MoveToNextWord \li Ctrl+Right \li Alt+Right \li Ctrl+Right \li Ctrl+Right-
285 \row \li MoveToPreviousWord \li Ctrl+Left \li Alt+Left \li Ctrl+Left \li Ctrl+Left-
286 \row \li MoveToNextLine \li Down \li Down, Meta+N \li Down \li Down-
287 \row \li MoveToPreviousLine \li Up \li Up, Meta+P \li Up \li Up-
288 \row \li MoveToNextPage \li PgDown \li PgDown, Alt+PgDown, Meta+Down, Meta+PgDown, Meta+V \li PgDown \li PgDown-
289 \row \li MoveToPreviousPage \li PgUp \li PgUp, Alt+PgUp, Meta+Up, Meta+PgUp \li PgUp \li PgUp-
290 \row \li MoveToStartOfLine \li Home \li Ctrl+Left, Meta+Left \li Home \li Home-
291 \row \li MoveToEndOfLine \li End \li Ctrl+Right, Meta+Right \li End, Ctrl+E \li End, Ctrl+E-
292 \row \li MoveToStartOfBlock \li (none) \li Alt+Up, Meta+A \li (none) \li (none)-
293 \row \li MoveToEndOfBlock \li (none) \li Alt+Down, Meta+E \li (none) \li (none)-
294 \row \li MoveToStartOfDocument\li Ctrl+Home \li Ctrl+Up, Home \li Ctrl+Home \li Ctrl+Home-
295 \row \li MoveToEndOfDocument \li Ctrl+End \li Ctrl+Down, End \li Ctrl+End \li Ctrl+End-
296 \row \li SelectNextChar \li Shift+Right \li Shift+Right \li Shift+Right \li Shift+Right-
297 \row \li SelectPreviousChar \li Shift+Left \li Shift+Left \li Shift+Left \li Shift+Left-
298 \row \li SelectNextWord \li Ctrl+Shift+Right \li Alt+Shift+Right \li Ctrl+Shift+Right \li Ctrl+Shift+Right-
299 \row \li SelectPreviousWord \li Ctrl+Shift+Left \li Alt+Shift+Left \li Ctrl+Shift+Left \li Ctrl+Shift+Left-
300 \row \li SelectNextLine \li Shift+Down \li Shift+Down \li Shift+Down \li Shift+Down-
301 \row \li SelectPreviousLine \li Shift+Up \li Shift+Up \li Shift+Up \li Shift+Up-
302 \row \li SelectNextPage \li Shift+PgDown \li Shift+PgDown \li Shift+PgDown \li Shift+PgDown-
303 \row \li SelectPreviousPage \li Shift+PgUp \li Shift+PgUp \li Shift+PgUp \li Shift+PgUp-
304 \row \li SelectStartOfLine \li Shift+Home \li Ctrl+Shift+Left \li Shift+Home \li Shift+Home-
305 \row \li SelectEndOfLine \li Shift+End \li Ctrl+Shift+Right \li Shift+End \li Shift+End-
306 \row \li SelectStartOfBlock \li (none) \li Alt+Shift+Up, Meta+Shift+A \li (none) \li (none)-
307 \row \li SelectEndOfBlock \li (none) \li Alt+Shift+Down, Meta+Shift+E \li (none) \li (none)-
308 \row \li SelectStartOfDocument\li Ctrl+Shift+Home \li Ctrl+Shift+Up, Shift+Home \li Ctrl+Shift+Home\li Ctrl+Shift+Home-
309 \row \li SelectEndOfDocument \li Ctrl+Shift+End \li Ctrl+Shift+Down, Shift+End \li Ctrl+Shift+End \li Ctrl+Shift+End-
310 \row \li DeleteStartOfWord \li Ctrl+Backspace \li Alt+Backspace \li Ctrl+Backspace \li Ctrl+Backspace-
311 \row \li DeleteEndOfWord \li Ctrl+Del \li (none) \li Ctrl+Del \li Ctrl+Del-
312 \row \li DeleteEndOfLine \li (none) \li (none) \li Ctrl+K \li Ctrl+K-
313 \row \li DeleteCompleteLine \li (none) \li (none) \li Ctrl+U \li Ctrl+U-
314 \row \li InsertParagraphSeparator \li Enter \li Enter \li Enter \li Enter-
315 \row \li InsertLineSeparator \li Shift+Enter \li Meta+Enter, Meta+O \li Shift+Enter \li Shift+Enter-
316 \row \li Backspace \li (none) \li Meta+H \li (none) \li (none)-
317 \row \li Cancel \li Escape \li Escape, Ctrl+. \li Escape \li Escape-
318 \endtable-
319-
320 Note that, since the key sequences used for the standard shortcuts differ-
321 between platforms, you still need to test your shortcuts on each platform-
322 to ensure that you do not unintentionally assign the same key sequence to-
323 many actions.-
324-
325 \section1 Keyboard Layout Issues-
326-
327 Many key sequence specifications are chosen by developers based on the-
328 layout of certain types of keyboard, rather than choosing keys that-
329 represent the first letter of an action's name, such as \uicontrol{Ctrl S}-
330 ("Ctrl+S") or \uicontrol{Ctrl C} ("Ctrl+C").-
331 Additionally, because certain symbols can only be entered with the-
332 help of modifier keys on certain keyboard layouts, key sequences intended-
333 for use with one keyboard layout may map to a different key, map to no-
334 keys at all, or require an additional modifier key to be used on-
335 different keyboard layouts.-
336-
337 For example, the shortcuts, \uicontrol{Ctrl plus} and \uicontrol{Ctrl minus}, are often-
338 used as shortcuts for zoom operations in graphics applications, and these-
339 may be specified as "Ctrl++" and "Ctrl+-" respectively. However, the way-
340 these shortcuts are specified and interpreted depends on the keyboard layout.-
341 Users of Norwegian keyboards will note that the \uicontrol{+} and \uicontrol{-} keys-
342 are not adjacent on the keyboard, but will still be able to activate both-
343 shortcuts without needing to press the \uicontrol{Shift} key. However, users-
344 with British keyboards will need to hold down the \uicontrol{Shift} key-
345 to enter the \uicontrol{+} symbol, making the shortcut effectively the same as-
346 "Ctrl+Shift+=".-
347-
348 Although some developers might resort to fully specifying all the modifiers-
349 they use on their keyboards to activate a shortcut, this will also result-
350 in unexpected behavior for users of different keyboard layouts.-
351-
352 For example, a developer using a British keyboard may decide to specify-
353 "Ctrl+Shift+=" as the key sequence in order to create a shortcut that-
354 coincidentally behaves in the same way as \uicontrol{Ctrl plus}. However, the-
355 \uicontrol{=} key needs to be accessed using the \uicontrol{Shift} key on Norwegian-
356 keyboard, making the required shortcut effectively \uicontrol{Ctrl Shift Shift =}-
357 (an impossible key combination).-
358-
359 As a result, both human-readable strings and hard-coded key codes-
360 can both be problematic to use when specifying a key sequence that-
361 can be used on a variety of different keyboard layouts. Only the-
362 use of \l{QKeySequence::StandardKey} {standard shortcuts}-
363 guarantees that the user will be able to use the shortcuts that-
364 the developer intended.-
365-
366 Despite this, we can address this issue by ensuring that human-readable-
367 strings are used, making it possible for translations of key sequences to-
368 be made for users of different languages. This approach will be successful-
369 for users whose keyboards have the most typical layout for the language-
370 they are using.-
371-
372 \section1 GNU Emacs Style Key Sequences-
373-
374 Key sequences similar to those used in \l{http://www.gnu.org/software/emacs/}{GNU Emacs}, allowing up to four-
375 key codes, can be created by using the multiple argument constructor,-
376 or by passing a human-readable string of comma-separated key sequences.-
377-
378 For example, the key sequence, \uicontrol{Ctrl X} followed by \uicontrol{Ctrl C}, can-
379 be specified using either of the following ways:-
380-
381 \snippet code/src_gui_kernel_qkeysequence.cpp 1-
382-
383 \warning A QApplication instance must have been constructed before a-
384 QKeySequence is created; otherwise, your application may crash.-
385-
386 \sa QShortcut-
387*/-
388-
389/*!-
390 \enum QKeySequence::SequenceMatch-
391-
392 \value NoMatch The key sequences are different; not even partially-
393 matching.-
394 \value PartialMatch The key sequences match partially, but are not-
395 the same.-
396 \value ExactMatch The key sequences are the same.-
397*/-
398-
399/*!-
400 \enum QKeySequence::SequenceFormat-
401-
402 \value NativeText The key sequence as a platform specific string.-
403 This means that it will be shown translated and on the Mac it will-
404 resemble a key sequence from the menu bar. This enum is best used when you-
405 want to display the string to the user.-
406-
407 \value PortableText The key sequence is given in a "portable" format,-
408 suitable for reading and writing to a file. In many cases, it will look-
409 similar to the native text on Windows and X11.-
410*/-
411-
412static const struct {-
413 int key;-
414 const char name[25];-
415} keyname[] = {-
416 //: This and all following "incomprehensible" strings in QShortcut context-
417 //: are key names. Please use the localized names appearing on actual-
418 //: keyboards or whatever is commonly used.-
419 { Qt::Key_Space, QT_TRANSLATE_NOOP("QShortcut", "Space") },-
420 { Qt::Key_Escape, QT_TRANSLATE_NOOP("QShortcut", "Esc") },-
421 { Qt::Key_Tab, QT_TRANSLATE_NOOP("QShortcut", "Tab") },-
422 { Qt::Key_Backtab, QT_TRANSLATE_NOOP("QShortcut", "Backtab") },-
423 { Qt::Key_Backspace, QT_TRANSLATE_NOOP("QShortcut", "Backspace") },-
424 { Qt::Key_Return, QT_TRANSLATE_NOOP("QShortcut", "Return") },-
425 { Qt::Key_Enter, QT_TRANSLATE_NOOP("QShortcut", "Enter") },-
426 { Qt::Key_Insert, QT_TRANSLATE_NOOP("QShortcut", "Ins") },-
427 { Qt::Key_Delete, QT_TRANSLATE_NOOP("QShortcut", "Del") },-
428 { Qt::Key_Pause, QT_TRANSLATE_NOOP("QShortcut", "Pause") },-
429 { Qt::Key_Print, QT_TRANSLATE_NOOP("QShortcut", "Print") },-
430 { Qt::Key_SysReq, QT_TRANSLATE_NOOP("QShortcut", "SysReq") },-
431 { Qt::Key_Home, QT_TRANSLATE_NOOP("QShortcut", "Home") },-
432 { Qt::Key_End, QT_TRANSLATE_NOOP("QShortcut", "End") },-
433 { Qt::Key_Left, QT_TRANSLATE_NOOP("QShortcut", "Left") },-
434 { Qt::Key_Up, QT_TRANSLATE_NOOP("QShortcut", "Up") },-
435 { Qt::Key_Right, QT_TRANSLATE_NOOP("QShortcut", "Right") },-
436 { Qt::Key_Down, QT_TRANSLATE_NOOP("QShortcut", "Down") },-
437 { Qt::Key_PageUp, QT_TRANSLATE_NOOP("QShortcut", "PgUp") },-
438 { Qt::Key_PageDown, QT_TRANSLATE_NOOP("QShortcut", "PgDown") },-
439 { Qt::Key_CapsLock, QT_TRANSLATE_NOOP("QShortcut", "CapsLock") },-
440 { Qt::Key_NumLock, QT_TRANSLATE_NOOP("QShortcut", "NumLock") },-
441 { Qt::Key_ScrollLock, QT_TRANSLATE_NOOP("QShortcut", "ScrollLock") },-
442 { Qt::Key_Menu, QT_TRANSLATE_NOOP("QShortcut", "Menu") },-
443 { Qt::Key_Help, QT_TRANSLATE_NOOP("QShortcut", "Help") },-
444-
445 // Special keys-
446 // Includes multimedia, launcher, lan keys ( bluetooth, wireless )-
447 // window navigation-
448 { Qt::Key_Back, QT_TRANSLATE_NOOP("QShortcut", "Back") },-
449 { Qt::Key_Forward, QT_TRANSLATE_NOOP("QShortcut", "Forward") },-
450 { Qt::Key_Stop, QT_TRANSLATE_NOOP("QShortcut", "Stop") },-
451 { Qt::Key_Refresh, QT_TRANSLATE_NOOP("QShortcut", "Refresh") },-
452 { Qt::Key_VolumeDown, QT_TRANSLATE_NOOP("QShortcut", "Volume Down") },-
453 { Qt::Key_VolumeMute, QT_TRANSLATE_NOOP("QShortcut", "Volume Mute") },-
454 { Qt::Key_VolumeUp, QT_TRANSLATE_NOOP("QShortcut", "Volume Up") },-
455 { Qt::Key_BassBoost, QT_TRANSLATE_NOOP("QShortcut", "Bass Boost") },-
456 { Qt::Key_BassUp, QT_TRANSLATE_NOOP("QShortcut", "Bass Up") },-
457 { Qt::Key_BassDown, QT_TRANSLATE_NOOP("QShortcut", "Bass Down") },-
458 { Qt::Key_TrebleUp, QT_TRANSLATE_NOOP("QShortcut", "Treble Up") },-
459 { Qt::Key_TrebleDown, QT_TRANSLATE_NOOP("QShortcut", "Treble Down") },-
460 { Qt::Key_MediaPlay, QT_TRANSLATE_NOOP("QShortcut", "Media Play") },-
461 { Qt::Key_MediaStop, QT_TRANSLATE_NOOP("QShortcut", "Media Stop") },-
462 { Qt::Key_MediaPrevious, QT_TRANSLATE_NOOP("QShortcut", "Media Previous") },-
463 { Qt::Key_MediaNext, QT_TRANSLATE_NOOP("QShortcut", "Media Next") },-
464 { Qt::Key_MediaRecord, QT_TRANSLATE_NOOP("QShortcut", "Media Record") },-
465 //: Media player pause button-
466 { Qt::Key_MediaPause, QT_TRANSLATE_NOOP("QShortcut", "Media Pause") },-
467 //: Media player button to toggle between playing and paused-
468 { Qt::Key_MediaTogglePlayPause, QT_TRANSLATE_NOOP("QShortcut", "Toggle Media Play/Pause") },-
469 { Qt::Key_HomePage, QT_TRANSLATE_NOOP("QShortcut", "Home Page") },-
470 { Qt::Key_Favorites, QT_TRANSLATE_NOOP("QShortcut", "Favorites") },-
471 { Qt::Key_Search, QT_TRANSLATE_NOOP("QShortcut", "Search") },-
472 { Qt::Key_Standby, QT_TRANSLATE_NOOP("QShortcut", "Standby") },-
473 { Qt::Key_OpenUrl, QT_TRANSLATE_NOOP("QShortcut", "Open URL") },-
474 { Qt::Key_LaunchMail, QT_TRANSLATE_NOOP("QShortcut", "Launch Mail") },-
475 { Qt::Key_LaunchMedia, QT_TRANSLATE_NOOP("QShortcut", "Launch Media") },-
476 { Qt::Key_Launch0, QT_TRANSLATE_NOOP("QShortcut", "Launch (0)") },-
477 { Qt::Key_Launch1, QT_TRANSLATE_NOOP("QShortcut", "Launch (1)") },-
478 { Qt::Key_Launch2, QT_TRANSLATE_NOOP("QShortcut", "Launch (2)") },-
479 { Qt::Key_Launch3, QT_TRANSLATE_NOOP("QShortcut", "Launch (3)") },-
480 { Qt::Key_Launch4, QT_TRANSLATE_NOOP("QShortcut", "Launch (4)") },-
481 { Qt::Key_Launch5, QT_TRANSLATE_NOOP("QShortcut", "Launch (5)") },-
482 { Qt::Key_Launch6, QT_TRANSLATE_NOOP("QShortcut", "Launch (6)") },-
483 { Qt::Key_Launch7, QT_TRANSLATE_NOOP("QShortcut", "Launch (7)") },-
484 { Qt::Key_Launch8, QT_TRANSLATE_NOOP("QShortcut", "Launch (8)") },-
485 { Qt::Key_Launch9, QT_TRANSLATE_NOOP("QShortcut", "Launch (9)") },-
486 { Qt::Key_LaunchA, QT_TRANSLATE_NOOP("QShortcut", "Launch (A)") },-
487 { Qt::Key_LaunchB, QT_TRANSLATE_NOOP("QShortcut", "Launch (B)") },-
488 { Qt::Key_LaunchC, QT_TRANSLATE_NOOP("QShortcut", "Launch (C)") },-
489 { Qt::Key_LaunchD, QT_TRANSLATE_NOOP("QShortcut", "Launch (D)") },-
490 { Qt::Key_LaunchE, QT_TRANSLATE_NOOP("QShortcut", "Launch (E)") },-
491 { Qt::Key_LaunchF, QT_TRANSLATE_NOOP("QShortcut", "Launch (F)") },-
492 { Qt::Key_MonBrightnessUp, QT_TRANSLATE_NOOP("QShortcut", "Monitor Brightness Up") },-
493 { Qt::Key_MonBrightnessDown, QT_TRANSLATE_NOOP("QShortcut", "Monitor Brightness Down") },-
494 { Qt::Key_KeyboardLightOnOff, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Light On/Off") },-
495 { Qt::Key_KeyboardBrightnessUp, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Brightness Up") },-
496 { Qt::Key_KeyboardBrightnessDown, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Brightness Down") },-
497 { Qt::Key_PowerOff, QT_TRANSLATE_NOOP("QShortcut", "Power Off") },-
498 { Qt::Key_WakeUp, QT_TRANSLATE_NOOP("QShortcut", "Wake Up") },-
499 { Qt::Key_Eject, QT_TRANSLATE_NOOP("QShortcut", "Eject") },-
500 { Qt::Key_ScreenSaver, QT_TRANSLATE_NOOP("QShortcut", "Screensaver") },-
501 { Qt::Key_WWW, QT_TRANSLATE_NOOP("QShortcut", "WWW") },-
502 { Qt::Key_Sleep, QT_TRANSLATE_NOOP("QShortcut", "Sleep") },-
503 { Qt::Key_LightBulb, QT_TRANSLATE_NOOP("QShortcut", "LightBulb") },-
504 { Qt::Key_Shop, QT_TRANSLATE_NOOP("QShortcut", "Shop") },-
505 { Qt::Key_History, QT_TRANSLATE_NOOP("QShortcut", "History") },-
506 { Qt::Key_AddFavorite, QT_TRANSLATE_NOOP("QShortcut", "Add Favorite") },-
507 { Qt::Key_HotLinks, QT_TRANSLATE_NOOP("QShortcut", "Hot Links") },-
508 { Qt::Key_BrightnessAdjust, QT_TRANSLATE_NOOP("QShortcut", "Adjust Brightness") },-
509 { Qt::Key_Finance, QT_TRANSLATE_NOOP("QShortcut", "Finance") },-
510 { Qt::Key_Community, QT_TRANSLATE_NOOP("QShortcut", "Community") },-
511 { Qt::Key_AudioRewind, QT_TRANSLATE_NOOP("QShortcut", "Media Rewind") },-
512 { Qt::Key_BackForward, QT_TRANSLATE_NOOP("QShortcut", "Back Forward") },-
513 { Qt::Key_ApplicationLeft, QT_TRANSLATE_NOOP("QShortcut", "Application Left") },-
514 { Qt::Key_ApplicationRight, QT_TRANSLATE_NOOP("QShortcut", "Application Right") },-
515 { Qt::Key_Book, QT_TRANSLATE_NOOP("QShortcut", "Book") },-
516 { Qt::Key_CD, QT_TRANSLATE_NOOP("QShortcut", "CD") },-
517 { Qt::Key_Calculator, QT_TRANSLATE_NOOP("QShortcut", "Calculator") },-
518 { Qt::Key_Clear, QT_TRANSLATE_NOOP("QShortcut", "Clear") },-
519 { Qt::Key_ClearGrab, QT_TRANSLATE_NOOP("QShortcut", "Clear Grab") },-
520 { Qt::Key_Close, QT_TRANSLATE_NOOP("QShortcut", "Close") },-
521 { Qt::Key_Copy, QT_TRANSLATE_NOOP("QShortcut", "Copy") },-
522 { Qt::Key_Cut, QT_TRANSLATE_NOOP("QShortcut", "Cut") },-
523 { Qt::Key_Display, QT_TRANSLATE_NOOP("QShortcut", "Display") },-
524 { Qt::Key_DOS, QT_TRANSLATE_NOOP("QShortcut", "DOS") },-
525 { Qt::Key_Documents, QT_TRANSLATE_NOOP("QShortcut", "Documents") },-
526 { Qt::Key_Excel, QT_TRANSLATE_NOOP("QShortcut", "Spreadsheet") },-
527 { Qt::Key_Explorer, QT_TRANSLATE_NOOP("QShortcut", "Browser") },-
528 { Qt::Key_Game, QT_TRANSLATE_NOOP("QShortcut", "Game") },-
529 { Qt::Key_Go, QT_TRANSLATE_NOOP("QShortcut", "Go") },-
530 { Qt::Key_iTouch, QT_TRANSLATE_NOOP("QShortcut", "iTouch") },-
531 { Qt::Key_LogOff, QT_TRANSLATE_NOOP("QShortcut", "Logoff") },-
532 { Qt::Key_Market, QT_TRANSLATE_NOOP("QShortcut", "Market") },-
533 { Qt::Key_Meeting, QT_TRANSLATE_NOOP("QShortcut", "Meeting") },-
534 { Qt::Key_MenuKB, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Menu") },-
535 { Qt::Key_MenuPB, QT_TRANSLATE_NOOP("QShortcut", "Menu PB") },-
536 { Qt::Key_MySites, QT_TRANSLATE_NOOP("QShortcut", "My Sites") },-
537 { Qt::Key_News, QT_TRANSLATE_NOOP("QShortcut", "News") },-
538 { Qt::Key_OfficeHome, QT_TRANSLATE_NOOP("QShortcut", "Home Office") },-
539 { Qt::Key_Option, QT_TRANSLATE_NOOP("QShortcut", "Option") },-
540 { Qt::Key_Paste, QT_TRANSLATE_NOOP("QShortcut", "Paste") },-
541 { Qt::Key_Phone, QT_TRANSLATE_NOOP("QShortcut", "Phone") },-
542 { Qt::Key_Reply, QT_TRANSLATE_NOOP("QShortcut", "Reply") },-
543 { Qt::Key_Reload, QT_TRANSLATE_NOOP("QShortcut", "Reload") },-
544 { Qt::Key_RotateWindows, QT_TRANSLATE_NOOP("QShortcut", "Rotate Windows") },-
545 { Qt::Key_RotationPB, QT_TRANSLATE_NOOP("QShortcut", "Rotation PB") },-
546 { Qt::Key_RotationKB, QT_TRANSLATE_NOOP("QShortcut", "Rotation KB") },-
547 { Qt::Key_Save, QT_TRANSLATE_NOOP("QShortcut", "Save") },-
548 { Qt::Key_Send, QT_TRANSLATE_NOOP("QShortcut", "Send") },-
549 { Qt::Key_Spell, QT_TRANSLATE_NOOP("QShortcut", "Spellchecker") },-
550 { Qt::Key_SplitScreen, QT_TRANSLATE_NOOP("QShortcut", "Split Screen") },-
551 { Qt::Key_Support, QT_TRANSLATE_NOOP("QShortcut", "Support") },-
552 { Qt::Key_TaskPane, QT_TRANSLATE_NOOP("QShortcut", "Task Panel") },-
553 { Qt::Key_Terminal, QT_TRANSLATE_NOOP("QShortcut", "Terminal") },-
554 { Qt::Key_Tools, QT_TRANSLATE_NOOP("QShortcut", "Tools") },-
555 { Qt::Key_Travel, QT_TRANSLATE_NOOP("QShortcut", "Travel") },-
556 { Qt::Key_Video, QT_TRANSLATE_NOOP("QShortcut", "Video") },-
557 { Qt::Key_Word, QT_TRANSLATE_NOOP("QShortcut", "Word Processor") },-
558 { Qt::Key_Xfer, QT_TRANSLATE_NOOP("QShortcut", "XFer") },-
559 { Qt::Key_ZoomIn, QT_TRANSLATE_NOOP("QShortcut", "Zoom In") },-
560 { Qt::Key_ZoomOut, QT_TRANSLATE_NOOP("QShortcut", "Zoom Out") },-
561 { Qt::Key_Away, QT_TRANSLATE_NOOP("QShortcut", "Away") },-
562 { Qt::Key_Messenger, QT_TRANSLATE_NOOP("QShortcut", "Messenger") },-
563 { Qt::Key_WebCam, QT_TRANSLATE_NOOP("QShortcut", "WebCam") },-
564 { Qt::Key_MailForward, QT_TRANSLATE_NOOP("QShortcut", "Mail Forward") },-
565 { Qt::Key_Pictures, QT_TRANSLATE_NOOP("QShortcut", "Pictures") },-
566 { Qt::Key_Music, QT_TRANSLATE_NOOP("QShortcut", "Music") },-
567 { Qt::Key_Battery, QT_TRANSLATE_NOOP("QShortcut", "Battery") },-
568 { Qt::Key_Bluetooth, QT_TRANSLATE_NOOP("QShortcut", "Bluetooth") },-
569 { Qt::Key_WLAN, QT_TRANSLATE_NOOP("QShortcut", "Wireless") },-
570 { Qt::Key_UWB, QT_TRANSLATE_NOOP("QShortcut", "Ultra Wide Band") },-
571 { Qt::Key_AudioForward, QT_TRANSLATE_NOOP("QShortcut", "Media Fast Forward") },-
572 { Qt::Key_AudioRepeat, QT_TRANSLATE_NOOP("QShortcut", "Audio Repeat") },-
573 { Qt::Key_AudioRandomPlay, QT_TRANSLATE_NOOP("QShortcut", "Audio Random Play") },-
574 { Qt::Key_Subtitle, QT_TRANSLATE_NOOP("QShortcut", "Subtitle") },-
575 { Qt::Key_AudioCycleTrack, QT_TRANSLATE_NOOP("QShortcut", "Audio Cycle Track") },-
576 { Qt::Key_Time, QT_TRANSLATE_NOOP("QShortcut", "Time") },-
577 { Qt::Key_Hibernate, QT_TRANSLATE_NOOP("QShortcut", "Hibernate") },-
578 { Qt::Key_View, QT_TRANSLATE_NOOP("QShortcut", "View") },-
579 { Qt::Key_TopMenu, QT_TRANSLATE_NOOP("QShortcut", "Top Menu") },-
580 { Qt::Key_PowerDown, QT_TRANSLATE_NOOP("QShortcut", "Power Down") },-
581 { Qt::Key_Suspend, QT_TRANSLATE_NOOP("QShortcut", "Suspend") },-
582-
583 { Qt::Key_MicMute, QT_TRANSLATE_NOOP("QShortcut", "Microphone Mute") },-
584-
585 { Qt::Key_Red, QT_TRANSLATE_NOOP("QShortcut", "Red") },-
586 { Qt::Key_Green, QT_TRANSLATE_NOOP("QShortcut", "Green") },-
587 { Qt::Key_Yellow, QT_TRANSLATE_NOOP("QShortcut", "Yellow") },-
588 { Qt::Key_Blue, QT_TRANSLATE_NOOP("QShortcut", "Blue") },-
589-
590 { Qt::Key_ChannelUp, QT_TRANSLATE_NOOP("QShortcut", "Channel Up") },-
591 { Qt::Key_ChannelDown, QT_TRANSLATE_NOOP("QShortcut", "Channel Down") },-
592-
593 { Qt::Key_Guide, QT_TRANSLATE_NOOP("QShortcut", "Guide") },-
594 { Qt::Key_Info, QT_TRANSLATE_NOOP("QShortcut", "Info") },-
595 { Qt::Key_Settings, QT_TRANSLATE_NOOP("QShortcut", "Settings") },-
596-
597 { Qt::Key_MicVolumeUp, QT_TRANSLATE_NOOP("QShortcut", "Microphone Volume Up") },-
598 { Qt::Key_MicVolumeDown, QT_TRANSLATE_NOOP("QShortcut", "Microphone Volume Down") },-
599-
600 { Qt::Key_New, QT_TRANSLATE_NOOP("QShortcut", "New") },-
601 { Qt::Key_Open, QT_TRANSLATE_NOOP("QShortcut", "Open") },-
602 { Qt::Key_Find, QT_TRANSLATE_NOOP("QShortcut", "Find") },-
603 { Qt::Key_Undo, QT_TRANSLATE_NOOP("QShortcut", "Undo") },-
604 { Qt::Key_Redo, QT_TRANSLATE_NOOP("QShortcut", "Redo") },-
605-
606 // ---------------------------------------------------------------
607 // More consistent namings-
608 { Qt::Key_Print, QT_TRANSLATE_NOOP("QShortcut", "Print Screen") },-
609 { Qt::Key_PageUp, QT_TRANSLATE_NOOP("QShortcut", "Page Up") },-
610 { Qt::Key_PageDown, QT_TRANSLATE_NOOP("QShortcut", "Page Down") },-
611 { Qt::Key_CapsLock, QT_TRANSLATE_NOOP("QShortcut", "Caps Lock") },-
612 { Qt::Key_NumLock, QT_TRANSLATE_NOOP("QShortcut", "Num Lock") },-
613 { Qt::Key_NumLock, QT_TRANSLATE_NOOP("QShortcut", "Number Lock") },-
614 { Qt::Key_ScrollLock, QT_TRANSLATE_NOOP("QShortcut", "Scroll Lock") },-
615 { Qt::Key_Insert, QT_TRANSLATE_NOOP("QShortcut", "Insert") },-
616 { Qt::Key_Delete, QT_TRANSLATE_NOOP("QShortcut", "Delete") },-
617 { Qt::Key_Escape, QT_TRANSLATE_NOOP("QShortcut", "Escape") },-
618 { Qt::Key_SysReq, QT_TRANSLATE_NOOP("QShortcut", "System Request") },-
619-
620 // ---------------------------------------------------------------
621 // Keypad navigation keys-
622 { Qt::Key_Select, QT_TRANSLATE_NOOP("QShortcut", "Select") },-
623 { Qt::Key_Yes, QT_TRANSLATE_NOOP("QShortcut", "Yes") },-
624 { Qt::Key_No, QT_TRANSLATE_NOOP("QShortcut", "No") },-
625-
626 // ---------------------------------------------------------------
627 // Device keys-
628 { Qt::Key_Context1, QT_TRANSLATE_NOOP("QShortcut", "Context1") },-
629 { Qt::Key_Context2, QT_TRANSLATE_NOOP("QShortcut", "Context2") },-
630 { Qt::Key_Context3, QT_TRANSLATE_NOOP("QShortcut", "Context3") },-
631 { Qt::Key_Context4, QT_TRANSLATE_NOOP("QShortcut", "Context4") },-
632 //: Button to start a call (note: a separate button is used to end the call)-
633 { Qt::Key_Call, QT_TRANSLATE_NOOP("QShortcut", "Call") },-
634 //: Button to end a call (note: a separate button is used to start the call)-
635 { Qt::Key_Hangup, QT_TRANSLATE_NOOP("QShortcut", "Hangup") },-
636 //: Button that will hang up if we're in call, or make a call if we're not.-
637 { Qt::Key_ToggleCallHangup, QT_TRANSLATE_NOOP("QShortcut", "Toggle Call/Hangup") },-
638 { Qt::Key_Flip, QT_TRANSLATE_NOOP("QShortcut", "Flip") },-
639 //: Button to trigger voice dialing-
640 { Qt::Key_VoiceDial, QT_TRANSLATE_NOOP("QShortcut", "Voice Dial") },-
641 //: Button to redial the last number called-
642 { Qt::Key_LastNumberRedial, QT_TRANSLATE_NOOP("QShortcut", "Last Number Redial") },-
643 //: Button to trigger the camera shutter (take a picture)-
644 { Qt::Key_Camera, QT_TRANSLATE_NOOP("QShortcut", "Camera Shutter") },-
645 //: Button to focus the camera-
646 { Qt::Key_CameraFocus, QT_TRANSLATE_NOOP("QShortcut", "Camera Focus") },-
647-
648 // ---------------------------------------------------------------
649 // Japanese keyboard support-
650 { Qt::Key_Kanji, QT_TRANSLATE_NOOP("QShortcut", "Kanji") },-
651 { Qt::Key_Muhenkan, QT_TRANSLATE_NOOP("QShortcut", "Muhenkan") },-
652 { Qt::Key_Henkan, QT_TRANSLATE_NOOP("QShortcut", "Henkan") },-
653 { Qt::Key_Romaji, QT_TRANSLATE_NOOP("QShortcut", "Romaji") },-
654 { Qt::Key_Hiragana, QT_TRANSLATE_NOOP("QShortcut", "Hiragana") },-
655 { Qt::Key_Katakana, QT_TRANSLATE_NOOP("QShortcut", "Katakana") },-
656 { Qt::Key_Hiragana_Katakana,QT_TRANSLATE_NOOP("QShortcut", "Hiragana Katakana") },-
657 { Qt::Key_Zenkaku, QT_TRANSLATE_NOOP("QShortcut", "Zenkaku") },-
658 { Qt::Key_Hankaku, QT_TRANSLATE_NOOP("QShortcut", "Hankaku") },-
659 { Qt::Key_Zenkaku_Hankaku, QT_TRANSLATE_NOOP("QShortcut", "Zenkaku Hankaku") },-
660 { Qt::Key_Touroku, QT_TRANSLATE_NOOP("QShortcut", "Touroku") },-
661 { Qt::Key_Massyo, QT_TRANSLATE_NOOP("QShortcut", "Massyo") },-
662 { Qt::Key_Kana_Lock, QT_TRANSLATE_NOOP("QShortcut", "Kana Lock") },-
663 { Qt::Key_Kana_Shift, QT_TRANSLATE_NOOP("QShortcut", "Kana Shift") },-
664 { Qt::Key_Eisu_Shift, QT_TRANSLATE_NOOP("QShortcut", "Eisu Shift") },-
665 { Qt::Key_Eisu_toggle, QT_TRANSLATE_NOOP("QShortcut", "Eisu toggle") },-
666 { Qt::Key_Codeinput, QT_TRANSLATE_NOOP("QShortcut", "Code input") },-
667 { Qt::Key_MultipleCandidate,QT_TRANSLATE_NOOP("QShortcut", "Multiple Candidate") },-
668 { Qt::Key_PreviousCandidate,QT_TRANSLATE_NOOP("QShortcut", "Previous Candidate") },-
669-
670 // ---------------------------------------------------------------
671 // Korean keyboard support-
672 { Qt::Key_Hangul, QT_TRANSLATE_NOOP("QShortcut", "Hangul") },-
673 { Qt::Key_Hangul_Start, QT_TRANSLATE_NOOP("QShortcut", "Hangul Start") },-
674 { Qt::Key_Hangul_End, QT_TRANSLATE_NOOP("QShortcut", "Hangul End") },-
675 { Qt::Key_Hangul_Hanja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Hanja") },-
676 { Qt::Key_Hangul_Jamo, QT_TRANSLATE_NOOP("QShortcut", "Hangul Jamo") },-
677 { Qt::Key_Hangul_Romaja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Romaja") },-
678 { Qt::Key_Hangul_Jeonja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Jeonja") },-
679 { Qt::Key_Hangul_Banja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Banja") },-
680 { Qt::Key_Hangul_PreHanja, QT_TRANSLATE_NOOP("QShortcut", "Hangul PreHanja") },-
681 { Qt::Key_Hangul_PostHanja,QT_TRANSLATE_NOOP("QShortcut", "Hangul PostHanja") },-
682 { Qt::Key_Hangul_Special, QT_TRANSLATE_NOOP("QShortcut", "Hangul Special") },-
683-
684 // ---------------------------------------------------------------
685 // Miscellaneous keys-
686 { Qt::Key_Cancel, QT_TRANSLATE_NOOP("QShortcut", "Cancel") },-
687 { Qt::Key_Printer, QT_TRANSLATE_NOOP("QShortcut", "Printer") },-
688 { Qt::Key_Execute, QT_TRANSLATE_NOOP("QShortcut", "Execute") },-
689 { Qt::Key_Play, QT_TRANSLATE_NOOP("QShortcut", "Play") },-
690 { Qt::Key_Zoom, QT_TRANSLATE_NOOP("QShortcut", "Zoom") },-
691 { Qt::Key_Exit, QT_TRANSLATE_NOOP("QShortcut", "Exit") },-
692 { Qt::Key_TouchpadToggle, QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },-
693 { Qt::Key_TouchpadOn, QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },-
694 { Qt::Key_TouchpadOff, QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },-
695-
696};-
697static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;-
698-
699/*!-
700 \enum QKeySequence::StandardKey-
701 \since 4.2-
702-
703 This enum represent standard key bindings. They can be used to-
704 assign platform dependent keyboard shortcuts to a QAction.-
705-
706 Note that the key bindings are platform dependent. The currently-
707 bound shortcuts can be queried using keyBindings().-
708-
709 \value AddTab Add new tab.-
710 \value Back Navigate back.-
711 \value Backspace Delete previous character.-
712 \value Bold Bold text.-
713 \value Close Close document/tab.-
714 \value Copy Copy.-
715 \value Cut Cut.-
716 \value Delete Delete.-
717 \value DeleteEndOfLine Delete end of line.-
718 \value DeleteEndOfWord Delete word from the end of the cursor.-
719 \value DeleteStartOfWord Delete the beginning of a word up to the cursor.-
720 \value DeleteCompleteLine Delete the entire line.-
721 \value Find Find in document.-
722 \value FindNext Find next result.-
723 \value FindPrevious Find previous result.-
724 \value Forward Navigate forward.-
725 \value HelpContents Open help contents.-
726 \value InsertLineSeparator Insert a new line.-
727 \value InsertParagraphSeparator Insert a new paragraph.-
728 \value Italic Italic text.-
729 \value MoveToEndOfBlock Move cursor to end of block. This shortcut is only used on the \macos.-
730 \value MoveToEndOfDocument Move cursor to end of document.-
731 \value MoveToEndOfLine Move cursor to end of line.-
732 \value MoveToNextChar Move cursor to next character.-
733 \value MoveToNextLine Move cursor to next line.-
734 \value MoveToNextPage Move cursor to next page.-
735 \value MoveToNextWord Move cursor to next word.-
736 \value MoveToPreviousChar Move cursor to previous character.-
737 \value MoveToPreviousLine Move cursor to previous line.-
738 \value MoveToPreviousPage Move cursor to previous page.-
739 \value MoveToPreviousWord Move cursor to previous word.-
740 \value MoveToStartOfBlock Move cursor to start of a block. This shortcut is only used on \macos.-
741 \value MoveToStartOfDocument Move cursor to start of document.-
742 \value MoveToStartOfLine Move cursor to start of line.-
743 \value New Create new document.-
744 \value NextChild Navigate to next tab or child window.-
745 \value Open Open document.-
746 \value Paste Paste.-
747 \value Preferences Open the preferences dialog.-
748 \value PreviousChild Navigate to previous tab or child window.-
749 \value Print Print document.-
750 \value Quit Quit the application.-
751 \value Redo Redo.-
752 \value Refresh Refresh or reload current document.-
753 \value Replace Find and replace.-
754 \value SaveAs Save document after prompting the user for a file name.-
755 \value Save Save document.-
756 \value SelectAll Select all text.-
757 \value Deselect Deselect text. Since 5.1-
758 \value SelectEndOfBlock Extend selection to the end of a text block. This shortcut is only used on \macos.-
759 \value SelectEndOfDocument Extend selection to end of document.-
760 \value SelectEndOfLine Extend selection to end of line.-
761 \value SelectNextChar Extend selection to next character.-
762 \value SelectNextLine Extend selection to next line.-
763 \value SelectNextPage Extend selection to next page.-
764 \value SelectNextWord Extend selection to next word.-
765 \value SelectPreviousChar Extend selection to previous character.-
766 \value SelectPreviousLine Extend selection to previous line.-
767 \value SelectPreviousPage Extend selection to previous page.-
768 \value SelectPreviousWord Extend selection to previous word.-
769 \value SelectStartOfBlock Extend selection to the start of a text block. This shortcut is only used on \macos.-
770 \value SelectStartOfDocument Extend selection to start of document.-
771 \value SelectStartOfLine Extend selection to start of line.-
772 \value Underline Underline text.-
773 \value Undo Undo.-
774 \value UnknownKey Unbound key.-
775 \value WhatsThis Activate "what's this".-
776 \value ZoomIn Zoom in.-
777 \value ZoomOut Zoom out.-
778 \value FullScreen Toggle the window state to/from full screen.-
779 \value Cancel Cancel the current operation.-
780*/-
781-
782/*!-
783 \fn QKeySequence &QKeySequence::operator=(QKeySequence &&other)-
784-
785 Move-assigns \a other to this QKeySequence instance.-
786-
787 \since 5.2-
788*/-
789-
790/*!-
791 \since 4.2-
792-
793 Constructs a QKeySequence object for the given \a key.-
794 The result will depend on the currently running platform.-
795-
796 The resulting object will be based on the first element in the-
797 list of key bindings for the \a key.-
798*/-
799QKeySequence::QKeySequence(StandardKey key)-
800{-
801 const QList <QKeySequence> bindings = keyBindings(key);-
802 //pick only the first/primary shortcut from current bindings-
803 if (bindings.size() > 0) {
bindings.size() > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
804 d = bindings.first().d;-
805 d->ref.ref();-
806 }
never executed: end of block
0
807 else-
808 d = new QKeySequencePrivate();
never executed: d = new QKeySequencePrivate();
0
809}-
810-
811-
812/*!-
813 Constructs an empty key sequence.-
814*/-
815QKeySequence::QKeySequence()-
816{-
817 static QKeySequencePrivate shared_empty;-
818 d = &shared_empty;-
819 d->ref.ref();-
820}
never executed: end of block
0
821-
822/*!-
823 Creates a key sequence from the \a key string, based on \a format.-
824-
825 For example "Ctrl+O" gives CTRL+'O'. The strings "Ctrl",-
826 "Shift", "Alt" and "Meta" are recognized, as well as their-
827 translated equivalents in the "QShortcut" context (using-
828 QObject::tr()).-
829-
830 Up to four key codes may be entered by separating them with-
831 commas, e.g. "Alt+X,Ctrl+S,Q".-
832-
833 This constructor is typically used with \l{QObject::tr()}{tr}(), so-
834 that shortcut keys can be replaced in translations:-
835-
836 \snippet code/src_gui_kernel_qkeysequence.cpp 2-
837-
838 Note the "File|Open" translator comment. It is by no means-
839 necessary, but it provides some context for the human translator.-
840*/-
841QKeySequence::QKeySequence(const QString &key, QKeySequence::SequenceFormat format)-
842{-
843 d = new QKeySequencePrivate();-
844 assign(key, format);-
845}
never executed: end of block
0
846-
847Q_STATIC_ASSERT_X(QKeySequencePrivate::MaxKeyCount == 4, "Change docs and ctor impl below");-
848/*!-
849 Constructs a key sequence with up to 4 keys \a k1, \a k2,-
850 \a k3 and \a k4.-
851-
852 The key codes are listed in Qt::Key and can be combined with-
853 modifiers (see Qt::Modifier) such as Qt::SHIFT, Qt::CTRL,-
854 Qt::ALT, or Qt::META.-
855*/-
856QKeySequence::QKeySequence(int k1, int k2, int k3, int k4)-
857{-
858 d = new QKeySequencePrivate();-
859 d->key[0] = k1;-
860 d->key[1] = k2;-
861 d->key[2] = k3;-
862 d->key[3] = k4;-
863}
never executed: end of block
0
864-
865/*!-
866 Copy constructor. Makes a copy of \a keysequence.-
867 */-
868QKeySequence::QKeySequence(const QKeySequence& keysequence)-
869 : d(keysequence.d)-
870{-
871 d->ref.ref();-
872}
never executed: end of block
0
873-
874/*!-
875 \since 4.2-
876-
877 Returns a list of key bindings for the given \a key.-
878 The result of calling this function will vary based on the target platform.-
879 The first element of the list indicates the primary shortcut for the given platform.-
880 If the result contains more than one result, these can-
881 be considered alternative shortcuts on the same platform for the given \a key.-
882*/-
883QList<QKeySequence> QKeySequence::keyBindings(StandardKey key)-
884{-
885 return QGuiApplicationPrivate::platformTheme()->keyBindings(key);
never executed: return QGuiApplicationPrivate::platformTheme()->keyBindings(key);
0
886}-
887-
888/*!-
889 Destroys the key sequence.-
890 */-
891QKeySequence::~QKeySequence()-
892{-
893 if (!d->ref.deref())
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
0
894 delete d;
never executed: delete d;
0
895}
never executed: end of block
0
896-
897/*!-
898 \internal-
899 KeySequences should never be modified, but rather just created.-
900 Internally though we do need to modify to keep pace in event-
901 delivery.-
902*/-
903-
904void QKeySequence::setKey(int key, int index)-
905{-
906 Q_ASSERT_X(index >= 0 && index < QKeySequencePrivate::MaxKeyCount, "QKeySequence::setKey", "index out of range");-
907 qAtomicDetach(d);-
908 d->key[index] = key;-
909}
never executed: end of block
0
910-
911Q_STATIC_ASSERT_X(QKeySequencePrivate::MaxKeyCount == 4, "Change docs below");-
912/*!-
913 Returns the number of keys in the key sequence.-
914 The maximum is 4.-
915 */-
916int QKeySequence::count() const-
917{-
918 return int(std::distance(d->key, std::find(d->key, d->key + QKeySequencePrivate::MaxKeyCount, 0)));
never executed: return int(std::distance(d->key, std::find(d->key, d->key + QKeySequencePrivate::MaxKeyCount, 0)));
0
919}-
920-
921-
922/*!-
923 Returns \c true if the key sequence is empty; otherwise returns-
924 false.-
925*/-
926bool QKeySequence::isEmpty() const-
927{-
928 return !d->key[0];
never executed: return !d->key[0];
0
929}-
930-
931-
932/*!-
933 Returns the shortcut key sequence for the mnemonic in \a text,-
934 or an empty key sequence if no mnemonics are found.-
935-
936 For example, mnemonic("E&xit") returns \c{Qt::ALT+Qt::Key_X},-
937 mnemonic("&Quit") returns \c{ALT+Key_Q}, and mnemonic("Quit")-
938 returns an empty QKeySequence.-
939-
940 We provide a \l{accelerators.html}{list of common mnemonics}-
941 in English. At the time of writing, Microsoft and Open Group do-
942 not appear to have issued equivalent recommendations for other-
943 languages.-
944*/-
945QKeySequence QKeySequence::mnemonic(const QString &text)-
946{-
947 QKeySequence ret;-
948-
949 if(qt_sequence_no_mnemonics)
qt_sequence_no_mnemonicsDescription
TRUEnever evaluated
FALSEnever evaluated
0
950 return ret;
never executed: return ret;
0
951-
952 bool found = false;-
953 int p = 0;-
954 while (p >= 0) {
p >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
955 p = text.indexOf(QLatin1Char('&'), p) + 1;-
956 if (p <= 0 || p >= (int)text.length())
p <= 0Description
TRUEnever evaluated
FALSEnever evaluated
p >= (int)text.length()Description
TRUEnever evaluated
FALSEnever evaluated
0
957 break;
never executed: break;
0
958 if (text.at(p) != QLatin1Char('&')) {
text.at(p) != QLatin1Char('&')Description
TRUEnever evaluated
FALSEnever evaluated
0
959 QChar c = text.at(p);-
960 if (c.isPrint()) {
c.isPrint()Description
TRUEnever evaluated
FALSEnever evaluated
0
961 if (!found) {
!foundDescription
TRUEnever evaluated
FALSEnever evaluated
0
962 c = c.toUpper();-
963 ret = QKeySequence(c.unicode() + Qt::ALT);-
964#ifdef QT_NO_DEBUG-
965 return ret;-
966#else-
967 found = true;-
968 } else {
never executed: end of block
0
969 qWarning("QKeySequence::mnemonic: \"%s\" contains multiple occurrences of '&'", qPrintable(text));-
970#endif-
971 }
never executed: end of block
0
972 }-
973 }
never executed: end of block
0
974 p++;-
975 }
never executed: end of block
0
976 return ret;
never executed: return ret;
0
977}-
978-
979/*!-
980 \fn int QKeySequence::assign(const QString &keys)-
981-
982 Adds the given \a keys to the key sequence. \a keys may-
983 contain up to four key codes, provided they are separated by a-
984 comma; for example, "Alt+X,Ctrl+S,Z". The return value is the-
985 number of key codes added.-
986 \a keys should be in NativeText format.-
987*/-
988int QKeySequence::assign(const QString &ks)-
989{-
990 return assign(ks, NativeText);
never executed: return assign(ks, NativeText);
0
991}-
992-
993/*!-
994 \fn int QKeySequence::assign(const QString &keys, QKeySequence::SequenceFormat format)-
995 \since 4.7-
996-
997 Adds the given \a keys to the key sequence (based on \a format).-
998 \a keys may contain up to four key codes, provided they are-
999 separated by a comma; for example, "Alt+X,Ctrl+S,Z". The return-
1000 value is the number of key codes added.-
1001*/-
1002int QKeySequence::assign(const QString &ks, QKeySequence::SequenceFormat format)-
1003{-
1004 QString keyseq = ks;-
1005 QString part;-
1006 int n = 0;-
1007 int p = 0, diff = 0;-
1008-
1009 // Run through the whole string, but stop-
1010 // if we have MaxKeyCount keys before the end.-
1011 while (keyseq.length() && n < QKeySequencePrivate::MaxKeyCount) {
keyseq.length()Description
TRUEnever evaluated
FALSEnever evaluated
n < QKeySequen...e::MaxKeyCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1012 // We MUST use something to separate each sequence, and space-
1013 // does not cut it, since some of the key names have space-
1014 // in them.. (Let's hope no one translate with a comma in it:)-
1015 p = keyseq.indexOf(QLatin1Char(','));-
1016 if (-1 != p) {
-1 != pDescription
TRUEnever evaluated
FALSEnever evaluated
0
1017 if (p == keyseq.count() - 1) { // Last comma 'Ctrl+,'
p == keyseq.count() - 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1018 p = -1;-
1019 } else {
never executed: end of block
0
1020 if (QLatin1Char(',') == keyseq.at(p+1)) // e.g. 'Ctrl+,, Shift+,,'
QLatin1Char(',...keyseq.at(p+1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1021 p++;
never executed: p++;
0
1022 if (QLatin1Char(' ') == keyseq.at(p+1)) { // Space after comma
QLatin1Char(' ...keyseq.at(p+1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1023 diff = 1;-
1024 p++;-
1025 } else {
never executed: end of block
0
1026 diff = 0;-
1027 }
never executed: end of block
0
1028 }-
1029 }-
1030 part = keyseq.left(-1 == p ? keyseq.length() : p - diff);-
1031 keyseq = keyseq.right(-1 == p ? 0 : keyseq.length() - (p + 1));-
1032 d->key[n] = QKeySequencePrivate::decodeString(part, format);-
1033 ++n;-
1034 }
never executed: end of block
0
1035 return n;
never executed: return n;
0
1036}-
1037-
1038struct QModifKeyName {-
1039 QModifKeyName() { }-
1040 QModifKeyName(int q, QChar n) : qt_key(q), name(n) { }
never executed: end of block
0
1041 QModifKeyName(int q, const QString &n) : qt_key(q), name(n) { }
never executed: end of block
0
1042 int qt_key;-
1043 QString name;-
1044};-
1045Q_DECLARE_TYPEINFO(QModifKeyName, Q_MOVABLE_TYPE);-
1046-
1047Q_GLOBAL_STATIC(QVector<QModifKeyName>, globalModifs)
never executed: end of block
never executed: guard.store(QtGlobalStatic::Destroyed);
never executed: return &holder.value;
guard.load() =...c::InitializedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1048Q_GLOBAL_STATIC(QVector<QModifKeyName>, globalPortableModifs)
never executed: end of block
never executed: guard.store(QtGlobalStatic::Destroyed);
never executed: return &holder.value;
guard.load() =...c::InitializedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1049-
1050/*!-
1051 Constructs a single key from the string \a str.-
1052*/-
1053int QKeySequence::decodeString(const QString &str)-
1054{-
1055 return QKeySequencePrivate::decodeString(str, NativeText);
never executed: return QKeySequencePrivate::decodeString(str, NativeText);
0
1056}-
1057-
1058int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::SequenceFormat format)-
1059{-
1060 int ret = 0;-
1061 QString accel = str.toLower();-
1062 bool nativeText = (format == QKeySequence::NativeText);-
1063-
1064 QVector<QModifKeyName> *gmodifs;-
1065 if (nativeText) {
nativeTextDescription
TRUEnever evaluated
FALSEnever evaluated
0
1066 gmodifs = globalModifs();-
1067 if (gmodifs->isEmpty()) {
gmodifs->isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1068#if defined(Q_OS_MACX)-
1069 const bool dontSwap = qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta);-
1070 if (dontSwap)-
1071 *gmodifs << QModifKeyName(Qt::META, QChar(kCommandUnicode));-
1072 else-
1073 *gmodifs << QModifKeyName(Qt::CTRL, QChar(kCommandUnicode));-
1074 *gmodifs << QModifKeyName(Qt::ALT, QChar(kOptionUnicode));-
1075 if (dontSwap)-
1076 *gmodifs << QModifKeyName(Qt::CTRL, QChar(kControlUnicode));-
1077 else-
1078 *gmodifs << QModifKeyName(Qt::META, QChar(kControlUnicode));-
1079 *gmodifs << QModifKeyName(Qt::SHIFT, QChar(kShiftUnicode));-
1080#endif-
1081 *gmodifs << QModifKeyName(Qt::CTRL, QLatin1String("ctrl+"))-
1082 << QModifKeyName(Qt::SHIFT, QLatin1String("shift+"))-
1083 << QModifKeyName(Qt::ALT, QLatin1String("alt+"))-
1084 << QModifKeyName(Qt::META, QLatin1String("meta+"))-
1085 << QModifKeyName(Qt::KeypadModifier, QLatin1String("num+"));-
1086 }
never executed: end of block
0
1087 } else {
never executed: end of block
0
1088 gmodifs = globalPortableModifs();-
1089 if (gmodifs->isEmpty()) {
gmodifs->isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1090 *gmodifs << QModifKeyName(Qt::CTRL, QLatin1String("ctrl+"))-
1091 << QModifKeyName(Qt::SHIFT, QLatin1String("shift+"))-
1092 << QModifKeyName(Qt::ALT, QLatin1String("alt+"))-
1093 << QModifKeyName(Qt::META, QLatin1String("meta+"))-
1094 << QModifKeyName(Qt::KeypadModifier, QLatin1String("num+"));-
1095 }
never executed: end of block
0
1096 }
never executed: end of block
0
1097 if (!gmodifs) return ret;
never executed: return ret;
!gmodifsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1098-
1099-
1100 QVector<QModifKeyName> modifs;-
1101 if (nativeText) {
nativeTextDescription
TRUEnever evaluated
FALSEnever evaluated
0
1102 modifs << QModifKeyName(Qt::CTRL, QCoreApplication::translate("QShortcut", "Ctrl").toLower().append(QLatin1Char('+')))-
1103 << QModifKeyName(Qt::SHIFT, QCoreApplication::translate("QShortcut", "Shift").toLower().append(QLatin1Char('+')))-
1104 << QModifKeyName(Qt::ALT, QCoreApplication::translate("QShortcut", "Alt").toLower().append(QLatin1Char('+')))-
1105 << QModifKeyName(Qt::META, QCoreApplication::translate("QShortcut", "Meta").toLower().append(QLatin1Char('+')))-
1106 << QModifKeyName(Qt::KeypadModifier, QCoreApplication::translate("QShortcut", "Num").toLower().append(QLatin1Char('+')));-
1107 }
never executed: end of block
0
1108 modifs += *gmodifs; // Test non-translated ones last-
1109-
1110 QString sl = accel;-
1111#if defined(Q_OS_MACX)-
1112 for (int i = 0; i < modifs.size(); ++i) {-
1113 const QModifKeyName &mkf = modifs.at(i);-
1114 if (sl.contains(mkf.name)) {-
1115 ret |= mkf.qt_key;-
1116 accel.remove(mkf.name);-
1117 sl = accel;-
1118 }-
1119 }-
1120#endif-
1121 int i = 0;-
1122 int lastI = 0;-
1123 while ((i = sl.indexOf(QLatin1Char('+'), i + 1)) != -1) {
(i = sl.indexO... i + 1)) != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1124 const QStringRef sub = sl.midRef(lastI, i - lastI + 1);-
1125 // If we get here the shortcuts contains at least one '+'. We break up-
1126 // along the following strategy:-
1127 // Meta+Ctrl++ ( "Meta+", "Ctrl+", "+" )-
1128 // Super+Shift+A ( "Super+", "Shift+" )-
1129 // 4+3+2=1 ( "4+", "3+" )-
1130 // In other words, everything we try to handle HAS to be a modifier-
1131 // except for a single '+' at the end of the string.-
1132-
1133 // Only '+' can have length 1.-
1134 if (sub.length() == 1) {
sub.length() == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1135 // Make sure we only encounter a single '+' at the end of the accel-
1136 if (accel.lastIndexOf(QLatin1Char('+')) != accel.length()-1)
accel.lastInde...cel.length()-1Description
TRUEnever evaluated
FALSEnever evaluated
0
1137 return Qt::Key_unknown;
never executed: return Qt::Key_unknown;
0
1138 } else {
never executed: end of block
0
1139 // Identify the modifier-
1140 bool validModifier = false;-
1141 for (int j = 0; j < modifs.size(); ++j) {
j < modifs.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1142 const QModifKeyName &mkf = modifs.at(j);-
1143 if (sub == mkf.name) {
sub == mkf.nameDescription
TRUEnever evaluated
FALSEnever evaluated
0
1144 ret |= mkf.qt_key;-
1145 validModifier = true;-
1146 break; // Shortcut, since if we find an other it would/should just be a dup
never executed: break;
0
1147 }-
1148 }
never executed: end of block
0
1149-
1150 if (!validModifier)
!validModifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
1151 return Qt::Key_unknown;
never executed: return Qt::Key_unknown;
0
1152 }
never executed: end of block
0
1153 lastI = i + 1;-
1154 }
never executed: end of block
0
1155-
1156 int p = accel.lastIndexOf(QLatin1Char('+'), str.length() - 2); // -2 so that Ctrl++ works-
1157 QStringRef accelRef(&accel);-
1158 if(p > 0)
p > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1159 accelRef = accelRef.mid(p + 1);
never executed: accelRef = accelRef.mid(p + 1);
0
1160-
1161 int fnum = 0;-
1162 if (accelRef.length() == 1) {
accelRef.length() == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1163#if defined(Q_OS_MACX)-
1164 int qtKey = qtkeyForMacSymbol(accelRef.at(0));-
1165 if (qtKey != -1) {-
1166 ret |= qtKey;-
1167 } else-
1168#endif-
1169 {-
1170 ret |= accelRef.at(0).toUpper().unicode();-
1171 }-
1172 } else if (accelRef.at(0) == QLatin1Char('f') && (fnum = accelRef.mid(1).toInt()) >= 1 && fnum <= 35) {
never executed: end of block
accelRef.at(0)...atin1Char('f')Description
TRUEnever evaluated
FALSEnever evaluated
(fnum = accelR....toInt()) >= 1Description
TRUEnever evaluated
FALSEnever evaluated
fnum <= 35Description
TRUEnever evaluated
FALSEnever evaluated
0
1173 ret |= Qt::Key_F1 + fnum - 1;-
1174 } else {
never executed: end of block
0
1175 // For NativeText, check the traslation table first,-
1176 // if we don't find anything then try it out with just the untranlated stuff.-
1177 // PortableText will only try the untranlated table.-
1178 bool found = false;-
1179 for (int tran = 0; tran < 2; ++tran) {
tran < 2Description
TRUEnever evaluated
FALSEnever evaluated
0
1180 if (!nativeText)
!nativeTextDescription
TRUEnever evaluated
FALSEnever evaluated
0
1181 ++tran;
never executed: ++tran;
0
1182 for (int i = 0; i < numKeyNames; ++i) {
i < numKeyNamesDescription
TRUEnever evaluated
FALSEnever evaluated
0
1183 QString keyName(tran == 0-
1184 ? QCoreApplication::translate("QShortcut", keyname[i].name)-
1185 : QString::fromLatin1(keyname[i].name));-
1186 if (accelRef == keyName.toLower()) {
accelRef == keyName.toLower()Description
TRUEnever evaluated
FALSEnever evaluated
0
1187 ret |= keyname[i].key;-
1188 found = true;-
1189 break;
never executed: break;
0
1190 }-
1191 }
never executed: end of block
0
1192 if (found)
foundDescription
TRUEnever evaluated
FALSEnever evaluated
0
1193 break;
never executed: break;
0
1194 }
never executed: end of block
0
1195 // We couldn't translate the key.-
1196 if (!found)
!foundDescription
TRUEnever evaluated
FALSEnever evaluated
0
1197 return Qt::Key_unknown;
never executed: return Qt::Key_unknown;
0
1198 }
never executed: end of block
0
1199 return ret;
never executed: return ret;
0
1200}-
1201-
1202/*!-
1203 Creates a shortcut string for \a key. For example,-
1204 Qt::CTRL+Qt::Key_O gives "Ctrl+O". The strings, "Ctrl", "Shift", etc. are-
1205 translated (using QObject::tr()) in the "QShortcut" context.-
1206 */-
1207QString QKeySequence::encodeString(int key)-
1208{-
1209 return QKeySequencePrivate::encodeString(key, NativeText);
never executed: return QKeySequencePrivate::encodeString(key, NativeText);
0
1210}-
1211-
1212static inline void addKey(QString &str, const QString &theKey, QKeySequence::SequenceFormat format)-
1213{-
1214 if (!str.isEmpty())
!str.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1215 str += (format == QKeySequence::NativeText) ? QCoreApplication::translate("QShortcut", "+")
never executed: str += (format == QKeySequence::NativeText) ? QCoreApplication::translate("QShortcut", "+") : QString::fromLatin1("+");
(format == QKe...e::NativeText)Description
TRUEnever evaluated
FALSEnever evaluated
0
1216 : QString::fromLatin1("+");
never executed: str += (format == QKeySequence::NativeText) ? QCoreApplication::translate("QShortcut", "+") : QString::fromLatin1("+");
0
1217 str += theKey;-
1218}
never executed: end of block
0
1219-
1220QString QKeySequencePrivate::encodeString(int key, QKeySequence::SequenceFormat format)-
1221{-
1222 bool nativeText = (format == QKeySequence::NativeText);-
1223 QString s;-
1224-
1225 // Handle -1 (Invalid Key) and Qt::Key_unknown gracefully-
1226 if (key == -1 || key == Qt::Key_unknown)
key == -1Description
TRUEnever evaluated
FALSEnever evaluated
key == Qt::Key_unknownDescription
TRUEnever evaluated
FALSEnever evaluated
0
1227 return s;
never executed: return s;
0
1228-
1229#if defined(Q_OS_MACX)-
1230 if (nativeText) {-
1231 // On OS X the order (by default) is Meta, Alt, Shift, Control.-
1232 // If the AA_MacDontSwapCtrlAndMeta is enabled, then the order-
1233 // is Ctrl, Alt, Shift, Meta. The macSymbolForQtKey does this swap-
1234 // for us, which means that we have to adjust our order here.-
1235 // The upshot is a lot more infrastructure to keep the number of-
1236 // if tests down and the code relatively clean.-
1237 static const int ModifierOrder[] = { Qt::META, Qt::ALT, Qt::SHIFT, Qt::CTRL, 0 };-
1238 static const int QtKeyOrder[] = { Qt::Key_Meta, Qt::Key_Alt, Qt::Key_Shift, Qt::Key_Control, 0 };-
1239 static const int DontSwapModifierOrder[] = { Qt::CTRL, Qt::ALT, Qt::SHIFT, Qt::META, 0 };-
1240 static const int DontSwapQtKeyOrder[] = { Qt::Key_Control, Qt::Key_Alt, Qt::Key_Shift, Qt::Key_Meta, 0 };-
1241 const int *modifierOrder;-
1242 const int *qtkeyOrder;-
1243 if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {-
1244 modifierOrder = DontSwapModifierOrder;-
1245 qtkeyOrder = DontSwapQtKeyOrder;-
1246 } else {-
1247 modifierOrder = ModifierOrder;-
1248 qtkeyOrder = QtKeyOrder;-
1249 }-
1250-
1251 for (int i = 0; modifierOrder[i] != 0; ++i) {-
1252 if (key & modifierOrder[i])-
1253 s += qt_macSymbolForQtKey(qtkeyOrder[i]);-
1254 }-
1255 } else-
1256#endif-
1257 {-
1258 // On other systems the order is Meta, Control, Alt, Shift-
1259 if ((key & Qt::META) == Qt::META)
(key & Qt::META) == Qt::METADescription
TRUEnever evaluated
FALSEnever evaluated
0
1260 s = nativeText ? QCoreApplication::translate("QShortcut", "Meta") : QString::fromLatin1("Meta");
never executed: s = nativeText ? QCoreApplication::translate("QShortcut", "Meta") : QString::fromLatin1("Meta");
nativeTextDescription
TRUEnever evaluated
FALSEnever evaluated
0
1261 if ((key & Qt::CTRL) == Qt::CTRL)
(key & Qt::CTRL) == Qt::CTRLDescription
TRUEnever evaluated
FALSEnever evaluated
0
1262 addKey(s, nativeText ? QCoreApplication::translate("QShortcut", "Ctrl") : QString::fromLatin1("Ctrl"), format);
never executed: addKey(s, nativeText ? QCoreApplication::translate("QShortcut", "Ctrl") : QString::fromLatin1("Ctrl"), format);
0
1263 if ((key & Qt::ALT) == Qt::ALT)
(key & Qt::ALT) == Qt::ALTDescription
TRUEnever evaluated
FALSEnever evaluated
0
1264 addKey(s, nativeText ? QCoreApplication::translate("QShortcut", "Alt") : QString::fromLatin1("Alt"), format);
never executed: addKey(s, nativeText ? QCoreApplication::translate("QShortcut", "Alt") : QString::fromLatin1("Alt"), format);
0
1265 if ((key & Qt::SHIFT) == Qt::SHIFT)
(key & Qt::SHIFT) == Qt::SHIFTDescription
TRUEnever evaluated
FALSEnever evaluated
0
1266 addKey(s, nativeText ? QCoreApplication::translate("QShortcut", "Shift") : QString::fromLatin1("Shift"), format);
never executed: addKey(s, nativeText ? QCoreApplication::translate("QShortcut", "Shift") : QString::fromLatin1("Shift"), format);
0
1267 }-
1268 if ((key & Qt::KeypadModifier) == Qt::KeypadModifier)
(key & Qt::Key...KeypadModifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
1269 addKey(s, nativeText ? QCoreApplication::translate("QShortcut", "Num") : QString::fromLatin1("Num"), format);
never executed: addKey(s, nativeText ? QCoreApplication::translate("QShortcut", "Num") : QString::fromLatin1("Num"), format);
0
1270-
1271 QString p = keyName(key, format);-
1272-
1273#if defined(Q_OS_OSX)-
1274 if (nativeText)-
1275 s += p;-
1276 else-
1277#endif-
1278 addKey(s, p, format);-
1279 return s;
never executed: return s;
0
1280}-
1281-
1282/*!-
1283 \internal-
1284 Returns the text representation of the key \a key, which can be used i.e.-
1285 when the sequence is serialized. This does not take modifiers into account-
1286 (see encodeString() for a version that does).-
1287-
1288 This static method is used by encodeString() and by the D-Bus menu exporter.-
1289*/-
1290QString QKeySequencePrivate::keyName(int key, QKeySequence::SequenceFormat format)-
1291{-
1292 bool nativeText = (format == QKeySequence::NativeText);-
1293 key &= ~(Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier | Qt::KeypadModifier);-
1294 QString p;-
1295-
1296 if (key && key < Qt::Key_Escape && key != Qt::Key_Space) {
keyDescription
TRUEnever evaluated
FALSEnever evaluated
key < Qt::Key_EscapeDescription
TRUEnever evaluated
FALSEnever evaluated
key != Qt::Key_SpaceDescription
TRUEnever evaluated
FALSEnever evaluated
0
1297 if (!QChar::requiresSurrogates(key)) {
!QChar::requir...urrogates(key)Description
TRUEnever evaluated
FALSEnever evaluated
0
1298 p = QChar(ushort(key)).toUpper();-
1299 } else {
never executed: end of block
0
1300 p += QChar(QChar::highSurrogate(key));-
1301 p += QChar(QChar::lowSurrogate(key));-
1302 }
never executed: end of block
0
1303 } else if (key >= Qt::Key_F1 && key <= Qt::Key_F35) {
key >= Qt::Key_F1Description
TRUEnever evaluated
FALSEnever evaluated
key <= Qt::Key_F35Description
TRUEnever evaluated
FALSEnever evaluated
0
1304 p = nativeText ? QCoreApplication::translate("QShortcut", "F%1").arg(key - Qt::Key_F1 + 1)
nativeTextDescription
TRUEnever evaluated
FALSEnever evaluated
0
1305 : QString::fromLatin1("F%1").arg(key - Qt::Key_F1 + 1);-
1306 } else if (key) {
never executed: end of block
keyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1307 int i=0;-
1308#if defined(Q_OS_MACX)-
1309 if (nativeText) {-
1310 QChar ch = qt_macSymbolForQtKey(key);-
1311 if (!ch.isNull())-
1312 p = ch;-
1313 else-
1314 goto NonSymbol;-
1315 } else-
1316#endif-
1317 {-
1318#if defined(Q_OS_MACX)-
1319NonSymbol:-
1320#endif-
1321 while (i < numKeyNames) {
i < numKeyNamesDescription
TRUEnever evaluated
FALSEnever evaluated
0
1322 if (key == keyname[i].key) {
key == keyname[i].keyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1323 p = nativeText ? QCoreApplication::translate("QShortcut", keyname[i].name)
nativeTextDescription
TRUEnever evaluated
FALSEnever evaluated
0
1324 : QString::fromLatin1(keyname[i].name);-
1325 break;
never executed: break;
0
1326 }-
1327 ++i;-
1328 }
never executed: end of block
0
1329 // If we can't find the actual translatable keyname,-
1330 // fall back on the unicode representation of it...-
1331 // Or else characters like Qt::Key_aring may not get displayed-
1332 // (Really depends on you locale)-
1333 if (i >= numKeyNames) {
i >= numKeyNamesDescription
TRUEnever evaluated
FALSEnever evaluated
0
1334 if (!QChar::requiresSurrogates(key)) {
!QChar::requir...urrogates(key)Description
TRUEnever evaluated
FALSEnever evaluated
0
1335 p = QChar(ushort(key)).toUpper();-
1336 } else {
never executed: end of block
0
1337 p += QChar(QChar::highSurrogate(key));-
1338 p += QChar(QChar::lowSurrogate(key));-
1339 }
never executed: end of block
0
1340 }-
1341 }-
1342 }
never executed: end of block
0
1343 return p;
never executed: return p;
0
1344}-
1345/*!-
1346 Matches the sequence with \a seq. Returns ExactMatch if-
1347 successful, PartialMatch if \a seq matches incompletely,-
1348 and NoMatch if the sequences have nothing in common.-
1349 Returns NoMatch if \a seq is shorter.-
1350*/-
1351QKeySequence::SequenceMatch QKeySequence::matches(const QKeySequence &seq) const-
1352{-
1353 uint userN = count(),-
1354 seqN = seq.count();-
1355-
1356 if (userN > seqN)
userN > seqNDescription
TRUEnever evaluated
FALSEnever evaluated
0
1357 return NoMatch;
never executed: return NoMatch;
0
1358-
1359 // If equal in length, we have a potential ExactMatch sequence,-
1360 // else we already know it can only be partial.-
1361 SequenceMatch match = (userN == seqN ? ExactMatch : PartialMatch);
userN == seqNDescription
TRUEnever evaluated
FALSEnever evaluated
0
1362-
1363 for (uint i = 0; i < userN; ++i) {
i < userNDescription
TRUEnever evaluated
FALSEnever evaluated
0
1364 int userKey = (*this)[i],-
1365 sequenceKey = seq[i];-
1366 if (userKey != sequenceKey)
userKey != sequenceKeyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1367 return NoMatch;
never executed: return NoMatch;
0
1368 }
never executed: end of block
0
1369 return match;
never executed: return match;
0
1370}-
1371-
1372-
1373/*! \fn QKeySequence::operator QString() const-
1374-
1375 \obsolete-
1376-
1377 Use toString() instead.-
1378-
1379 Returns the key sequence as a QString. This is equivalent to-
1380 calling toString(QKeySequence::NativeText). Note that the-
1381 result is not platform independent.-
1382*/-
1383-
1384/*!-
1385 Returns the key sequence as a QVariant-
1386*/-
1387QKeySequence::operator QVariant() const-
1388{-
1389 return QVariant(QVariant::KeySequence, this);
never executed: return QVariant(QVariant::KeySequence, this);
0
1390}-
1391-
1392/*! \fn QKeySequence::operator int () const-
1393-
1394 \obsolete-
1395 For backward compatibility: returns the first keycode-
1396 as integer. If the key sequence is empty, 0 is returned.-
1397 */-
1398-
1399/*!-
1400 Returns a reference to the element at position \a index in the key-
1401 sequence. This can only be used to read an element.-
1402 */-
1403int QKeySequence::operator[](uint index) const-
1404{-
1405 Q_ASSERT_X(index < QKeySequencePrivate::MaxKeyCount, "QKeySequence::operator[]", "index out of range");-
1406 return d->key[index];
never executed: return d->key[index];
0
1407}-
1408-
1409-
1410/*!-
1411 Assignment operator. Assigns the \a other key sequence to this-
1412 object.-
1413 */-
1414QKeySequence &QKeySequence::operator=(const QKeySequence &other)-
1415{-
1416 qAtomicAssign(d, other.d);-
1417 return *this;
never executed: return *this;
0
1418}-
1419-
1420/*!-
1421 \fn void QKeySequence::swap(QKeySequence &other)-
1422 \since 4.8-
1423-
1424 Swaps key sequence \a other with this key sequence. This operation is very-
1425 fast and never fails.-
1426*/-
1427-
1428/*!-
1429 \fn bool QKeySequence::operator!=(const QKeySequence &other) const-
1430-
1431 Returns \c true if this key sequence is not equal to the \a other-
1432 key sequence; otherwise returns \c false.-
1433*/-
1434-
1435-
1436/*!-
1437 Returns \c true if this key sequence is equal to the \a other-
1438 key sequence; otherwise returns \c false.-
1439 */-
1440bool QKeySequence::operator==(const QKeySequence &other) const-
1441{-
1442 return (d->key[0] == other.d->key[0] &&
never executed: return (d->key[0] == other.d->key[0] && d->key[1] == other.d->key[1] && d->key[2] == other.d->key[2] && d->key[3] == other.d->key[3]);
0
1443 d->key[1] == other.d->key[1] &&
never executed: return (d->key[0] == other.d->key[0] && d->key[1] == other.d->key[1] && d->key[2] == other.d->key[2] && d->key[3] == other.d->key[3]);
0
1444 d->key[2] == other.d->key[2] &&
never executed: return (d->key[0] == other.d->key[0] && d->key[1] == other.d->key[1] && d->key[2] == other.d->key[2] && d->key[3] == other.d->key[3]);
0
1445 d->key[3] == other.d->key[3]);
never executed: return (d->key[0] == other.d->key[0] && d->key[1] == other.d->key[1] && d->key[2] == other.d->key[2] && d->key[3] == other.d->key[3]);
0
1446}-
1447-
1448/*!-
1449 \since 5.6-
1450-
1451 Calculates the hash value of \a key, using-
1452 \a seed to seed the calculation.-
1453*/-
1454uint qHash(const QKeySequence &key, uint seed) Q_DECL_NOTHROW-
1455{-
1456 return qHashRange(key.d->key, key.d->key + QKeySequencePrivate::MaxKeyCount, seed);
never executed: return qHashRange(key.d->key, key.d->key + QKeySequencePrivate::MaxKeyCount, seed);
0
1457}-
1458-
1459/*!-
1460 Provides an arbitrary comparison of this key sequence and-
1461 \a other key sequence. All that is guaranteed is that the-
1462 operator returns \c false if both key sequences are equal and-
1463 that (ks1 \< ks2) == !( ks2 \< ks1) if the key sequences-
1464 are not equal.-
1465-
1466 This function is useful in some circumstances, for example-
1467 if you want to use QKeySequence objects as keys in a QMap.-
1468-
1469 \sa operator==(), operator!=(), operator>(), operator<=(), operator>=()-
1470*/-
1471bool QKeySequence::operator< (const QKeySequence &other) const-
1472{-
1473 return std::lexicographical_compare(d->key, d->key + QKeySequencePrivate::MaxKeyCount,
never executed: return std::lexicographical_compare(d->key, d->key + QKeySequencePrivate::MaxKeyCount, other.d->key, other.d->key + QKeySequencePrivate::MaxKeyCount);
0
1474 other.d->key, other.d->key + QKeySequencePrivate::MaxKeyCount);
never executed: return std::lexicographical_compare(d->key, d->key + QKeySequencePrivate::MaxKeyCount, other.d->key, other.d->key + QKeySequencePrivate::MaxKeyCount);
0
1475}-
1476-
1477/*!-
1478 \fn bool QKeySequence::operator> (const QKeySequence &other) const-
1479-
1480 Returns \c true if this key sequence is larger than the \a other key-
1481 sequence; otherwise returns \c false.-
1482-
1483 \sa operator==(), operator!=(), operator<(), operator<=(), operator>=()-
1484*/-
1485-
1486/*!-
1487 \fn bool QKeySequence::operator<= (const QKeySequence &other) const-
1488-
1489 Returns \c true if this key sequence is smaller or equal to the-
1490 \a other key sequence; otherwise returns \c false.-
1491-
1492 \sa operator==(), operator!=(), operator<(), operator>(), operator>=()-
1493*/-
1494-
1495/*!-
1496 \fn bool QKeySequence::operator>= (const QKeySequence &other) const-
1497-
1498 Returns \c true if this key sequence is larger or equal to the-
1499 \a other key sequence; otherwise returns \c false.-
1500-
1501 \sa operator==(), operator!=(), operator<(), operator>(), operator<=()-
1502*/-
1503-
1504/*!-
1505 \internal-
1506*/-
1507bool QKeySequence::isDetached() const-
1508{-
1509 return d->ref.load() == 1;
never executed: return d->ref.load() == 1;
0
1510}-
1511-
1512/*!-
1513 \since 4.1-
1514-
1515 Return a string representation of the key sequence,-
1516 based on \a format.-
1517-
1518 For example, the value Qt::CTRL+Qt::Key_O results in "Ctrl+O".-
1519 If the key sequence has multiple key codes, each is separated-
1520 by commas in the string returned, such as "Alt+X, Ctrl+Y, Z".-
1521 The strings, "Ctrl", "Shift", etc. are translated using-
1522 QObject::tr() in the "QShortcut" context.-
1523-
1524 If the key sequence has no keys, an empty string is returned.-
1525-
1526 On \macos, the string returned resembles the sequence that is-
1527 shown in the menu bar if \a format is-
1528 QKeySequence::NativeText; otherwise, the string uses the-
1529 "portable" format, suitable for writing to a file.-
1530-
1531 \sa fromString()-
1532*/-
1533QString QKeySequence::toString(SequenceFormat format) const-
1534{-
1535 QString finalString;-
1536 // A standard string, with no translation or anything like that. In some ways it will-
1537 // look like our latin case on Windows and X11-
1538 int end = count();-
1539 for (int i = 0; i < end; ++i) {
i < endDescription
TRUEnever evaluated
FALSEnever evaluated
0
1540 finalString += d->encodeString(d->key[i], format);-
1541 finalString += QLatin1String(", ");-
1542 }
never executed: end of block
0
1543 finalString.truncate(finalString.length() - 2);-
1544 return finalString;
never executed: return finalString;
0
1545}-
1546-
1547/*!-
1548 \since 4.1-
1549-
1550 Return a QKeySequence from the string \a str based on \a format.-
1551-
1552 \sa toString()-
1553*/-
1554QKeySequence QKeySequence::fromString(const QString &str, SequenceFormat format)-
1555{-
1556 return QKeySequence(str, format);
never executed: return QKeySequence(str, format);
0
1557}-
1558-
1559/*!-
1560 \since 5.1-
1561-
1562 Return a list of QKeySequence from the string \a str based on \a format.-
1563-
1564 \sa fromString()-
1565 \sa listToString()-
1566*/-
1567QList<QKeySequence> QKeySequence::listFromString(const QString &str, SequenceFormat format)-
1568{-
1569 QList<QKeySequence> result;-
1570-
1571 const QStringList strings = str.split(QLatin1String("; "));-
1572 result.reserve(strings.count());-
1573 for (const QString &string : strings) {-
1574 result << fromString(string, format);-
1575 }
never executed: end of block
0
1576-
1577 return result;
never executed: return result;
0
1578}-
1579-
1580/*!-
1581 \since 5.1-
1582-
1583 Return a string representation of \a list based on \a format.-
1584-
1585 \sa toString()-
1586 \sa listFromString()-
1587*/-
1588QString QKeySequence::listToString(const QList<QKeySequence> &list, SequenceFormat format)-
1589{-
1590 QString result;-
1591-
1592 for (const QKeySequence &sequence : list) {-
1593 result += sequence.toString(format);-
1594 result += QLatin1String("; ");-
1595 }
never executed: end of block
0
1596 result.truncate(result.length() - 2);-
1597-
1598 return result;
never executed: return result;
0
1599}-
1600-
1601/*****************************************************************************-
1602 QKeySequence stream functions-
1603 *****************************************************************************/-
1604#if !defined(QT_NO_DATASTREAM)-
1605/*!-
1606 \fn QDataStream &operator<<(QDataStream &stream, const QKeySequence &sequence)-
1607 \relates QKeySequence-
1608-
1609 Writes the key \a sequence to the \a stream.-
1610-
1611 \sa{Serializing Qt Data Types}{Format of the QDataStream operators}-
1612*/-
1613QDataStream &operator<<(QDataStream &s, const QKeySequence &keysequence)-
1614{-
1615 Q_STATIC_ASSERT_X(QKeySequencePrivate::MaxKeyCount == 4, "Forgot to adapt QDataStream &operator<<(QDataStream &s, const QKeySequence &keysequence) to new QKeySequence::MaxKeyCount");-
1616 const bool extended = s.version() >= 5 && keysequence.count() > 1;
s.version() >= 5Description
TRUEnever evaluated
FALSEnever evaluated
keysequence.count() > 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1617 s << quint32(extended ? 4 : 1) << quint32(keysequence.d->key[0]);-
1618 if (extended) {
extendedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1619 s << quint32(keysequence.d->key[1])-
1620 << quint32(keysequence.d->key[2])-
1621 << quint32(keysequence.d->key[3]);-
1622 }
never executed: end of block
0
1623 return s;
never executed: return s;
0
1624}-
1625-
1626-
1627/*!-
1628 \fn QDataStream &operator>>(QDataStream &stream, QKeySequence &sequence)-
1629 \relates QKeySequence-
1630-
1631 Reads a key sequence from the \a stream into the key \a sequence.-
1632-
1633 \sa{Serializing Qt Data Types}{Format of the QDataStream operators}-
1634*/-
1635QDataStream &operator>>(QDataStream &s, QKeySequence &keysequence)-
1636{-
1637 const quint32 MaxKeys = QKeySequencePrivate::MaxKeyCount;-
1638 quint32 c;-
1639 s >> c;-
1640 quint32 keys[MaxKeys] = {0};-
1641 for (uint i = 0; i < qMin(c, MaxKeys); ++i) {
i < qMin(c, MaxKeys)Description
TRUEnever evaluated
FALSEnever evaluated
0
1642 if (s.atEnd()) {
s.atEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
1643 qWarning("Premature EOF while reading QKeySequence");-
1644 return s;
never executed: return s;
0
1645 }-
1646 s >> keys[i];-
1647 }
never executed: end of block
0
1648 qAtomicDetach(keysequence.d);-
1649 std::copy(keys, keys + MaxKeys, QT_MAKE_CHECKED_ARRAY_ITERATOR(keysequence.d->key, MaxKeys));-
1650 return s;
never executed: return s;
0
1651}-
1652-
1653#endif //QT_NO_DATASTREAM-
1654-
1655#ifndef QT_NO_DEBUG_STREAM-
1656QDebug operator<<(QDebug dbg, const QKeySequence &p)-
1657{-
1658 QDebugStateSaver saver(dbg);-
1659 dbg.nospace() << "QKeySequence(" << p.toString() << ')';-
1660 return dbg;
never executed: return dbg;
0
1661}-
1662#endif-
1663-
1664#endif // QT_NO_SHORTCUT-
1665-
1666-
1667/*!-
1668 \typedef QKeySequence::DataPtr-
1669 \internal-
1670*/-
1671-
1672 /*!-
1673 \fn DataPtr &QKeySequence::data_ptr()-
1674 \internal-
1675*/-
1676-
1677QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9