def _setupHooks(self): try: # 2.1.20+ from aqt.gui_hooks import profile_will_close profile_will_close.append(self.close) except (ImportError, ModuleNotFoundError): from anki.hooks import addHook addHook("unloadProfile", self.close)
def closeEvent(self, event): if mw.pm.profile is not None: self.deckChooser.cleanup() saveGeom(self, "imgoccedit") self.visible = False self.svg_edit = None del(self.svg_edit_anim) # might not be gc'd try: from aqt.gui_hooks import profile_will_close profile_will_close.append(self.onProfileUnload) except (ImportError, ModuleNotFoundError): remHook("unloadProfile", self.onProfileUnload) QDialog.reject(self)
def __init__(self, imgoccadd, parent): QDialog.__init__(self) mw.setupDialogGC(self) self.setWindowFlags(Qt.Window) self.visible = False self.imgoccadd = imgoccadd self.parent = parent self.mode = "add" loadConfig(self) self.setupUi() restoreGeom(self, "imgoccedit") try: from aqt.gui_hooks import profile_will_close profile_will_close.append(self.onProfileUnload) except (ImportError, ModuleNotFoundError): addHook("unloadProfile", self.onProfileUnload)
def init_conf_dict(): profile_did_open.append(load_conf_dict) profile_will_close.append(save_conf_dict)
if mw.pm.name not in prev_for_all_profiles: prev_for_all_profiles[mw.pm.name] = {} profile_did_open.append(load_prev) def savedict(): global prev_for_all_profiles if mw.pm.name not in prev_for_all_profiles: prev_for_all_profiles[mw.pm.name] = {} prev_for_all_profiles[mw.pm.name][mw.col.sched.today] = new_count() picklesave(prev_for_all_profiles, addons_pickle) profile_will_close.append(savedict) #### show stats from .toolbar import getMenu from aqt.utils import showInfo from aqt.qt import QAction from pprint import pformat def show_new_cards_learned(): prev_for_all_profiles[mw.pm.name][mw.col.sched.today] = new_count() dict_of_new = prev_for_all_profiles[mw.pm.name].copy() dict_of_new_with_real_dates = {} if datetime.datetime.now().timestamp() > return_day_start_in_epoch():
def init_deckbrowser(): profile_did_open.append(add_deckbrowser_hook) profile_will_close.append(remove_deckbrowser_hook) DeckBrowser._linkHandler = wrap(DeckBrowser._linkHandler, add_browser_search_link, "before")
alreadyrun = False def main_setup_menus(): # noqa global alreadyrun if alreadyrun: return alreadyrun = True view = get_menu(mw, "&View") action = QAction(mw) action.setText("Card Stats") action.setCheckable(True) action.setChecked(sidebar_visibility) action.setShortcut(QKeySequence("Shift+C")) view.addAction(action) action.toggled.connect(card_stats) profile_did_open.append(main_setup_menus) # noqa def hide_sidebar(): global sidebar_visibility cs.hide() profile_will_close.append(hide_sidebar) # noqa