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

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