From 0a9825d39aa04a1efee9c4da41a4f331ceb66790 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 6 Jan 2014 17:20:17 +0530 Subject: [PATCH] Handle changing focus ed widget in parent while charmap is visible --- src/calibre/gui2/tweak_book/char_select.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/calibre/gui2/tweak_book/char_select.py b/src/calibre/gui2/tweak_book/char_select.py index 53da28314e..298552212d 100644 --- a/src/calibre/gui2/tweak_book/char_select.py +++ b/src/calibre/gui2/tweak_book/char_select.py @@ -6,7 +6,7 @@ from __future__ import (unicode_literals, division, absolute_import, __license__ = 'GPL v3' __copyright__ = '2014, Kovid Goyal ' -import unicodedata, re, weakref +import unicodedata, re from bisect import bisect from functools import partial @@ -716,10 +716,6 @@ class CharSelect(Dialog): self.char_info.clear() def show(self): - try: - self.focus_widget = weakref.ref(QApplication.focusWidget()) - except TypeError: - self.focus_widget = None self.initialize() Dialog.show(self) self.raise_() @@ -727,17 +723,22 @@ class CharSelect(Dialog): def char_selected(self, c): if QApplication.keyboardModifiers() & Qt.CTRL: self.hide() - if self.focus_widget is None or self.focus_widget() is None: + if self.parent() is None or self.parent().focusWidget() is None: QApplication.clipboard().setText(c) return - w = self.focus_widget() + self.parent().activateWindow() + w = self.parent().focusWidget() if hasattr(w, 'textCursor'): cr = w.textCursor() cr.insertText(c) w.setTextCursor(cr) elif hasattr(w, 'insert'): + if hasattr(w, 'no_popup'): + oval = w.no_popup + w.no_popup = True w.insert(c) - + if hasattr(w, 'no_popup'): + w.no_popup = oval if __name__ == '__main__': app = QApplication([])