From dcf48d9945590db3d74e4928837d99af5ea775a8 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 29 Jun 2015 09:51:05 +0530 Subject: [PATCH] Fix Cmd+Left/Right keyboard shortcut not working when editing items in the book list on OS X. Fixes #1469554 [Keyboard navigation when editing fields in main window](https://bugs.launchpad.net/calibre/+bug/1469554) Workaround for yet another Qt OSX bug. https://bugreports.qt.io/browse/QTBUG-46911 --- src/calibre/gui2/complete2.py | 7 +++++++ src/calibre/gui2/widgets.py | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/complete2.py b/src/calibre/gui2/complete2.py index 5539d6edd3..9cc8d3414b 100644 --- a/src/calibre/gui2/complete2.py +++ b/src/calibre/gui2/complete2.py @@ -340,6 +340,13 @@ class LineEdit(QLineEdit, LineEditECM): return property(fget=fget, fset=fset) # }}} + def event(self, ev): + # See https://bugreports.qt.io/browse/QTBUG-46911 + if ev.type() == ev.ShortcutOverride and ( + ev.key() in (Qt.Key_Left, Qt.Key_Right) and (ev.modifiers() & ~Qt.KeypadModifier) == Qt.ControlModifier): + ev.accept() + return QLineEdit.event(self, ev) + def complete(self, show_all=False, select_first=True): orig = None if show_all: diff --git a/src/calibre/gui2/widgets.py b/src/calibre/gui2/widgets.py index ed40a97e35..85b649109b 100644 --- a/src/calibre/gui2/widgets.py +++ b/src/calibre/gui2/widgets.py @@ -480,7 +480,13 @@ class EnLineEdit(LineEditECM, QLineEdit): # {{{ Includes an extended content menu. ''' - pass + def event(self, ev): + # See https://bugreports.qt.io/browse/QTBUG-46911 + if ev.type() == ev.ShortcutOverride and ( + ev.key() in (Qt.Key_Left, Qt.Key_Right) and (ev.modifiers() & ~Qt.KeypadModifier) == Qt.ControlModifier): + ev.accept() + return QLineEdit.event(self, ev) + # }}} class ItemsCompleter(QCompleter): # {{{