From 8074e7b5a89fac83a4e27108fe2038c229125b07 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sun, 28 Nov 2010 18:03:00 +0900 Subject: [PATCH] more robust add cards fix --- ankiqt/ui/facteditor.py | 9 ++------- ankiqt/ui/main.py | 5 +++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/ankiqt/ui/facteditor.py b/ankiqt/ui/facteditor.py index be517e069..d8abe7c29 100644 --- a/ankiqt/ui/facteditor.py +++ b/ankiqt/ui/facteditor.py @@ -512,10 +512,7 @@ class FactEditor(object): self.fact.setModified(textChanged=True) self.loadFields(font=False) if modified and self.resetOnEdit: - oldFocus = ankiqt.mw.app.focusWidget() - ankiqt.mw.reset() - if oldFocus: - oldFocus.setFocus() + ankiqt.mw.reset(runHooks=False) def onTextChanged(self): interval = 250 @@ -981,7 +978,6 @@ class FactEdit(QTextEdit): def __init__(self, parent, *args): QTextEdit.__init__(self, *args) self.parent = parent - self._programLayout = None if sys.platform.startswith("win32"): self._ownLayout = None @@ -1086,8 +1082,7 @@ class FactEdit(QTextEdit): self.parent.lastFocusedEdit = self self.parent.resetFormatButtons() self.parent.disableButtons() - # for some reason this can be fired before a focus in has fired - if sys.platform.startswith("win32") and self._programLayout: + if sys.platform.startswith("win32"): self._ownLayout = GetKeyboardLayout(0) ActivateKeyboardLayout(self._programLayout, 0) self.emit(SIGNAL("lostFocus")) diff --git a/ankiqt/ui/main.py b/ankiqt/ui/main.py index f863b777d..88e812f78 100755 --- a/ankiqt/ui/main.py +++ b/ankiqt/ui/main.py @@ -291,13 +291,14 @@ Please do not file a bug report with Anki.
""") self.views = self.viewsBackup self.viewsBackup = None - def reset(self, count=True, priorities=False): + def reset(self, count=True, priorities=False, runHooks=True): if self.deck: self.deck.refreshSession() if priorities: self.deck.updateAllPriorities() self.deck.reset() - runHook("guiReset") + if runHooks: + runHook("guiReset") self.moveToState("initial") def moveToState(self, state):