Skip to content

Commit

Permalink
Switch AddCards model without running hook
Browse files Browse the repository at this point in the history
Not the prettiest solution, but it should fix ospalh#102
  • Loading branch information
glutanimate committed Apr 13, 2017
1 parent fc4c9c6 commit 1facc5b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion quick_note_and_deck_buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@

from aqt.modelchooser import ModelChooser
from aqt.deckchooser import DeckChooser
from aqt.addcards import AddCards
from aqt.utils import tooltip

from anki.hooks import wrap
Expand Down Expand Up @@ -197,7 +198,13 @@ def change_model_to(chooser, model_name):
cdeck = chooser.deck.decks.current()
cdeck['mid'] = m['id']
chooser.deck.decks.save(cdeck)
runHook("currentModelChanged")
window = chooser.widget.parent()
if window and isinstance(window, AddCards):
# Workaround for "Multiple Windows" add-on:
window.onModelChange()
chooser.onReset()
else:
runHook("currentModelChanged")
chooser.mw.reset()


Expand Down

0 comments on commit 1facc5b

Please sign in to comment.