From aaf5770db9747a9441d9abd8ae691774aa8a700c Mon Sep 17 00:00:00 2001 From: RumovZ Date: Sat, 24 Oct 2020 10:47:25 +0200 Subject: [PATCH 1/3] Work around Qt's focus bug (fix help-wanted#22) Manually hide the editor's completer popup before accepting a short cut which changes the focus widget. Thus, work around the bug in PyQt 5.15 where a QLineEdit with open QCompleter popup won't get notified about focus changes handled by the Main Window, leading to inconsistent focus. --- qt/aqt/addcards.py | 4 ++++ qt/aqt/browser.py | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/qt/aqt/addcards.py b/qt/aqt/addcards.py index 5de6bbff1..127a2898e 100644 --- a/qt/aqt/addcards.py +++ b/qt/aqt/addcards.py @@ -195,6 +195,10 @@ class AddCards(QDialog): self.editor.saveAddModeVars() if not self.addNote(self.editor.note): return + + # workaround for PyQt focus bug + self.editor.hideCompleters() + tooltip(_("Added"), period=500) av_player.stop_and_clear_queue() self.onReset(keep=True) diff --git a/qt/aqt/browser.py b/qt/aqt/browser.py index 5db9fd142..705044d12 100644 --- a/qt/aqt/browser.py +++ b/qt/aqt/browser.py @@ -1061,6 +1061,9 @@ QTableView {{ gridline-color: {grid} }} self.maybeRefreshSidebar() def focusSidebar(self) -> None: + # workaround for PyQt focus bug + self.editor.hideCompleters() + self.sidebarDockWidget.setVisible(True) self.sidebarTree.setFocus() @@ -2072,10 +2075,16 @@ where id in %s""" sm.select(item, QItemSelectionModel.SelectCurrent | QItemSelectionModel.Rows) def onFind(self): + # workaround for PyQt focus bug + self.editor.hideCompleters() + self.form.searchEdit.setFocus() self.form.searchEdit.lineEdit().selectAll() def onNote(self): + # workaround for PyQt focus bug + self.editor.hideCompleters() + self.editor.web.setFocus() self.editor.loadNote(focusTo=0) From a1b7768ee266a1beea161affaa77d6cec25bc47b Mon Sep 17 00:00:00 2001 From: RumovZ Date: Sat, 24 Oct 2020 11:02:18 +0200 Subject: [PATCH 2/3] Add author to CONTRIBUTORS --- CONTRIBUTORS | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index f304612ec..bebf18827 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -65,6 +65,7 @@ lukkea David Allison Tsung-Han Yu Piotr Kubowicz +RumovZ ******************** From 5e949d19fe67d9a408e392667a34ebad3fd1fe83 Mon Sep 17 00:00:00 2001 From: RumovZ <48286681+RumovZ@users.noreply.github.com> Date: Thu, 29 Oct 2020 12:30:40 +0100 Subject: [PATCH 3/3] Space for author check --- CONTRIBUTORS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index bebf18827..c85c3ae31 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -65,7 +65,7 @@ lukkea David Allison Tsung-Han Yu Piotr Kubowicz -RumovZ +RumovZ ********************