Qt 4.8
qkeysequence.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
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 Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/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 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qkeysequence.h"
43 #include "qkeysequence_p.h"
44 #include "private/qapplication_p.h"
45 
46 #ifndef QT_NO_SHORTCUT
47 
48 #include "qshortcut.h"
49 #include "qdebug.h"
50 #ifndef QT_NO_REGEXP
51 # include "qregexp.h"
52 #endif
53 #ifndef QT_NO_DATASTREAM
54 # include "qdatastream.h"
55 #endif
56 #include "qvariant.h"
57 
58 #ifdef Q_WS_MAC
59 # include <private/qt_mac_p.h>
60 
61 #endif
62 
64 
65 #ifdef Q_WS_MAC
66 static bool qt_sequence_no_mnemonics = true;
67 struct MacSpecialKey {
68  int key;
70 };
71 
72 static const int NumEntries = 21;
73 static const MacSpecialKey entries[NumEntries] = {
74  { Qt::Key_Escape, 0x238B },
75  { Qt::Key_Tab, 0x21E5 },
76  { Qt::Key_Backtab, 0x21E4 },
77  { Qt::Key_Backspace, 0x232B },
78  { Qt::Key_Return, 0x21B5 },
79  { Qt::Key_Enter, 0x2324 },
80  { Qt::Key_Delete, 0x2326 },
81  { Qt::Key_Home, 0x2196 },
82  { Qt::Key_End, 0x2198 },
83  { Qt::Key_Left, 0x2190 },
84  { Qt::Key_Up, 0x2191 },
85  { Qt::Key_Right, 0x2192 },
86  { Qt::Key_Down, 0x2193 },
87  { Qt::Key_PageUp, 0x21DE },
88  { Qt::Key_PageDown, 0x21DF },
89  { Qt::Key_Shift, kShiftUnicode },
90  { Qt::Key_Control, kCommandUnicode },
91  { Qt::Key_Meta, kControlUnicode },
92  { Qt::Key_Alt, kOptionUnicode },
93  { Qt::Key_CapsLock, 0x21EA },
94 };
95 
96 static bool operator<(const MacSpecialKey &entry, int key)
97 {
98  return entry.key < key;
99 }
100 
101 static bool operator<(int key, const MacSpecialKey &entry)
102 {
103  return key < entry.key;
104 }
105 
106 static const MacSpecialKey * const MacSpecialKeyEntriesEnd = entries + NumEntries;
107 
109 {
110  const MacSpecialKey *i = qBinaryFind(entries, MacSpecialKeyEntriesEnd, key);
111  if (i == MacSpecialKeyEntriesEnd)
112  return QChar();
114  if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)
115  && (macSymbol == kControlUnicode || macSymbol == kCommandUnicode)) {
116  if (macSymbol == kControlUnicode)
117  macSymbol = kCommandUnicode;
118  else
119  macSymbol = kControlUnicode;
120  }
121 
122  return QChar(macSymbol);
123 }
124 
125 static int qtkeyForMacSymbol(const QChar ch)
126 {
127  const ushort unicode = ch.unicode();
128  for (int i = 0; i < NumEntries; ++i) {
129  const MacSpecialKey &entry = entries[i];
130  if (entry.macSymbol == unicode) {
131  int key = entry.key;
132  if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)
133  && (unicode == kControlUnicode || unicode == kCommandUnicode)) {
134  if (unicode == kControlUnicode)
135  key = Qt::Key_Control;
136  else
137  key = Qt::Key_Meta;
138  }
139  return key;
140  }
141  }
142  return -1;
143 }
144 
145 #else
146 static bool qt_sequence_no_mnemonics = false;
147 #endif
149 
394 static const struct {
395  int key;
396  const char* name;
397 } keyname[] = {
398  //: This and all following "incomprehensible" strings in QShortcut context
399  //: are key names. Please use the localized names appearing on actual
400  //: keyboards or whatever is commonly used.
401  { Qt::Key_Space, QT_TRANSLATE_NOOP("QShortcut", "Space") },
402  { Qt::Key_Escape, QT_TRANSLATE_NOOP("QShortcut", "Esc") },
403  { Qt::Key_Tab, QT_TRANSLATE_NOOP("QShortcut", "Tab") },
404  { Qt::Key_Backtab, QT_TRANSLATE_NOOP("QShortcut", "Backtab") },
405  { Qt::Key_Backspace, QT_TRANSLATE_NOOP("QShortcut", "Backspace") },
406  { Qt::Key_Return, QT_TRANSLATE_NOOP("QShortcut", "Return") },
407  { Qt::Key_Enter, QT_TRANSLATE_NOOP("QShortcut", "Enter") },
408  { Qt::Key_Insert, QT_TRANSLATE_NOOP("QShortcut", "Ins") },
409  { Qt::Key_Delete, QT_TRANSLATE_NOOP("QShortcut", "Del") },
410  { Qt::Key_Pause, QT_TRANSLATE_NOOP("QShortcut", "Pause") },
411  { Qt::Key_Print, QT_TRANSLATE_NOOP("QShortcut", "Print") },
412  { Qt::Key_SysReq, QT_TRANSLATE_NOOP("QShortcut", "SysReq") },
413  { Qt::Key_Home, QT_TRANSLATE_NOOP("QShortcut", "Home") },
414  { Qt::Key_End, QT_TRANSLATE_NOOP("QShortcut", "End") },
415  { Qt::Key_Left, QT_TRANSLATE_NOOP("QShortcut", "Left") },
416  { Qt::Key_Up, QT_TRANSLATE_NOOP("QShortcut", "Up") },
417  { Qt::Key_Right, QT_TRANSLATE_NOOP("QShortcut", "Right") },
418  { Qt::Key_Down, QT_TRANSLATE_NOOP("QShortcut", "Down") },
419  { Qt::Key_PageUp, QT_TRANSLATE_NOOP("QShortcut", "PgUp") },
420  { Qt::Key_PageDown, QT_TRANSLATE_NOOP("QShortcut", "PgDown") },
421  { Qt::Key_CapsLock, QT_TRANSLATE_NOOP("QShortcut", "CapsLock") },
422  { Qt::Key_NumLock, QT_TRANSLATE_NOOP("QShortcut", "NumLock") },
423  { Qt::Key_ScrollLock, QT_TRANSLATE_NOOP("QShortcut", "ScrollLock") },
424  { Qt::Key_Menu, QT_TRANSLATE_NOOP("QShortcut", "Menu") },
425  { Qt::Key_Help, QT_TRANSLATE_NOOP("QShortcut", "Help") },
426 
427  // Special keys
428  // Includes multimedia, launcher, lan keys ( bluetooth, wireless )
429  // window navigation
430  { Qt::Key_Back, QT_TRANSLATE_NOOP("QShortcut", "Back") },
431  { Qt::Key_Forward, QT_TRANSLATE_NOOP("QShortcut", "Forward") },
432  { Qt::Key_Stop, QT_TRANSLATE_NOOP("QShortcut", "Stop") },
433  { Qt::Key_Refresh, QT_TRANSLATE_NOOP("QShortcut", "Refresh") },
434  { Qt::Key_VolumeDown, QT_TRANSLATE_NOOP("QShortcut", "Volume Down") },
435  { Qt::Key_VolumeMute, QT_TRANSLATE_NOOP("QShortcut", "Volume Mute") },
436  { Qt::Key_VolumeUp, QT_TRANSLATE_NOOP("QShortcut", "Volume Up") },
437  { Qt::Key_BassBoost, QT_TRANSLATE_NOOP("QShortcut", "Bass Boost") },
438  { Qt::Key_BassUp, QT_TRANSLATE_NOOP("QShortcut", "Bass Up") },
439  { Qt::Key_BassDown, QT_TRANSLATE_NOOP("QShortcut", "Bass Down") },
440  { Qt::Key_TrebleUp, QT_TRANSLATE_NOOP("QShortcut", "Treble Up") },
441  { Qt::Key_TrebleDown, QT_TRANSLATE_NOOP("QShortcut", "Treble Down") },
442  { Qt::Key_MediaPlay, QT_TRANSLATE_NOOP("QShortcut", "Media Play") },
443  { Qt::Key_MediaStop, QT_TRANSLATE_NOOP("QShortcut", "Media Stop") },
444  { Qt::Key_MediaPrevious, QT_TRANSLATE_NOOP("QShortcut", "Media Previous") },
445  { Qt::Key_MediaNext, QT_TRANSLATE_NOOP("QShortcut", "Media Next") },
446  { Qt::Key_MediaRecord, QT_TRANSLATE_NOOP("QShortcut", "Media Record") },
447  //: Media player pause button
448  { Qt::Key_MediaPause, QT_TRANSLATE_NOOP("QShortcut", "Media Pause") },
449  //: Media player button to toggle between playing and paused
450  { Qt::Key_MediaTogglePlayPause, QT_TRANSLATE_NOOP("QShortcut", "Toggle Media Play/Pause") },
451  { Qt::Key_HomePage, QT_TRANSLATE_NOOP("QShortcut", "Home Page") },
452  { Qt::Key_Favorites, QT_TRANSLATE_NOOP("QShortcut", "Favorites") },
453  { Qt::Key_Search, QT_TRANSLATE_NOOP("QShortcut", "Search") },
454  { Qt::Key_Standby, QT_TRANSLATE_NOOP("QShortcut", "Standby") },
455  { Qt::Key_OpenUrl, QT_TRANSLATE_NOOP("QShortcut", "Open URL") },
456  { Qt::Key_LaunchMail, QT_TRANSLATE_NOOP("QShortcut", "Launch Mail") },
457  { Qt::Key_LaunchMedia, QT_TRANSLATE_NOOP("QShortcut", "Launch Media") },
458  { Qt::Key_Launch0, QT_TRANSLATE_NOOP("QShortcut", "Launch (0)") },
459  { Qt::Key_Launch1, QT_TRANSLATE_NOOP("QShortcut", "Launch (1)") },
460  { Qt::Key_Launch2, QT_TRANSLATE_NOOP("QShortcut", "Launch (2)") },
461  { Qt::Key_Launch3, QT_TRANSLATE_NOOP("QShortcut", "Launch (3)") },
462  { Qt::Key_Launch4, QT_TRANSLATE_NOOP("QShortcut", "Launch (4)") },
463  { Qt::Key_Launch5, QT_TRANSLATE_NOOP("QShortcut", "Launch (5)") },
464  { Qt::Key_Launch6, QT_TRANSLATE_NOOP("QShortcut", "Launch (6)") },
465  { Qt::Key_Launch7, QT_TRANSLATE_NOOP("QShortcut", "Launch (7)") },
466  { Qt::Key_Launch8, QT_TRANSLATE_NOOP("QShortcut", "Launch (8)") },
467  { Qt::Key_Launch9, QT_TRANSLATE_NOOP("QShortcut", "Launch (9)") },
468  { Qt::Key_LaunchA, QT_TRANSLATE_NOOP("QShortcut", "Launch (A)") },
469  { Qt::Key_LaunchB, QT_TRANSLATE_NOOP("QShortcut", "Launch (B)") },
470  { Qt::Key_LaunchC, QT_TRANSLATE_NOOP("QShortcut", "Launch (C)") },
471  { Qt::Key_LaunchD, QT_TRANSLATE_NOOP("QShortcut", "Launch (D)") },
472  { Qt::Key_LaunchE, QT_TRANSLATE_NOOP("QShortcut", "Launch (E)") },
473  { Qt::Key_LaunchF, QT_TRANSLATE_NOOP("QShortcut", "Launch (F)") },
474  { Qt::Key_MonBrightnessUp, QT_TRANSLATE_NOOP("QShortcut", "Monitor Brightness Up") },
475  { Qt::Key_MonBrightnessDown, QT_TRANSLATE_NOOP("QShortcut", "Monitor Brightness Down") },
476  { Qt::Key_KeyboardLightOnOff, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Light On/Off") },
477  { Qt::Key_KeyboardBrightnessUp, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Brightness Up") },
478  { Qt::Key_KeyboardBrightnessDown, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Brightness Down") },
479  { Qt::Key_PowerOff, QT_TRANSLATE_NOOP("QShortcut", "Power Off") },
480  { Qt::Key_WakeUp, QT_TRANSLATE_NOOP("QShortcut", "Wake Up") },
481  { Qt::Key_Eject, QT_TRANSLATE_NOOP("QShortcut", "Eject") },
482  { Qt::Key_ScreenSaver, QT_TRANSLATE_NOOP("QShortcut", "Screensaver") },
483  { Qt::Key_WWW, QT_TRANSLATE_NOOP("QShortcut", "WWW") },
484  { Qt::Key_Sleep, QT_TRANSLATE_NOOP("QShortcut", "Sleep") },
485  { Qt::Key_LightBulb, QT_TRANSLATE_NOOP("QShortcut", "LightBulb") },
486  { Qt::Key_Shop, QT_TRANSLATE_NOOP("QShortcut", "Shop") },
487  { Qt::Key_History, QT_TRANSLATE_NOOP("QShortcut", "History") },
488  { Qt::Key_AddFavorite, QT_TRANSLATE_NOOP("QShortcut", "Add Favorite") },
489  { Qt::Key_HotLinks, QT_TRANSLATE_NOOP("QShortcut", "Hot Links") },
490  { Qt::Key_BrightnessAdjust, QT_TRANSLATE_NOOP("QShortcut", "Adjust Brightness") },
491  { Qt::Key_Finance, QT_TRANSLATE_NOOP("QShortcut", "Finance") },
492  { Qt::Key_Community, QT_TRANSLATE_NOOP("QShortcut", "Community") },
493  { Qt::Key_AudioRewind, QT_TRANSLATE_NOOP("QShortcut", "Audio Rewind") },
494  { Qt::Key_BackForward, QT_TRANSLATE_NOOP("QShortcut", "Back Forward") },
495  { Qt::Key_ApplicationLeft, QT_TRANSLATE_NOOP("QShortcut", "Application Left") },
496  { Qt::Key_ApplicationRight, QT_TRANSLATE_NOOP("QShortcut", "Application Right") },
497  { Qt::Key_Book, QT_TRANSLATE_NOOP("QShortcut", "Book") },
498  { Qt::Key_CD, QT_TRANSLATE_NOOP("QShortcut", "CD") },
499  { Qt::Key_Calculator, QT_TRANSLATE_NOOP("QShortcut", "Calculator") },
500  { Qt::Key_Clear, QT_TRANSLATE_NOOP("QShortcut", "Clear") },
501  { Qt::Key_ClearGrab, QT_TRANSLATE_NOOP("QShortcut", "Clear Grab") },
502  { Qt::Key_Close, QT_TRANSLATE_NOOP("QShortcut", "Close") },
503  { Qt::Key_Copy, QT_TRANSLATE_NOOP("QShortcut", "Copy") },
504  { Qt::Key_Cut, QT_TRANSLATE_NOOP("QShortcut", "Cut") },
505  { Qt::Key_Display, QT_TRANSLATE_NOOP("QShortcut", "Display") },
506  { Qt::Key_DOS, QT_TRANSLATE_NOOP("QShortcut", "DOS") },
507  { Qt::Key_Documents, QT_TRANSLATE_NOOP("QShortcut", "Documents") },
508  { Qt::Key_Excel, QT_TRANSLATE_NOOP("QShortcut", "Spreadsheet") },
509  { Qt::Key_Explorer, QT_TRANSLATE_NOOP("QShortcut", "Browser") },
510  { Qt::Key_Game, QT_TRANSLATE_NOOP("QShortcut", "Game") },
511  { Qt::Key_Go, QT_TRANSLATE_NOOP("QShortcut", "Go") },
512  { Qt::Key_iTouch, QT_TRANSLATE_NOOP("QShortcut", "iTouch") },
513  { Qt::Key_LogOff, QT_TRANSLATE_NOOP("QShortcut", "Logoff") },
514  { Qt::Key_Market, QT_TRANSLATE_NOOP("QShortcut", "Market") },
515  { Qt::Key_Meeting, QT_TRANSLATE_NOOP("QShortcut", "Meeting") },
516  { Qt::Key_MenuKB, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Menu") },
517  { Qt::Key_MenuPB, QT_TRANSLATE_NOOP("QShortcut", "Menu PB") },
518  { Qt::Key_MySites, QT_TRANSLATE_NOOP("QShortcut", "My Sites") },
519  { Qt::Key_News, QT_TRANSLATE_NOOP("QShortcut", "News") },
520  { Qt::Key_OfficeHome, QT_TRANSLATE_NOOP("QShortcut", "Home Office") },
521  { Qt::Key_Option, QT_TRANSLATE_NOOP("QShortcut", "Option") },
522  { Qt::Key_Paste, QT_TRANSLATE_NOOP("QShortcut", "Paste") },
523  { Qt::Key_Phone, QT_TRANSLATE_NOOP("QShortcut", "Phone") },
524  { Qt::Key_Reply, QT_TRANSLATE_NOOP("QShortcut", "Reply") },
525  { Qt::Key_Reload, QT_TRANSLATE_NOOP("QShortcut", "Reload") },
526  { Qt::Key_RotateWindows, QT_TRANSLATE_NOOP("QShortcut", "Rotate Windows") },
527  { Qt::Key_RotationPB, QT_TRANSLATE_NOOP("QShortcut", "Rotation PB") },
528  { Qt::Key_RotationKB, QT_TRANSLATE_NOOP("QShortcut", "Rotation KB") },
529  { Qt::Key_Save, QT_TRANSLATE_NOOP("QShortcut", "Save") },
530  { Qt::Key_Send, QT_TRANSLATE_NOOP("QShortcut", "Send") },
531  { Qt::Key_Spell, QT_TRANSLATE_NOOP("QShortcut", "Spellchecker") },
532  { Qt::Key_SplitScreen, QT_TRANSLATE_NOOP("QShortcut", "Split Screen") },
533  { Qt::Key_Support, QT_TRANSLATE_NOOP("QShortcut", "Support") },
534  { Qt::Key_TaskPane, QT_TRANSLATE_NOOP("QShortcut", "Task Panel") },
535  { Qt::Key_Terminal, QT_TRANSLATE_NOOP("QShortcut", "Terminal") },
536  { Qt::Key_Tools, QT_TRANSLATE_NOOP("QShortcut", "Tools") },
537  { Qt::Key_Travel, QT_TRANSLATE_NOOP("QShortcut", "Travel") },
538  { Qt::Key_Video, QT_TRANSLATE_NOOP("QShortcut", "Video") },
539  { Qt::Key_Word, QT_TRANSLATE_NOOP("QShortcut", "Word Processor") },
540  { Qt::Key_Xfer, QT_TRANSLATE_NOOP("QShortcut", "XFer") },
541  { Qt::Key_ZoomIn, QT_TRANSLATE_NOOP("QShortcut", "Zoom In") },
542  { Qt::Key_ZoomOut, QT_TRANSLATE_NOOP("QShortcut", "Zoom Out") },
543  { Qt::Key_Away, QT_TRANSLATE_NOOP("QShortcut", "Away") },
544  { Qt::Key_Messenger, QT_TRANSLATE_NOOP("QShortcut", "Messenger") },
545  { Qt::Key_WebCam, QT_TRANSLATE_NOOP("QShortcut", "WebCam") },
546  { Qt::Key_MailForward, QT_TRANSLATE_NOOP("QShortcut", "Mail Forward") },
547  { Qt::Key_Pictures, QT_TRANSLATE_NOOP("QShortcut", "Pictures") },
548  { Qt::Key_Music, QT_TRANSLATE_NOOP("QShortcut", "Music") },
549  { Qt::Key_Battery, QT_TRANSLATE_NOOP("QShortcut", "Battery") },
550  { Qt::Key_Bluetooth, QT_TRANSLATE_NOOP("QShortcut", "Bluetooth") },
551  { Qt::Key_WLAN, QT_TRANSLATE_NOOP("QShortcut", "Wireless") },
552  { Qt::Key_UWB, QT_TRANSLATE_NOOP("QShortcut", "Ultra Wide Band") },
553  { Qt::Key_AudioForward, QT_TRANSLATE_NOOP("QShortcut", "Audio Forward") },
554  { Qt::Key_AudioRepeat, QT_TRANSLATE_NOOP("QShortcut", "Audio Repeat") },
555  { Qt::Key_AudioRandomPlay, QT_TRANSLATE_NOOP("QShortcut", "Audio Random Play") },
556  { Qt::Key_Subtitle, QT_TRANSLATE_NOOP("QShortcut", "Subtitle") },
557  { Qt::Key_AudioCycleTrack, QT_TRANSLATE_NOOP("QShortcut", "Audio Cycle Track") },
558  { Qt::Key_Time, QT_TRANSLATE_NOOP("QShortcut", "Time") },
559  { Qt::Key_Select, QT_TRANSLATE_NOOP("QShortcut", "Select") },
560  { Qt::Key_View, QT_TRANSLATE_NOOP("QShortcut", "View") },
561  { Qt::Key_TopMenu, QT_TRANSLATE_NOOP("QShortcut", "Top Menu") },
562  { Qt::Key_Suspend, QT_TRANSLATE_NOOP("QShortcut", "Suspend") },
563  { Qt::Key_Hibernate, QT_TRANSLATE_NOOP("QShortcut", "Hibernate") },
564 
565  // --------------------------------------------------------------
566  // More consistent namings
567  { Qt::Key_Print, QT_TRANSLATE_NOOP("QShortcut", "Print Screen") },
568  { Qt::Key_PageUp, QT_TRANSLATE_NOOP("QShortcut", "Page Up") },
569  { Qt::Key_PageDown, QT_TRANSLATE_NOOP("QShortcut", "Page Down") },
570  { Qt::Key_CapsLock, QT_TRANSLATE_NOOP("QShortcut", "Caps Lock") },
571  { Qt::Key_NumLock, QT_TRANSLATE_NOOP("QShortcut", "Num Lock") },
572  { Qt::Key_NumLock, QT_TRANSLATE_NOOP("QShortcut", "Number Lock") },
573  { Qt::Key_ScrollLock, QT_TRANSLATE_NOOP("QShortcut", "Scroll Lock") },
574  { Qt::Key_Insert, QT_TRANSLATE_NOOP("QShortcut", "Insert") },
575  { Qt::Key_Delete, QT_TRANSLATE_NOOP("QShortcut", "Delete") },
576  { Qt::Key_Escape, QT_TRANSLATE_NOOP("QShortcut", "Escape") },
577  { Qt::Key_SysReq, QT_TRANSLATE_NOOP("QShortcut", "System Request") },
578 
579  // --------------------------------------------------------------
580  // Keypad navigation keys
581  { Qt::Key_Select, QT_TRANSLATE_NOOP("QShortcut", "Select") },
582  { Qt::Key_Yes, QT_TRANSLATE_NOOP("QShortcut", "Yes") },
583  { Qt::Key_No, QT_TRANSLATE_NOOP("QShortcut", "No") },
584 
585  // --------------------------------------------------------------
586  // Device keys
587  { Qt::Key_Context1, QT_TRANSLATE_NOOP("QShortcut", "Context1") },
588  { Qt::Key_Context2, QT_TRANSLATE_NOOP("QShortcut", "Context2") },
589  { Qt::Key_Context3, QT_TRANSLATE_NOOP("QShortcut", "Context3") },
590  { Qt::Key_Context4, QT_TRANSLATE_NOOP("QShortcut", "Context4") },
591  //: Button to start a call (note: a separate button is used to end the call)
592  { Qt::Key_Call, QT_TRANSLATE_NOOP("QShortcut", "Call") },
593  //: Button to end a call (note: a separate button is used to start the call)
594  { Qt::Key_Hangup, QT_TRANSLATE_NOOP("QShortcut", "Hangup") },
595  //: Button that will hang up if we're in call, or make a call if we're not.
596  { Qt::Key_ToggleCallHangup, QT_TRANSLATE_NOOP("QShortcut", "Toggle Call/Hangup") },
597  { Qt::Key_Flip, QT_TRANSLATE_NOOP("QShortcut", "Flip") },
598  //: Button to trigger voice dialing
599  { Qt::Key_VoiceDial, QT_TRANSLATE_NOOP("QShortcut", "Voice Dial") },
600  //: Button to redial the last number called
601  { Qt::Key_LastNumberRedial, QT_TRANSLATE_NOOP("QShortcut", "Last Number Redial") },
602  //: Button to trigger the camera shutter (take a picture)
603  { Qt::Key_Camera, QT_TRANSLATE_NOOP("QShortcut", "Camera Shutter") },
604  //: Button to focus the camera
605  { Qt::Key_CameraFocus, QT_TRANSLATE_NOOP("QShortcut", "Camera Focus") },
606 
607  // --------------------------------------------------------------
608  // Japanese keyboard support
609  { Qt::Key_Kanji, QT_TRANSLATE_NOOP("QShortcut", "Kanji") },
610  { Qt::Key_Muhenkan, QT_TRANSLATE_NOOP("QShortcut", "Muhenkan") },
611  { Qt::Key_Henkan, QT_TRANSLATE_NOOP("QShortcut", "Henkan") },
612  { Qt::Key_Romaji, QT_TRANSLATE_NOOP("QShortcut", "Romaji") },
613  { Qt::Key_Hiragana, QT_TRANSLATE_NOOP("QShortcut", "Hiragana") },
614  { Qt::Key_Katakana, QT_TRANSLATE_NOOP("QShortcut", "Katakana") },
615  { Qt::Key_Hiragana_Katakana,QT_TRANSLATE_NOOP("QShortcut", "Hiragana Katakana") },
616  { Qt::Key_Zenkaku, QT_TRANSLATE_NOOP("QShortcut", "Zenkaku") },
617  { Qt::Key_Hankaku, QT_TRANSLATE_NOOP("QShortcut", "Hankaku") },
618  { Qt::Key_Zenkaku_Hankaku, QT_TRANSLATE_NOOP("QShortcut", "Zenkaku Hankaku") },
619  { Qt::Key_Touroku, QT_TRANSLATE_NOOP("QShortcut", "Touroku") },
620  { Qt::Key_Massyo, QT_TRANSLATE_NOOP("QShortcut", "Massyo") },
621  { Qt::Key_Kana_Lock, QT_TRANSLATE_NOOP("QShortcut", "Kana Lock") },
622  { Qt::Key_Kana_Shift, QT_TRANSLATE_NOOP("QShortcut", "Kana Shift") },
623  { Qt::Key_Eisu_Shift, QT_TRANSLATE_NOOP("QShortcut", "Eisu Shift") },
624  { Qt::Key_Eisu_toggle, QT_TRANSLATE_NOOP("QShortcut", "Eisu toggle") },
625  { Qt::Key_Codeinput, QT_TRANSLATE_NOOP("QShortcut", "Code input") },
626  { Qt::Key_MultipleCandidate,QT_TRANSLATE_NOOP("QShortcut", "Multiple Candidate") },
627  { Qt::Key_PreviousCandidate,QT_TRANSLATE_NOOP("QShortcut", "Previous Candidate") },
628 
629  // --------------------------------------------------------------
630  // Korean keyboard support
631  { Qt::Key_Hangul, QT_TRANSLATE_NOOP("QShortcut", "Hangul") },
632  { Qt::Key_Hangul_Start, QT_TRANSLATE_NOOP("QShortcut", "Hangul Start") },
633  { Qt::Key_Hangul_End, QT_TRANSLATE_NOOP("QShortcut", "Hangul End") },
634  { Qt::Key_Hangul_Hanja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Hanja") },
635  { Qt::Key_Hangul_Jamo, QT_TRANSLATE_NOOP("QShortcut", "Hangul Jamo") },
636  { Qt::Key_Hangul_Romaja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Romaja") },
637  { Qt::Key_Hangul_Jeonja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Jeonja") },
638  { Qt::Key_Hangul_Banja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Banja") },
639  { Qt::Key_Hangul_PreHanja, QT_TRANSLATE_NOOP("QShortcut", "Hangul PreHanja") },
640  { Qt::Key_Hangul_PostHanja,QT_TRANSLATE_NOOP("QShortcut", "Hangul PostHanja") },
641  { Qt::Key_Hangul_Special, QT_TRANSLATE_NOOP("QShortcut", "Hangul Special") },
642 
643  { 0, 0 }
644 };
645 
646 //Table of key bindings. It must be sorted on key sequence.
647 //A priority of 1 indicates that this is the primary key binding when multiple are defined.
648 
650 // StandardKey Priority Key Sequence Platforms
653  {QKeySequence::InsertParagraphSeparator,0, Qt::Key_Enter, QApplicationPrivate::KB_All},
654  {QKeySequence::Delete, 1, Qt::Key_Delete, QApplicationPrivate::KB_All},
658  {QKeySequence::MoveToEndOfDocument, 0, Qt::Key_End, QApplicationPrivate::KB_Mac},
659  {QKeySequence::MoveToPreviousChar, 0, Qt::Key_Left, QApplicationPrivate::KB_All},
660  {QKeySequence::MoveToPreviousLine, 0, Qt::Key_Up, QApplicationPrivate::KB_All},
661  {QKeySequence::MoveToNextChar, 0, Qt::Key_Right, QApplicationPrivate::KB_All},
662  {QKeySequence::MoveToNextLine, 0, Qt::Key_Down, QApplicationPrivate::KB_All},
663  {QKeySequence::MoveToPreviousPage, 1, Qt::Key_PageUp, QApplicationPrivate::KB_All},
664  {QKeySequence::MoveToNextPage, 1, Qt::Key_PageDown, QApplicationPrivate::KB_All},
665  {QKeySequence::HelpContents, 0, Qt::Key_F1, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11},
668  {QKeySequence::FindNext, 1, Qt::Key_F3, QApplicationPrivate::KB_Win},
669  {QKeySequence::Refresh, 0, Qt::Key_F5, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11},
670  {QKeySequence::Undo, 0, Qt::Key_F14, QApplicationPrivate::KB_X11}, //Undo on sun keyboards
671  {QKeySequence::Copy, 0, Qt::Key_F16, QApplicationPrivate::KB_X11}, //Copy on sun keyboards
672  {QKeySequence::Paste, 0, Qt::Key_F18, QApplicationPrivate::KB_X11}, //Paste on sun keyboards
673  {QKeySequence::Cut, 0, Qt::Key_F20, QApplicationPrivate::KB_X11}, //Cut on sun keyboards
674  {QKeySequence::PreviousChild, 0, Qt::Key_Back, QApplicationPrivate::KB_All},
675  {QKeySequence::NextChild, 0, Qt::Key_Forward, QApplicationPrivate::KB_All},
676  {QKeySequence::Forward, 0, Qt::SHIFT | Qt::Key_Backspace, QApplicationPrivate::KB_Win},
677  {QKeySequence::Delete, 0, Qt::SHIFT | Qt::Key_Backspace, QApplicationPrivate::KB_S60},
678  {QKeySequence::InsertLineSeparator, 0, Qt::SHIFT | Qt::Key_Return, QApplicationPrivate::KB_All},
679  {QKeySequence::InsertLineSeparator, 0, Qt::SHIFT | Qt::Key_Enter, QApplicationPrivate::KB_All},
680  {QKeySequence::Paste, 0, Qt::SHIFT | Qt::Key_Insert, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11},
681  {QKeySequence::Cut, 0, Qt::SHIFT | Qt::Key_Delete, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11}, //## Check if this should work on mac
682  {QKeySequence::SelectStartOfLine, 0, Qt::SHIFT | Qt::Key_Home, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60},
683  {QKeySequence::SelectStartOfDocument, 0, Qt::SHIFT | Qt::Key_Home, QApplicationPrivate::KB_Mac},
684  {QKeySequence::SelectEndOfLine, 0, Qt::SHIFT | Qt::Key_End, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60},
685  {QKeySequence::SelectEndOfDocument, 0, Qt::SHIFT | Qt::Key_End, QApplicationPrivate::KB_Mac},
686  {QKeySequence::SelectPreviousChar, 0, Qt::SHIFT | Qt::Key_Left, QApplicationPrivate::KB_All},
687  {QKeySequence::SelectPreviousLine, 0, Qt::SHIFT | Qt::Key_Up, QApplicationPrivate::KB_All},
688  {QKeySequence::SelectNextChar, 0, Qt::SHIFT | Qt::Key_Right, QApplicationPrivate::KB_All},
689  {QKeySequence::SelectNextLine, 0, Qt::SHIFT | Qt::Key_Down, QApplicationPrivate::KB_All},
690  {QKeySequence::SelectPreviousPage, 0, Qt::SHIFT | Qt::Key_PageUp, QApplicationPrivate::KB_All},
691  {QKeySequence::SelectNextPage, 0, Qt::SHIFT | Qt::Key_PageDown, QApplicationPrivate::KB_All},
692  {QKeySequence::WhatsThis, 1, Qt::SHIFT | Qt::Key_F1, QApplicationPrivate::KB_All},
693  {QKeySequence::FindPrevious, 0, Qt::SHIFT | Qt::Key_F3, QApplicationPrivate::KB_X11},
694  {QKeySequence::FindPrevious, 1, Qt::SHIFT | Qt::Key_F3, QApplicationPrivate::KB_Win},
695  {QKeySequence::ZoomIn, 1, Qt::CTRL | Qt::Key_Plus, QApplicationPrivate::KB_All},
697  {QKeySequence::Preferences, 0, Qt::CTRL | Qt::Key_Comma, QApplicationPrivate::KB_Mac},
698  {QKeySequence::ZoomOut, 1, Qt::CTRL | Qt::Key_Minus, QApplicationPrivate::KB_All},
699  {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::Key_Period, QApplicationPrivate::KB_KDE},
700  {QKeySequence::HelpContents, 1, Qt::CTRL | Qt::Key_Question, QApplicationPrivate::KB_Mac},
701  {QKeySequence::SelectAll, 1, Qt::CTRL | Qt::Key_A, QApplicationPrivate::KB_All},
702  {QKeySequence::Bold, 1, Qt::CTRL | Qt::Key_B, QApplicationPrivate::KB_All},
703  {QKeySequence::Copy, 1, Qt::CTRL | Qt::Key_C, QApplicationPrivate::KB_All},
704  {QKeySequence::Delete, 0, Qt::CTRL | Qt::Key_D, QApplicationPrivate::KB_X11}, //emacs (line edit only)
705  {QKeySequence::Find, 0, Qt::CTRL | Qt::Key_F, QApplicationPrivate::KB_All},
706  {QKeySequence::FindNext, 1, Qt::CTRL | Qt::Key_G, QApplicationPrivate::KB_Gnome | QApplicationPrivate::KB_Mac},
707  {QKeySequence::FindNext, 0, Qt::CTRL | Qt::Key_G, QApplicationPrivate::KB_Win},
708  {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_H, QApplicationPrivate::KB_Win},
710  {QKeySequence::Italic, 0, Qt::CTRL | Qt::Key_I, QApplicationPrivate::KB_All},
711  {QKeySequence::DeleteEndOfLine, 0, Qt::CTRL | Qt::Key_K, QApplicationPrivate::KB_X11}, //emacs (line edit only)
712  {QKeySequence::New, 1, Qt::CTRL | Qt::Key_N, QApplicationPrivate::KB_All},
713  {QKeySequence::Open, 1, Qt::CTRL | Qt::Key_O, QApplicationPrivate::KB_All},
714  {QKeySequence::Print, 1, Qt::CTRL | Qt::Key_P, QApplicationPrivate::KB_All},
715  {QKeySequence::Quit, 0, Qt::CTRL | Qt::Key_Q, QApplicationPrivate::KB_Gnome | QApplicationPrivate::KB_KDE | QApplicationPrivate::KB_Mac},
716  {QKeySequence::Refresh, 1, Qt::CTRL | Qt::Key_R, QApplicationPrivate::KB_Gnome | QApplicationPrivate::KB_Mac},
717  {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_R, QApplicationPrivate::KB_KDE},
718  {QKeySequence::Save, 1, Qt::CTRL | Qt::Key_S, QApplicationPrivate::KB_All},
719  {QKeySequence::AddTab, 0, Qt::CTRL | Qt::Key_T, QApplicationPrivate::KB_All},
720  {QKeySequence::Underline, 1, Qt::CTRL | Qt::Key_U, QApplicationPrivate::KB_All},
721  {QKeySequence::Paste, 1, Qt::CTRL | Qt::Key_V, QApplicationPrivate::KB_All},
722  {QKeySequence::Close, 0, Qt::CTRL | Qt::Key_W, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11},
723  {QKeySequence::Close, 1, Qt::CTRL | Qt::Key_W, QApplicationPrivate::KB_Mac},
724  {QKeySequence::Cut, 1, Qt::CTRL | Qt::Key_X, QApplicationPrivate::KB_All},
725  {QKeySequence::Redo, 1, Qt::CTRL | Qt::Key_Y, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_S60},
726  {QKeySequence::Undo, 1, Qt::CTRL | Qt::Key_Z, QApplicationPrivate::KB_All},
727  {QKeySequence::Back, 1, Qt::CTRL | Qt::Key_BracketLeft, QApplicationPrivate::KB_Mac},
728  {QKeySequence::Forward, 1, Qt::CTRL | Qt::Key_BracketRight, QApplicationPrivate::KB_Mac},
729  {QKeySequence::PreviousChild, 1, Qt::CTRL | Qt::Key_BraceLeft, QApplicationPrivate::KB_Mac},
730  {QKeySequence::NextChild, 1, Qt::CTRL | Qt::Key_BraceRight, QApplicationPrivate::KB_Mac},
731  {QKeySequence::NextChild, 1, Qt::CTRL | Qt::Key_Tab, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11},
732  {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_Tab, QApplicationPrivate::KB_Mac}, //different priority from above
733  {QKeySequence::DeleteStartOfWord, 0, Qt::CTRL | Qt::Key_Backspace, QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_Win},
734  {QKeySequence::Copy, 0, Qt::CTRL | Qt::Key_Insert, QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_Win},
735  {QKeySequence::DeleteEndOfWord, 0, Qt::CTRL | Qt::Key_Delete, QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_Win},
736  {QKeySequence::MoveToStartOfDocument, 0, Qt::CTRL | Qt::Key_Home, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60},
737  {QKeySequence::MoveToEndOfDocument, 0, Qt::CTRL | Qt::Key_End, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60},
738  {QKeySequence::Back, 0, Qt::CTRL | Qt::Key_Left, QApplicationPrivate::KB_Mac},
739  {QKeySequence::MoveToPreviousWord, 0, Qt::CTRL | Qt::Key_Left, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60},
740  {QKeySequence::MoveToStartOfLine, 0, Qt::CTRL | Qt::Key_Left, QApplicationPrivate::KB_Mac },
741  {QKeySequence::MoveToStartOfDocument, 1, Qt::CTRL | Qt::Key_Up, QApplicationPrivate::KB_Mac},
742  {QKeySequence::Forward, 0, Qt::CTRL | Qt::Key_Right, QApplicationPrivate::KB_Mac},
743  {QKeySequence::MoveToEndOfLine, 0, Qt::CTRL | Qt::Key_Right, QApplicationPrivate::KB_Mac },
744  {QKeySequence::MoveToNextWord, 0, Qt::CTRL | Qt::Key_Right, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60},
745  {QKeySequence::MoveToEndOfDocument, 1, Qt::CTRL | Qt::Key_Down, QApplicationPrivate::KB_Mac},
746  {QKeySequence::Close, 1, Qt::CTRL | Qt::Key_F4, QApplicationPrivate::KB_Win},
747  {QKeySequence::Close, 0, Qt::CTRL | Qt::Key_F4, QApplicationPrivate::KB_Mac},
748  {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_F6, QApplicationPrivate::KB_Win},
749  {QKeySequence::FindPrevious, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_G, QApplicationPrivate::KB_Gnome | QApplicationPrivate::KB_Mac},
750  {QKeySequence::FindPrevious, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_G, QApplicationPrivate::KB_Win},
751  {QKeySequence::AddTab, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_N, QApplicationPrivate::KB_KDE},
752  {QKeySequence::SaveAs, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_S, QApplicationPrivate::KB_Gnome | QApplicationPrivate::KB_Mac},
753  {QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60},
754  {QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, QApplicationPrivate::KB_Mac},
755  {QKeySequence::PreviousChild, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11},
756  {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, QApplicationPrivate::KB_Mac },//different priority from above
757  {QKeySequence::Paste, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Insert, QApplicationPrivate::KB_X11},
758  {QKeySequence::SelectStartOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Home, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60},
759  {QKeySequence::SelectEndOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_End, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60},
760  {QKeySequence::SelectPreviousWord, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Left, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60},
761  {QKeySequence::SelectStartOfLine, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Left, QApplicationPrivate::KB_Mac },
762  {QKeySequence::SelectStartOfDocument, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Up, QApplicationPrivate::KB_Mac},
763  {QKeySequence::SelectNextWord, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Right, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60},
764  {QKeySequence::SelectEndOfLine, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Right, QApplicationPrivate::KB_Mac },
765  {QKeySequence::SelectEndOfDocument, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Down, QApplicationPrivate::KB_Mac},
766  {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_F6, QApplicationPrivate::KB_Win},
767  {QKeySequence::Undo, 0, Qt::ALT | Qt::Key_Backspace, QApplicationPrivate::KB_Win},
768  {QKeySequence::DeleteStartOfWord, 0, Qt::ALT | Qt::Key_Backspace, QApplicationPrivate::KB_Mac},
769  {QKeySequence::DeleteEndOfWord, 0, Qt::ALT | Qt::Key_Delete, QApplicationPrivate::KB_Mac},
770  {QKeySequence::Back, 1, Qt::ALT | Qt::Key_Left, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11},
771  {QKeySequence::MoveToPreviousWord, 0, Qt::ALT | Qt::Key_Left, QApplicationPrivate::KB_Mac},
772  {QKeySequence::MoveToStartOfBlock, 0, Qt::ALT | Qt::Key_Up, QApplicationPrivate::KB_Mac}, //mac only
773  {QKeySequence::MoveToNextWord, 0, Qt::ALT | Qt::Key_Right, QApplicationPrivate::KB_Mac},
774  {QKeySequence::Forward, 1, Qt::ALT | Qt::Key_Right, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11},
775  {QKeySequence::MoveToEndOfBlock, 0, Qt::ALT | Qt::Key_Down, QApplicationPrivate::KB_Mac}, //mac only
776  {QKeySequence::MoveToPreviousPage, 0, Qt::ALT | Qt::Key_PageUp, QApplicationPrivate::KB_Mac },
777  {QKeySequence::MoveToNextPage, 0, Qt::ALT | Qt::Key_PageDown, QApplicationPrivate::KB_Mac },
778  {QKeySequence::Redo, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Backspace,QApplicationPrivate::KB_Win},
779  {QKeySequence::SelectPreviousWord, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Left, QApplicationPrivate::KB_Mac},
780  {QKeySequence::SelectStartOfBlock, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Up, QApplicationPrivate::KB_Mac}, //mac only
781  {QKeySequence::SelectNextWord, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Right, QApplicationPrivate::KB_Mac},
782  {QKeySequence::SelectEndOfBlock, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Down, QApplicationPrivate::KB_Mac}, //mac only
783  {QKeySequence::MoveToStartOfBlock, 0, Qt::META | Qt::Key_A, QApplicationPrivate::KB_Mac},
784  {QKeySequence::Delete, 0, Qt::META | Qt::Key_D, QApplicationPrivate::KB_Mac},
785  {QKeySequence::MoveToEndOfBlock, 0, Qt::META | Qt::Key_E, QApplicationPrivate::KB_Mac},
786  {QKeySequence::InsertLineSeparator, 0, Qt::META | Qt::Key_Return, QApplicationPrivate::KB_Mac},
787  {QKeySequence::InsertLineSeparator, 0, Qt::META | Qt::Key_Enter, QApplicationPrivate::KB_Mac},
788  {QKeySequence::MoveToStartOfLine, 0, Qt::META | Qt::Key_Left, QApplicationPrivate::KB_Mac},
789  {QKeySequence::MoveToPreviousPage, 0, Qt::META | Qt::Key_Up, QApplicationPrivate::KB_Mac},
790  {QKeySequence::MoveToEndOfLine, 0, Qt::META | Qt::Key_Right, QApplicationPrivate::KB_Mac},
791  {QKeySequence::MoveToNextPage, 0, Qt::META | Qt::Key_Down, QApplicationPrivate::KB_Mac},
792  {QKeySequence::MoveToPreviousPage, 0, Qt::META | Qt::Key_PageUp, QApplicationPrivate::KB_Mac},
793  {QKeySequence::MoveToNextPage, 0, Qt::META | Qt::Key_PageDown, QApplicationPrivate::KB_Mac},
794  {QKeySequence::SelectStartOfBlock, 0, Qt::META | Qt::SHIFT | Qt::Key_A, QApplicationPrivate::KB_Mac},
795  {QKeySequence::SelectEndOfBlock, 0, Qt::META | Qt::SHIFT | Qt::Key_E, QApplicationPrivate::KB_Mac},
796  {QKeySequence::SelectStartOfLine, 0, Qt::META | Qt::SHIFT | Qt::Key_Left, QApplicationPrivate::KB_Mac},
797  {QKeySequence::SelectEndOfLine, 0, Qt::META | Qt::SHIFT | Qt::Key_Right, QApplicationPrivate::KB_Mac}
798 };
799 
801 
802 
897 {
898  const QList <QKeySequence> bindings = keyBindings(key);
899  //pick only the first/primary shortcut from current bindings
900  if (bindings.size() > 0) {
901  d = bindings.first().d;
902  d->ref.ref();
903  }
904  else
905  d = new QKeySequencePrivate();
906 }
907 
908 
913 {
914  static QKeySequencePrivate shared_empty;
915  d = &shared_empty;
916  d->ref.ref();
917 }
918 
941 {
942  d = new QKeySequencePrivate();
943  assign(key);
944 }
945 
954 {
955  d = new QKeySequencePrivate();
956  assign(key, format);
957 }
958 
967 QKeySequence::QKeySequence(int k1, int k2, int k3, int k4)
968 {
969  d = new QKeySequencePrivate();
970  d->key[0] = k1;
971  d->key[1] = k2;
972  d->key[2] = k3;
973  d->key[3] = k4;
974 }
975 
980  : d(keysequence.d)
981 {
982  d->ref.ref();
983 }
984 
985 #ifdef Q_WS_MAC
986 static inline int maybeSwapShortcut(int shortcut)
987 {
988  if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
989  uint oldshortcut = shortcut;
990  shortcut &= ~(Qt::CTRL | Qt::META);
991  if (oldshortcut & Qt::CTRL)
992  shortcut |= Qt::META;
993  if (oldshortcut & Qt::META)
994  shortcut |= Qt::CTRL;
995  }
996  return shortcut;
997 }
998 #endif
999 
1013 {
1015  QList <QKeySequence> list;
1016  for (uint i = 0; i < QKeySequencePrivate::numberOfKeyBindings ; ++i) {
1017  QKeyBinding keyBinding = QKeySequencePrivate::keyBindings[i];
1018  if (keyBinding.standardKey == key && (keyBinding.platform & platform)) {
1019  uint shortcut =
1020 #ifdef Q_WS_MAC
1021  maybeSwapShortcut(QKeySequencePrivate::keyBindings[i].shortcut);
1022 #else
1023  QKeySequencePrivate::keyBindings[i].shortcut;
1024 #endif
1025  if (keyBinding.priority > 0)
1026  list.prepend(QKeySequence(shortcut));
1027  else
1028  list.append(QKeySequence(shortcut));
1029  }
1030  }
1031  return list;
1032 }
1033 
1038 {
1039  if (!d->ref.deref())
1040  delete d;
1041 }
1042 
1054 {
1055  Q_ASSERT_X(index >= 0 && index < 4, "QKeySequence::setKey", "index out of range");
1056  qAtomicDetach(d);
1057  d->key[index] = key;
1058 }
1059 
1065 {
1066  if (!d->key[0])
1067  return 0;
1068  if (!d->key[1])
1069  return 1;
1070  if (!d->key[2])
1071  return 2;
1072  if (!d->key[3])
1073  return 3;
1074  return 4;
1075 }
1076 
1077 
1083 {
1084  return !d->key[0];
1085 }
1086 
1087 
1104 {
1105  QKeySequence ret;
1106 
1108  return ret;
1109 
1110  bool found = false;
1111  int p = 0;
1112  while (p >= 0) {
1113  p = text.indexOf(QLatin1Char('&'), p) + 1;
1114  if (p <= 0 || p >= (int)text.length())
1115  break;
1116  if (text.at(p) != QLatin1Char('&')) {
1117  QChar c = text.at(p);
1118  if (c.isPrint()) {
1119  if (!found) {
1120  c = c.toUpper();
1121  ret = QKeySequence(c.unicode() + Qt::ALT);
1122 #ifdef QT_NO_DEBUG
1123  return ret;
1124 #else
1125  found = true;
1126  } else {
1127  qWarning("QKeySequence::mnemonic: \"%s\" contains multiple occurrences of '&'", qPrintable(text));
1128 #endif
1129  }
1130  }
1131  }
1132  p++;
1133  }
1134  return ret;
1135 }
1136 
1150 {
1151  return assign(ks, NativeText);
1152 }
1153 
1167 {
1168  QString keyseq = ks;
1169  QString part;
1170  int n = 0;
1171  int p = 0, diff = 0;
1172 
1173  // Run through the whole string, but stop
1174  // if we have 4 keys before the end.
1175  while (keyseq.length() && n < 4) {
1176  // We MUST use something to separate each sequence, and space
1177  // does not cut it, since some of the key names have space
1178  // in them.. (Let's hope no one translate with a comma in it:)
1179  p = keyseq.indexOf(QLatin1Char(','));
1180  if (-1 != p) {
1181  if (p == keyseq.count() - 1) { // Last comma 'Ctrl+,'
1182  p = -1;
1183  } else {
1184  if (QLatin1Char(',') == keyseq.at(p+1)) // e.g. 'Ctrl+,, Shift+,,'
1185  p++;
1186  if (QLatin1Char(' ') == keyseq.at(p+1)) { // Space after comma
1187  diff = 1;
1188  p++;
1189  } else {
1190  diff = 0;
1191  }
1192  }
1193  }
1194  part = keyseq.left(-1 == p ? keyseq.length() : p - diff);
1195  keyseq = keyseq.right(-1 == p ? 0 : keyseq.length() - (p + 1));
1196  d->key[n] = QKeySequencePrivate::decodeString(part, format);
1197  ++n;
1198  }
1199  return n;
1200 }
1201 
1204  QModifKeyName(int q, QChar n) : qt_key(q), name(n) { }
1205  QModifKeyName(int q, const QString &n) : qt_key(q), name(n) { }
1206  int qt_key;
1208 };
1209 
1211 Q_GLOBAL_STATIC(QList<QModifKeyName>, globalPortableModifs)
1212 
1213 
1217 {
1219 }
1220 
1222 {
1223  int ret = 0;
1224  QString accel = str.toLower();
1225  bool nativeText = (format == QKeySequence::NativeText);
1226 
1227  QList<QModifKeyName> *gmodifs;
1228  if (nativeText) {
1229  gmodifs = globalModifs();
1230  if (gmodifs->isEmpty()) {
1231 #ifdef Q_WS_MAC
1232  const bool dontSwap = qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta);
1233  if (dontSwap)
1234  *gmodifs << QModifKeyName(Qt::META, QChar(kCommandUnicode));
1235  else
1236  *gmodifs << QModifKeyName(Qt::CTRL, QChar(kCommandUnicode));
1237  *gmodifs << QModifKeyName(Qt::ALT, QChar(kOptionUnicode));
1238  if (dontSwap)
1239  *gmodifs << QModifKeyName(Qt::CTRL, QChar(kControlUnicode));
1240  else
1241  *gmodifs << QModifKeyName(Qt::META, QChar(kControlUnicode));
1242  *gmodifs << QModifKeyName(Qt::SHIFT, QChar(kShiftUnicode));
1243 #endif
1244  *gmodifs << QModifKeyName(Qt::CTRL, QLatin1String("ctrl+"))
1245  << QModifKeyName(Qt::SHIFT, QLatin1String("shift+"))
1246  << QModifKeyName(Qt::ALT, QLatin1String("alt+"))
1247  << QModifKeyName(Qt::META, QLatin1String("meta+"));
1248  }
1249  } else {
1250  gmodifs = globalPortableModifs();
1251  if (gmodifs->isEmpty()) {
1252  *gmodifs << QModifKeyName(Qt::CTRL, QLatin1String("ctrl+"))
1253  << QModifKeyName(Qt::SHIFT, QLatin1String("shift+"))
1254  << QModifKeyName(Qt::ALT, QLatin1String("alt+"))
1255  << QModifKeyName(Qt::META, QLatin1String("meta+"));
1256  }
1257  }
1258  if (!gmodifs) return ret;
1259 
1260 
1261  QList<QModifKeyName> modifs;
1262  if (nativeText) {
1263  modifs << QModifKeyName(Qt::CTRL, QShortcut::tr("Ctrl").toLower().append(QLatin1Char('+')))
1264  << QModifKeyName(Qt::SHIFT, QShortcut::tr("Shift").toLower().append(QLatin1Char('+')))
1265  << QModifKeyName(Qt::ALT, QShortcut::tr("Alt").toLower().append(QLatin1Char('+')))
1266  << QModifKeyName(Qt::META, QShortcut::tr("Meta").toLower().append(QLatin1Char('+')));
1267  }
1268  modifs += *gmodifs; // Test non-translated ones last
1269 
1270  QString sl = accel;
1271 #ifdef Q_WS_MAC
1272  for (int i = 0; i < modifs.size(); ++i) {
1273  const QModifKeyName &mkf = modifs.at(i);
1274  if (sl.contains(mkf.name)) {
1275  ret |= mkf.qt_key;
1276  accel.remove(mkf.name);
1277  sl = accel;
1278  }
1279  }
1280 #else
1281  int i = 0;
1282  int lastI = 0;
1283  while ((i = sl.indexOf(QLatin1Char('+'), i + 1)) != -1) {
1284  const QString sub = sl.mid(lastI, i - lastI + 1);
1285  // Just shortcut the check here if we only have one character.
1286  // Rational: A modifier will contain the name AND +, so longer than 1, a length of 1 is just
1287  // the remaining part of the shortcut (ei. The 'C' in "Ctrl+C"), so no need to check that.
1288  if (sub.length() > 1) {
1289  for (int j = 0; j < modifs.size(); ++j) {
1290  const QModifKeyName &mkf = modifs.at(j);
1291  if (sub == mkf.name) {
1292  ret |= mkf.qt_key;
1293  break; // Shortcut, since if we find an other it would/should just be a dup
1294  }
1295  }
1296  }
1297  lastI = i + 1;
1298  }
1299 #endif
1300 
1301  int p = accel.lastIndexOf(QLatin1Char('+'), str.length() - 2); // -2 so that Ctrl++ works
1302  if(p > 0)
1303  accel = accel.mid(p + 1);
1304 
1305  int fnum = 0;
1306  if (accel.length() == 1) {
1307 #ifdef Q_WS_MAC
1308  int qtKey = qtkeyForMacSymbol(accel[0]);
1309  if (qtKey != -1) {
1310  ret |= qtKey;
1311  } else
1312 #endif
1313  {
1314  ret |= accel[0].toUpper().unicode();
1315  }
1316  } else if (accel[0] == QLatin1Char('f') && (fnum = accel.mid(1).toInt()) && (fnum >= 1) && (fnum <= 35)) {
1317  ret |= Qt::Key_F1 + fnum - 1;
1318  } else {
1319  // For NativeText, check the traslation table first,
1320  // if we don't find anything then try it out with just the untranlated stuff.
1321  // PortableText will only try the untranlated table.
1322  bool found = false;
1323  for (int tran = 0; tran < 2; ++tran) {
1324  if (!nativeText)
1325  ++tran;
1326  for (int i = 0; keyname[i].name; ++i) {
1327  QString keyName(tran == 0
1328  ? QShortcut::tr(keyname[i].name)
1329  : QString::fromLatin1(keyname[i].name));
1330  if (accel == keyName.toLower()) {
1331  ret |= keyname[i].key;
1332  found = true;
1333  break;
1334  }
1335  }
1336  if (found)
1337  break;
1338  }
1339  }
1340  return ret;
1341 }
1342 
1349 {
1351 }
1352 
1353 static inline void addKey(QString &str, const QString &theKey, QKeySequence::SequenceFormat format)
1354 {
1355  if (!str.isEmpty())
1356  str += (format == QKeySequence::NativeText) ? QShortcut::tr("+")
1357  : QString::fromLatin1("+");
1358  str += theKey;
1359 }
1360 
1362 {
1363  bool nativeText = (format == QKeySequence::NativeText);
1364  QString s;
1365 #if defined(Q_WS_MAC)
1366  if (nativeText) {
1367  // On Mac OS X the order (by default) is Meta, Alt, Shift, Control.
1368  // If the AA_MacDontSwapCtrlAndMeta is enabled, then the order
1369  // is Ctrl, Alt, Shift, Meta. The macSymbolForQtKey does this swap
1370  // for us, which means that we have to adjust our order here.
1371  // The upshot is a lot more infrastructure to keep the number of
1372  // if tests down and the code relatively clean.
1373  static const int ModifierOrder[] = { Qt::META, Qt::ALT, Qt::SHIFT, Qt::CTRL, 0 };
1374  static const int QtKeyOrder[] = { Qt::Key_Meta, Qt::Key_Alt, Qt::Key_Shift, Qt::Key_Control, 0 };
1375  static const int DontSwapModifierOrder[] = { Qt::CTRL, Qt::ALT, Qt::SHIFT, Qt::META, 0 };
1376  static const int DontSwapQtKeyOrder[] = { Qt::Key_Control, Qt::Key_Alt, Qt::Key_Shift, Qt::Key_Meta, 0 };
1377  const int *modifierOrder;
1378  const int *qtkeyOrder;
1379  if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
1380  modifierOrder = DontSwapModifierOrder;
1381  qtkeyOrder = DontSwapQtKeyOrder;
1382  } else {
1383  modifierOrder = ModifierOrder;
1384  qtkeyOrder = QtKeyOrder;
1385  }
1386 
1387  for (int i = 0; modifierOrder[i] != 0; ++i) {
1388  if (key & modifierOrder[i])
1389  s += qt_macSymbolForQtKey(qtkeyOrder[i]);
1390  }
1391  } else
1392 #endif
1393  {
1394  // On other systems the order is Meta, Control, Alt, Shift
1395  if ((key & Qt::META) == Qt::META)
1396  s = nativeText ? QShortcut::tr("Meta") : QString::fromLatin1("Meta");
1397  if ((key & Qt::CTRL) == Qt::CTRL)
1398  addKey(s, nativeText ? QShortcut::tr("Ctrl") : QString::fromLatin1("Ctrl"), format);
1399  if ((key & Qt::ALT) == Qt::ALT)
1400  addKey(s, nativeText ? QShortcut::tr("Alt") : QString::fromLatin1("Alt"), format);
1401  if ((key & Qt::SHIFT) == Qt::SHIFT)
1402  addKey(s, nativeText ? QShortcut::tr("Shift") : QString::fromLatin1("Shift"), format);
1403  }
1404 
1405 
1407  QString p;
1408 
1409  if (key && key < Qt::Key_Escape && key != Qt::Key_Space) {
1410  if (!QChar::requiresSurrogates(key)) {
1411  p = QChar(ushort(key)).toUpper();
1412  } else {
1413  p += QChar(QChar::highSurrogate(key));
1414  p += QChar(QChar::lowSurrogate(key));
1415  }
1416  } else if (key >= Qt::Key_F1 && key <= Qt::Key_F35) {
1417  p = nativeText ? QShortcut::tr("F%1").arg(key - Qt::Key_F1 + 1)
1418  : QString::fromLatin1("F%1").arg(key - Qt::Key_F1 + 1);
1419  } else if (key) {
1420  int i=0;
1421 #if defined(Q_WS_MAC)
1422  if (nativeText) {
1423  QChar ch = qt_macSymbolForQtKey(key);
1424  if (!ch.isNull())
1425  p = ch;
1426  else
1427  goto NonSymbol;
1428  } else
1429 #endif
1430  {
1431 #ifdef Q_WS_MAC
1432 NonSymbol:
1433 #endif
1434  while (keyname[i].name) {
1435  if (key == keyname[i].key) {
1436  p = nativeText ? QShortcut::tr(keyname[i].name)
1437  : QString::fromLatin1(keyname[i].name);
1438  break;
1439  }
1440  ++i;
1441  }
1442  // If we can't find the actual translatable keyname,
1443  // fall back on the unicode representation of it...
1444  // Or else characters like Qt::Key_aring may not get displayed
1445  // (Really depends on you locale)
1446  if (!keyname[i].name) {
1447  if (!QChar::requiresSurrogates(key)) {
1448  p = QChar(ushort(key)).toUpper();
1449  } else {
1450  p += QChar(QChar::highSurrogate(key));
1451  p += QChar(QChar::lowSurrogate(key));
1452  }
1453  }
1454  }
1455  }
1456 
1457 #ifdef Q_WS_MAC
1458  if (nativeText)
1459  s += p;
1460  else
1461 #endif
1462  addKey(s, p, format);
1463  return s;
1464 }
1472 {
1473  uint userN = count(),
1474  seqN = seq.count();
1475 
1476  if (userN > seqN)
1477  return NoMatch;
1478 
1479  // If equal in length, we have a potential ExactMatch sequence,
1480  // else we already know it can only be partial.
1481  SequenceMatch match = (userN == seqN ? ExactMatch : PartialMatch);
1482 
1483  for (uint i = 0; i < userN; ++i) {
1484  int userKey = (*this)[i],
1485  sequenceKey = seq[i];
1486  if (userKey != sequenceKey)
1487  return NoMatch;
1488  }
1489  return match;
1490 }
1491 
1492 
1505 QKeySequence::operator QString() const
1506 {
1508 }
1509 
1513 QKeySequence::operator QVariant() const
1514 {
1515  return QVariant(QVariant::KeySequence, this);
1516 }
1517 
1526 QKeySequence::operator int () const
1527 {
1528  if (1 <= count())
1529  return d->key[0];
1530  return 0;
1531 }
1532 
1533 
1539 {
1540  Q_ASSERT_X(index < 4, "QKeySequence::operator[]", "index out of range");
1541  return d->key[index];
1542 }
1543 
1544 
1550 {
1551  qAtomicAssign(d, other.d);
1552  return *this;
1553 }
1554 
1581 bool QKeySequence::operator==(const QKeySequence &other) const
1582 {
1583  return (d->key[0] == other.d->key[0] &&
1584  d->key[1] == other.d->key[1] &&
1585  d->key[2] == other.d->key[2] &&
1586  d->key[3] == other.d->key[3]);
1587 }
1588 
1589 
1602 bool QKeySequence::operator< (const QKeySequence &other) const
1603 {
1604  for (int i = 0; i < 4; ++i)
1605  if (d->key[i] != other.d->key[i])
1606  return d->key[i] < other.d->key[i];
1607  return false;
1608 }
1609 
1650 {
1651  return d->ref == 1;
1652 }
1653 
1677 {
1678  QString finalString;
1679  // A standard string, with no translation or anything like that. In some ways it will
1680  // look like our latin case on Windows and X11
1681  int end = count();
1682  for (int i = 0; i < end; ++i) {
1683  finalString += d->encodeString(d->key[i], format);
1684  finalString += QLatin1String(", ");
1685  }
1686  finalString.truncate(finalString.length() - 2);
1687  return finalString;
1688 }
1689 
1701 {
1702  return QKeySequence(str, format);
1703 }
1704 
1705 /*****************************************************************************
1706  QKeySequence stream functions
1707  *****************************************************************************/
1708 #if !defined(QT_NO_DATASTREAM)
1709 
1721 {
1722  QList<quint32> list;
1723  list << keysequence.d->key[0];
1724 
1725  if (s.version() >= 5 && keysequence.count() > 1) {
1726  list << keysequence.d->key[1];
1727  list << keysequence.d->key[2];
1728  list << keysequence.d->key[3];
1729  }
1730  s << list;
1731  return s;
1732 }
1733 
1734 
1747 {
1748  qAtomicDetach(keysequence.d);
1749  QList<quint32> list;
1750  s >> list;
1751  for (int i = 0; i < 4; ++i)
1752  keysequence.d->key[i] = list.value(i);
1753  return s;
1754 }
1755 
1756 #endif //QT_NO_DATASTREAM
1757 
1758 #ifndef QT_NO_DEBUG_STREAM
1760 {
1761 #ifndef Q_BROKEN_DEBUG_STREAM
1762  dbg.nospace() << "QKeySequence(" << p.toString() << ')';
1763  return dbg.space();
1764 #else
1765  qWarning("This compiler doesn't support streaming QKeySequence to QDebug");
1766  return dbg;
1767  Q_UNUSED(p);
1768 #endif
1769 }
1770 #endif
1771 
1772 #endif // QT_NO_SHORTCUT
1773 
1774 
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
The QDebug class provides an output stream for debugging information.
Definition: qdebug.h:62
double d
Definition: qnumeric_p.h:62
QKeySequence::StandardKey standardKey
void qAtomicDetach(T *&d)
This is a helper for the detach method of implicitly shared classes.
Definition: qatomic.h:214
static QString keyName(const QString &rKey)
static const struct @203 keyname[]
QModifKeyName(int q, QChar n)
unsigned char c[8]
Definition: qnumeric_p.h:62
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
Definition: qstring.cpp:6090
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qchar.h:251
bool isNull() const
Returns true if the character is the Unicode character 0x0000 (&#39;\0&#39;); otherwise returns false...
Definition: qchar.h:262
QDebug & nospace()
Clears the stream&#39;s internal flag that records whether the last character was a space and returns a r...
Definition: qdebug.h:92
static QString encodeString(int key, QKeySequence::SequenceFormat format)
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
friend Q_GUI_EXPORT QDataStream & operator<<(QDataStream &in, const QKeySequence &ks)
Writes the key sequence to the stream.
static QKeySequence mnemonic(const QString &text)
Returns the shortcut key sequence for the mnemonic in text, or an empty key sequence if no mnemonics ...
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QString toUpper() const Q_REQUIRED_RESULT
Returns an uppercase copy of the string.
Definition: qstring.cpp:5483
void setKey(int key, int index)
KeySequences should never be modified, but rather just created.
static bool match(const uchar *found, const char *target, uint len)
#define QT_TRANSLATE_NOOP(scope, x)
Marks the string literal sourceText for dynamic translation in the given context; i...
Definition: qglobal.h:2487
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
~QKeySequence()
Destroys the key sequence.
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
Definition: qalgorithms.h:295
StandardKey
This enum represent standard key bindings.
Definition: qkeysequence.h:75
bool ref()
Atomically increments the value of this QAtomicInt.
static QList< QKeySequence > keyBindings(StandardKey key)
Returns a list of key bindings for the given key.
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString encodeString(int key)
Creates a shortcut string for key.
bool isPrint() const
Returns true if the character is a printable character; otherwise returns false.
Definition: qchar.cpp:598
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
static ushort highSurrogate(uint ucs4)
Returns the high surrogate value of a ucs4 code point.
Definition: qchar.h:303
int operator[](uint i) const
Returns a reference to the element at position index in the key sequence.
static ushort lowSurrogate(uint ucs4)
Returns the low surrogate value of a ucs4 code point.
Definition: qchar.h:306
static uint currentPlatform()
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
static void addKey(QString &str, const QString &theKey, QKeySequence::SequenceFormat format)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static bool requiresSurrogates(uint ucs4)
Returns true if the UCS-4-encoded character specified by ucs4 can be split into the high and low part...
Definition: qchar.h:294
void truncate(int pos)
Truncates the string at the given position index.
Definition: qstring.cpp:4603
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
static QKeySequence fromString(const QString &str, SequenceFormat format=PortableText)
Return a QKeySequence from the string str based on format.
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define qApp
void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b)
const char * name
#define Q_GLOBAL_STATIC(TYPE, NAME)
Declares a global static variable with the given type and name.
Definition: qglobal.h:1968
void prepend(const T &t)
Inserts value at the beginning of the list.
Definition: qlist.h:541
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
bool deref()
Atomically decrements the value of this QAtomicInt.
QKeySequencePrivate * d
Definition: qkeysequence.h:206
Q_CORE_EXPORT void qWarning(const char *,...)
unsigned int uint
Definition: qglobal.h:996
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
static Bigint * diff(Bigint *a, Bigint *b)
static const int NumEntries
QChar toUpper() const
Returns the uppercase equivalent if the character is lowercase or titlecase; otherwise returns the ch...
Definition: qchar.cpp:1287
QString toString(SequenceFormat format=PortableText) const
Return a string representation of the key sequence, based on format.
QString right(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n rightmost characters of the string.
Definition: qstring.cpp:3682
bool isEmpty() const
Returns true if the key sequence is empty; otherwise returns false.
int count() const
Definition: qstring.h:103
static int decodeString(const QString &ks)
Constructs a single key from the string str.
int version() const
Returns the version number of the data serialization format.
Definition: qdatastream.h:212
friend Q_GUI_EXPORT QDataStream & operator>>(QDataStream &in, QKeySequence &ks)
Reads a key sequence from the stream into the key sequence.
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
static const MacSpecialKey entries[NumEntries]
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
The QKeySequence class encapsulates a key sequence as used by shortcuts.
Definition: qkeysequence.h:72
int assign(const QString &str)
Adds the given keys to the key sequence.
bool isDetached() const
unsigned short ushort
Definition: qglobal.h:995
static bool qt_sequence_no_mnemonics
int lastIndexOf(QChar c, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:3000
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
static int decodeString(const QString &keyStr, QKeySequence::SequenceFormat format)
int key
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
Definition: qstring.cpp:5389
static const uint numberOfKeyBindings
QKeySequence & operator=(const QKeySequence &other)
Assignment operator.
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
void qAtomicAssign(T *&d, T *x)
This is a helper for the assignment operators of implicitly shared classes.
Definition: qatomic.h:195
uint count() const
Returns the number of keys in the key sequence.
bool operator<(const QKeySequence &ks) const
Provides an arbitrary comparison of this key sequence and other key sequence.
quint16 index
QKeySequence()
Constructs an empty key sequence.
static const QKeyBinding keyBindings[]
static int qtkeyForMacSymbol(const QChar ch)
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
QChar qt_macSymbolForQtKey(int key)
bool operator==(const QKeySequence &other) const
Returns true if this key sequence is equal to the other key sequence; otherwise returns false...
static QString qtKey(CFStringRef cfkey)
QString & remove(int i, int len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
Definition: qstring.cpp:1867
static const KeyPair *const end
static const MacSpecialKey *const MacSpecialKeyEntriesEnd
QDebug & space()
Writes a space character to the debug stream and returns a reference to the stream.
Definition: qdebug.h:91
SequenceFormat
This means that it will be shown translated and on the Mac it will resemble a key sequence from the m...
Definition: qkeysequence.h:144
#define qPrintable(string)
Definition: qglobal.h:1750
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
static bool operator<(const MacSpecialKey &entry, int key)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
static int maybeSwapShortcut(int shortcut)
#define text
Definition: qobjectdefs.h:80
SequenceMatch matches(const QKeySequence &seq) const
Matches the sequence with seq.
QModifKeyName(int q, const QString &n)