Keyboard shortcuts: Allow use of symbol keys like >,*,etc. Fixes #847378 (Error in shortcut-handler)

This commit is contained in:
Kovid Goyal 2011-09-12 11:48:53 -06:00
parent 7eadf1c5c1
commit 1ecfb81a07

View File

@ -443,7 +443,13 @@ class Editor(QFrame): # {{{
return QWidget.keyPressEvent(self, ev) return QWidget.keyPressEvent(self, ev)
button = getattr(self, 'button%d'%which) button = getattr(self, 'button%d'%which)
button.setStyleSheet('QPushButton { font-weight: normal}') button.setStyleSheet('QPushButton { font-weight: normal}')
sequence = QKeySequence(code|(int(ev.modifiers())&~Qt.KeypadModifier)) mods = int(ev.modifiers()) & ~Qt.KeypadModifier
txt = unicode(ev.text())
if txt and txt.lower() == txt.upper():
# We have a symbol like ! or > etc. In this case the value of code
# already includes Shift, so remove it
mods &= ~Qt.ShiftModifier
sequence = QKeySequence(code|mods)
button.setText(sequence.toString(QKeySequence.NativeText)) button.setText(sequence.toString(QKeySequence.NativeText))
self.capture = 0 self.capture = 0
dup_desc = self.dup_check(sequence) dup_desc = self.dup_check(sequence)