Changeset View
Changeset View
Standalone View
Standalone View
src/kkeysequencewidget.cpp
Show First 20 Lines • Show All 640 Lines • ▼ Show 20 Line(s) | 639 | { | |||
---|---|---|---|---|---|
641 | QString s = keySequence.toString(QKeySequence::NativeText); | 641 | QString s = keySequence.toString(QKeySequence::NativeText); | ||
642 | s.replace(QLatin1Char('&'), QStringLiteral("&&")); | 642 | s.replace(QLatin1Char('&'), QStringLiteral("&&")); | ||
643 | 643 | | |||
644 | if (isRecording) { | 644 | if (isRecording) { | ||
645 | if (modifierKeys) { | 645 | if (modifierKeys) { | ||
646 | if (!s.isEmpty()) { | 646 | if (!s.isEmpty()) { | ||
647 | s.append(QLatin1Char(',')); | 647 | s.append(QLatin1Char(',')); | ||
648 | } | 648 | } | ||
649 | if (modifierKeys & Qt::META) { | 649 | if (modifierKeys & Qt::MetaModifier) { | ||
650 | s += KKeyServer::modToStringUser(Qt::META) + QLatin1Char('+'); | 650 | s += KKeyServer::modToStringUser(Qt::MetaModifier) + QLatin1Char('+'); | ||
651 | } | 651 | } | ||
652 | #if defined(Q_OS_MAC) | 652 | #if defined(Q_OS_MAC) | ||
653 | if (modifierKeys & Qt::ALT) { | 653 | if (modifierKeys & Qt::AltModifier) { | ||
654 | s += KKeyServer::modToStringUser(Qt::ALT) + QLatin1Char('+'); | 654 | s += KKeyServer::modToStringUser(Qt::AltModifier) + QLatin1Char('+'); | ||
655 | } | 655 | } | ||
656 | if (modifierKeys & Qt::CTRL) { | 656 | if (modifierKeys & Qt::ControlModifier) { | ||
657 | s += KKeyServer::modToStringUser(Qt::CTRL) + QLatin1Char('+'); | 657 | s += KKeyServer::modToStringUser(Qt::ControlModifier) + QLatin1Char('+'); | ||
658 | } | 658 | } | ||
659 | #else | 659 | #else | ||
660 | if (modifierKeys & Qt::CTRL) { | 660 | if (modifierKeys & Qt::ControlModifier) { | ||
661 | s += KKeyServer::modToStringUser(Qt::CTRL) + QLatin1Char('+'); | 661 | s += KKeyServer::modToStringUser(Qt::ControlModifier) + QLatin1Char('+'); | ||
662 | } | 662 | } | ||
663 | if (modifierKeys & Qt::ALT) { | 663 | if (modifierKeys & Qt::AltModifier) { | ||
664 | s += KKeyServer::modToStringUser(Qt::ALT) + QLatin1Char('+'); | 664 | s += KKeyServer::modToStringUser(Qt::AltModifier) + QLatin1Char('+'); | ||
665 | } | 665 | } | ||
666 | #endif | 666 | #endif | ||
667 | if (modifierKeys & Qt::SHIFT) { | 667 | if (modifierKeys & Qt::ShiftModifier) { | ||
668 | s += KKeyServer::modToStringUser(Qt::SHIFT) + QLatin1Char('+'); | 668 | s += KKeyServer::modToStringUser(Qt::ShiftModifier) + QLatin1Char('+'); | ||
669 | } | ||||
670 | if (modifierKeys & Qt::KeypadModifier) { | ||||
671 | s += KKeyServer::modToStringUser(Qt::KeypadModifier) + QLatin1Char('+'); | ||||
669 | } | 672 | } | ||
670 | 673 | | |||
671 | } else if (nKey == 0) { | 674 | } else if (nKey == 0) { | ||
672 | s = i18nc("What the user inputs now will be taken as the new shortcut", "Input"); | 675 | s = i18nc("What the user inputs now will be taken as the new shortcut", "Input"); | ||
673 | } | 676 | } | ||
674 | //make it clear that input is still going on | 677 | //make it clear that input is still going on | ||
675 | s.append(QStringLiteral(" ...")); | 678 | s.append(QStringLiteral(" ...")); | ||
676 | } | 679 | } | ||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | 723 | if (keyQt == -1) { | |||
722 | // We cannot do anything useful with those (several keys have -1, indistinguishable) | 725 | // We cannot do anything useful with those (several keys have -1, indistinguishable) | ||
723 | // and QKeySequence.toString() will also yield a garbage string. | 726 | // and QKeySequence.toString() will also yield a garbage string. | ||
724 | KMessageBox::sorry(this, | 727 | KMessageBox::sorry(this, | ||
725 | i18n("The key you just pressed is not supported by Qt."), | 728 | i18n("The key you just pressed is not supported by Qt."), | ||
726 | i18n("Unsupported Key")); | 729 | i18n("Unsupported Key")); | ||
727 | return d->cancelRecording(); | 730 | return d->cancelRecording(); | ||
728 | } | 731 | } | ||
729 | 732 | | |||
730 | uint newModifiers = e->modifiers() & (Qt::SHIFT | Qt::CTRL | Qt::ALT | Qt::META); | 733 | uint newModifiers = e->modifiers() & (Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier | Qt::KeypadModifier); | ||
731 | 734 | | |||
732 | //don't have the return or space key appear as first key of the sequence when they | 735 | //don't have the return or space key appear as first key of the sequence when they | ||
733 | //were pressed to start editing - catch and them and imitate their effect | 736 | //were pressed to start editing - catch and them and imitate their effect | ||
734 | if (!d->isRecording && ((keyQt == Qt::Key_Return || keyQt == Qt::Key_Space))) { | 737 | if (!d->isRecording && ((keyQt == Qt::Key_Return || keyQt == Qt::Key_Space))) { | ||
735 | d->startRecording(); | 738 | d->startRecording(); | ||
736 | d->modifierKeys = newModifiers; | 739 | d->modifierKeys = newModifiers; | ||
737 | d->updateShortcutDisplay(); | 740 | d->updateShortcutDisplay(); | ||
738 | return; | 741 | return; | ||
Show All 28 Lines | 769 | if (!(KKeySequenceWidgetPrivate::isOkWhenModifierless(keyQt) | |||
767 | || d->allowModifierless)) { | 770 | || d->allowModifierless)) { | ||
768 | // No it's not | 771 | // No it's not | ||
769 | return; | 772 | return; | ||
770 | } | 773 | } | ||
771 | } | 774 | } | ||
772 | 775 | | |||
773 | // We now have a valid key press. | 776 | // We now have a valid key press. | ||
774 | if (keyQt) { | 777 | if (keyQt) { | ||
775 | if ((keyQt == Qt::Key_Backtab) && (d->modifierKeys & Qt::SHIFT)) { | 778 | if ((keyQt == Qt::Key_Backtab) && (d->modifierKeys & Qt::SHIFT)) { | ||
davidedmundson: Should this section be using ShiftModifier? Qt::SHIFT has been masked out | |||||
qglobal.h: SHIFT = Qt::ShiftModifier And Shift hasn't been masked out, it's been masked in :) dfaure: qglobal.h: SHIFT = Qt::ShiftModifier
so it's the same (in case your sentence was… | |||||
776 | keyQt = Qt::Key_Tab | d->modifierKeys; | 779 | keyQt = Qt::Key_Tab | d->modifierKeys; | ||
777 | } else if (KKeyServer::isShiftAsModifierAllowed(keyQt)) { | 780 | } else if (KKeyServer::isShiftAsModifierAllowed(keyQt)) { | ||
778 | keyQt |= d->modifierKeys; | 781 | keyQt |= d->modifierKeys; | ||
779 | } else { | 782 | } else { | ||
780 | keyQt |= (d->modifierKeys & ~Qt::SHIFT); | 783 | keyQt |= (d->modifierKeys & ~Qt::SHIFT); | ||
781 | } | 784 | } | ||
782 | 785 | | |||
783 | if (d->nKey == 0) { | 786 | if (d->nKey == 0) { | ||
Show All 22 Lines | 805 | { | |||
806 | } | 809 | } | ||
807 | 810 | | |||
808 | if (!d->isRecording) { | 811 | if (!d->isRecording) { | ||
809 | return QPushButton::keyReleaseEvent(e); | 812 | return QPushButton::keyReleaseEvent(e); | ||
810 | } | 813 | } | ||
811 | 814 | | |||
812 | e->accept(); | 815 | e->accept(); | ||
813 | 816 | | |||
814 | uint newModifiers = e->modifiers() & (Qt::SHIFT | Qt::CTRL | Qt::ALT | Qt::META); | 817 | uint newModifiers = e->modifiers() & (Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier | Qt::KeypadModifier); | ||
815 | 818 | | |||
816 | //if a modifier that belongs to the shortcut was released... | 819 | //if a modifier that belongs to the shortcut was released... | ||
817 | if ((newModifiers & d->modifierKeys) < d->modifierKeys) { | 820 | if ((newModifiers & d->modifierKeys) < d->modifierKeys) { | ||
818 | d->modifierKeys = newModifiers; | 821 | d->modifierKeys = newModifiers; | ||
819 | d->controlModifierlessTimout(); | 822 | d->controlModifierlessTimout(); | ||
820 | d->updateShortcutDisplay(); | 823 | d->updateShortcutDisplay(); | ||
821 | } | 824 | } | ||
822 | } | 825 | } | ||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |
Should this section be using ShiftModifier? Qt::SHIFT has been masked out