From 1ecfb81a0708b4f7027d5dde6f8b189f8e060933 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 12 Sep 2011 11:48:53 -0600 Subject: [PATCH] Keyboard shortcuts: Allow use of symbol keys like >,*,etc. Fixes #847378 (Error in shortcut-handler) --- src/calibre/gui2/keyboard.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/keyboard.py b/src/calibre/gui2/keyboard.py index 9b0b1d8f69..362a074304 100644 --- a/src/calibre/gui2/keyboard.py +++ b/src/calibre/gui2/keyboard.py @@ -443,7 +443,13 @@ class Editor(QFrame): # {{{ return QWidget.keyPressEvent(self, ev) button = getattr(self, 'button%d'%which) 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)) self.capture = 0 dup_desc = self.dup_check(sequence)