388 |
388 |
389 static const struct { |
389 static const struct { |
390 int key; |
390 int key; |
391 const char* name; |
391 const char* name; |
392 } keyname[] = { |
392 } keyname[] = { |
|
393 //: This and all following "incomprehensible" strings in QShortcut context |
|
394 //: are key names. Please use the localized names appearing on actual |
|
395 //: keyboards or whatever is commonly used. |
393 { Qt::Key_Space, QT_TRANSLATE_NOOP("QShortcut", "Space") }, |
396 { Qt::Key_Space, QT_TRANSLATE_NOOP("QShortcut", "Space") }, |
394 { Qt::Key_Escape, QT_TRANSLATE_NOOP("QShortcut", "Esc") }, |
397 { Qt::Key_Escape, QT_TRANSLATE_NOOP("QShortcut", "Esc") }, |
395 { Qt::Key_Tab, QT_TRANSLATE_NOOP("QShortcut", "Tab") }, |
398 { Qt::Key_Tab, QT_TRANSLATE_NOOP("QShortcut", "Tab") }, |
396 { Qt::Key_Backtab, QT_TRANSLATE_NOOP("QShortcut", "Backtab") }, |
399 { Qt::Key_Backtab, QT_TRANSLATE_NOOP("QShortcut", "Backtab") }, |
397 { Qt::Key_Backspace, QT_TRANSLATE_NOOP("QShortcut", "Backspace") }, |
400 { Qt::Key_Backspace, QT_TRANSLATE_NOOP("QShortcut", "Backspace") }, |
578 { Qt::Key_Context4, QT_TRANSLATE_NOOP("QShortcut", "Context4") }, |
581 { Qt::Key_Context4, QT_TRANSLATE_NOOP("QShortcut", "Context4") }, |
579 { Qt::Key_Call, QT_TRANSLATE_NOOP("QShortcut", "Call") }, |
582 { Qt::Key_Call, QT_TRANSLATE_NOOP("QShortcut", "Call") }, |
580 { Qt::Key_Hangup, QT_TRANSLATE_NOOP("QShortcut", "Hangup") }, |
583 { Qt::Key_Hangup, QT_TRANSLATE_NOOP("QShortcut", "Hangup") }, |
581 { Qt::Key_Flip, QT_TRANSLATE_NOOP("QShortcut", "Flip") }, |
584 { Qt::Key_Flip, QT_TRANSLATE_NOOP("QShortcut", "Flip") }, |
582 |
585 |
|
586 // -------------------------------------------------------------- |
|
587 // Japanese keyboard support |
|
588 { Qt::Key_Kanji, QT_TRANSLATE_NOOP("QShortcut", "Kanji") }, |
|
589 { Qt::Key_Muhenkan, QT_TRANSLATE_NOOP("QShortcut", "Muhenkan") }, |
|
590 { Qt::Key_Henkan, QT_TRANSLATE_NOOP("QShortcut", "Henkan") }, |
|
591 { Qt::Key_Romaji, QT_TRANSLATE_NOOP("QShortcut", "Romaji") }, |
|
592 { Qt::Key_Hiragana, QT_TRANSLATE_NOOP("QShortcut", "Hiragana") }, |
|
593 { Qt::Key_Katakana, QT_TRANSLATE_NOOP("QShortcut", "Katakana") }, |
|
594 { Qt::Key_Hiragana_Katakana,QT_TRANSLATE_NOOP("QShortcut", "Hiragana Katakana") }, |
|
595 { Qt::Key_Zenkaku, QT_TRANSLATE_NOOP("QShortcut", "Zenkaku") }, |
|
596 { Qt::Key_Hankaku, QT_TRANSLATE_NOOP("QShortcut", "Hankaku") }, |
|
597 { Qt::Key_Zenkaku_Hankaku, QT_TRANSLATE_NOOP("QShortcut", "Zenkaku Hankaku") }, |
|
598 { Qt::Key_Touroku, QT_TRANSLATE_NOOP("QShortcut", "Touroku") }, |
|
599 { Qt::Key_Massyo, QT_TRANSLATE_NOOP("QShortcut", "Massyo") }, |
|
600 { Qt::Key_Kana_Lock, QT_TRANSLATE_NOOP("QShortcut", "Kana Lock") }, |
|
601 { Qt::Key_Kana_Shift, QT_TRANSLATE_NOOP("QShortcut", "Kana Shift") }, |
|
602 { Qt::Key_Eisu_Shift, QT_TRANSLATE_NOOP("QShortcut", "Eisu Shift") }, |
|
603 { Qt::Key_Eisu_toggle, QT_TRANSLATE_NOOP("QShortcut", "Eisu toggle") }, |
|
604 { Qt::Key_Codeinput, QT_TRANSLATE_NOOP("QShortcut", "Code input") }, |
|
605 { Qt::Key_MultipleCandidate,QT_TRANSLATE_NOOP("QShortcut", "Multiple Candidate") }, |
|
606 { Qt::Key_PreviousCandidate,QT_TRANSLATE_NOOP("QShortcut", "Previous Candidate") }, |
|
607 |
|
608 // -------------------------------------------------------------- |
|
609 // Korean keyboard support |
|
610 { Qt::Key_Hangul, QT_TRANSLATE_NOOP("QShortcut", "Hangul") }, |
|
611 { Qt::Key_Hangul_Start, QT_TRANSLATE_NOOP("QShortcut", "Hangul Start") }, |
|
612 { Qt::Key_Hangul_End, QT_TRANSLATE_NOOP("QShortcut", "Hangul End") }, |
|
613 { Qt::Key_Hangul_Hanja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Hanja") }, |
|
614 { Qt::Key_Hangul_Jamo, QT_TRANSLATE_NOOP("QShortcut", "Hangul Jamo") }, |
|
615 { Qt::Key_Hangul_Romaja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Romaja") }, |
|
616 { Qt::Key_Hangul_Jeonja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Jeonja") }, |
|
617 { Qt::Key_Hangul_Banja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Banja") }, |
|
618 { Qt::Key_Hangul_PreHanja, QT_TRANSLATE_NOOP("QShortcut", "Hangul PreHanja") }, |
|
619 { Qt::Key_Hangul_PostHanja,QT_TRANSLATE_NOOP("QShortcut", "Hangul PostHanja") }, |
|
620 { Qt::Key_Hangul_Special, QT_TRANSLATE_NOOP("QShortcut", "Hangul Special") }, |
583 |
621 |
584 { 0, 0 } |
622 { 0, 0 } |
585 }; |
623 }; |
586 |
624 |
587 //Table of key bindings. It must be sorted on key sequence. |
625 //Table of key bindings. It must be sorted on key sequence. |
694 {QKeySequence::SaveAs, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_S, QApplicationPrivate::KB_Gnome | QApplicationPrivate::KB_Mac}, |
732 {QKeySequence::SaveAs, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_S, QApplicationPrivate::KB_Gnome | QApplicationPrivate::KB_Mac}, |
695 {QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60}, |
733 {QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60}, |
696 {QKeySequence::Redo, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, QApplicationPrivate::KB_Mac}, //different priority from above |
734 {QKeySequence::Redo, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, QApplicationPrivate::KB_Mac}, //different priority from above |
697 {QKeySequence::PreviousChild, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11}, |
735 {QKeySequence::PreviousChild, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11}, |
698 {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, QApplicationPrivate::KB_Mac },//different priority from above |
736 {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, QApplicationPrivate::KB_Mac },//different priority from above |
|
737 {QKeySequence::Paste, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Insert, QApplicationPrivate::KB_X11}, |
699 {QKeySequence::SelectStartOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Home, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60}, |
738 {QKeySequence::SelectStartOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Home, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60}, |
700 {QKeySequence::SelectEndOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_End, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60}, |
739 {QKeySequence::SelectEndOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_End, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60}, |
701 {QKeySequence::SelectPreviousWord, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Left, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60}, |
740 {QKeySequence::SelectPreviousWord, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Left, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60}, |
702 {QKeySequence::SelectStartOfLine, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Left, QApplicationPrivate::KB_Mac }, |
741 {QKeySequence::SelectStartOfLine, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Left, QApplicationPrivate::KB_Mac }, |
703 {QKeySequence::SelectStartOfDocument, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Up, QApplicationPrivate::KB_Mac}, |
742 {QKeySequence::SelectStartOfDocument, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Up, QApplicationPrivate::KB_Mac}, |
1053 |
1104 |
1054 Adds the given \a keys to the key sequence. \a keys may |
1105 Adds the given \a keys to the key sequence. \a keys may |
1055 contain up to four key codes, provided they are separated by a |
1106 contain up to four key codes, provided they are separated by a |
1056 comma; for example, "Alt+X,Ctrl+S,Z". The return value is the |
1107 comma; for example, "Alt+X,Ctrl+S,Z". The return value is the |
1057 number of key codes added. |
1108 number of key codes added. |
|
1109 \a keys should be in NativeText format. |
1058 */ |
1110 */ |
1059 int QKeySequence::assign(const QString &ks) |
1111 int QKeySequence::assign(const QString &ks) |
|
1112 { |
|
1113 return assign(ks, NativeText); |
|
1114 } |
|
1115 |
|
1116 /*! |
|
1117 \fn int QKeySequence::assign(const QString &keys, QKeySequence::SequenceFormat format) |
|
1118 \since 4.x |
|
1119 |
|
1120 Adds the given \a keys to the key sequence (based on \a format). |
|
1121 \a keys may contain up to four key codes, provided they are |
|
1122 separated by a comma; for example, "Alt+X,Ctrl+S,Z". The return |
|
1123 value is the number of key codes added. |
|
1124 */ |
|
1125 int QKeySequence::assign(const QString &ks, QKeySequence::SequenceFormat format) |
1060 { |
1126 { |
1061 QString keyseq = ks; |
1127 QString keyseq = ks; |
1062 QString part; |
1128 QString part; |
1063 int n = 0; |
1129 int n = 0; |
1064 int p = 0, diff = 0; |
1130 int p = 0, diff = 0; |
1555 |
1621 |
1556 \sa toString() |
1622 \sa toString() |
1557 */ |
1623 */ |
1558 QKeySequence QKeySequence::fromString(const QString &str, SequenceFormat format) |
1624 QKeySequence QKeySequence::fromString(const QString &str, SequenceFormat format) |
1559 { |
1625 { |
1560 QStringList sl = str.split(QLatin1String(", ")); |
1626 return QKeySequence(str, format); |
1561 int keys[4] = {0, 0, 0, 0}; |
|
1562 int total = qMin(sl.count(), 4); |
|
1563 for (int i = 0; i < total; ++i) |
|
1564 keys[i] = QKeySequencePrivate::decodeString(sl[i], format); |
|
1565 return QKeySequence(keys[0], keys[1], keys[2], keys[3]); |
|
1566 } |
1627 } |
1567 |
1628 |
1568 /***************************************************************************** |
1629 /***************************************************************************** |
1569 QKeySequence stream functions |
1630 QKeySequence stream functions |
1570 *****************************************************************************/ |
1631 *****************************************************************************/ |