-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
executable file
·54 lines (40 loc) · 1.48 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from .constants import *
from .profiles import Profile, FrenchProfile, EnglishProfile
from .edit_words_dialog import *
from .utils import *
from .profiles import *
from PyQt6.QtGui import QAction
from aqt import gui_hooks
import importlib
import os
import sys
from aqt import mw
import_task = None
print("loaded module")
def start_import(profile: Profile):
global import_task
import_task = profile.start_import()
currently_added_actions: [QAction] = []
def add_action_items(profile: Profile):
# add menu option to import new cards
options_action = QAction(f"Import from Cambridge ({profile.language})...", mw)
options_action.triggered.connect(lambda _, o=mw: start_import(profile))
mw.form.menuTools.addAction(options_action)
currently_added_actions.append(options_action)
# add menu option to import new cards
options_action = QAction(f"Update Tampermonkey list ({profile.language})", mw)
options_action.triggered.connect(lambda _, o=mw: profile.update_tampermonkey_list())
mw.form.menuTools.addAction(options_action)
currently_added_actions.append(options_action)
def remove_menu_items():
global currently_added_actions
for action in currently_added_actions:
print("unloading")
mw.form.menuTools.removeAction(action)
currently_added_actions = []
def add_menu_items():
# reload()
profiles: [Profile] = [EnglishProfile(), FrenchProfile()]
for profile in profiles:
add_action_items(profile)
add_menu_items()