-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathmain.py
67 lines (50 loc) · 2.09 KB
/
main.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
55
56
57
58
59
60
61
62
63
64
65
66
67
# from PyQt6.QtGui import QIcon, QFont
# from PyQt6.QtWidgets import *
# from aqt import mw
# from aqt.utils import tooltip
# from anki.hooks import addHook
from aqt import mw
from aqt.qt import QAction, QMenu, QDialog
from aqt.utils import showInfo
from .gui import *
from ._names import *
from .Cambridge import CDDownloader
def ask_user_for_link():
window = LinkDialogue()
setattr(mw, LINK_DLG_NAME, window)
r = window.exec()
downloader = mw.cddownloader
if r == QDialog.DialogCode.Accepted and downloader.word_data:
sd = WordDefDialogue(downloader.word_data, downloader.word)
sd.exec()
sd = None
def open_main_windows_addon():
window = AddonConfigWindow()
window.exec()
def parse_saved_wl():
mw.wl_pareser = WParseSavedWL()
mw.wl_pareser.parse()
mw.edit_cambridge_submenu = QMenu(u"&Cambridge Dictionary", mw)
mw.form.menuEdit.addSeparator()
mw.form.menuEdit.addMenu(mw.edit_cambridge_submenu)
# Single word
mw.create_notes_from_link_action = QAction(mw)
mw.create_notes_from_link_action.setText("Create new note(s) from link")
mw.create_notes_from_link_action.setToolTip("Fetch word definitions from provided link.")
mw.create_notes_from_link_action.setShortcut(CREATE_NEW_NOTES_SHORTCUT)
mw.create_notes_from_link_action.triggered.connect(ask_user_for_link)
mw.edit_cambridge_submenu.addAction(mw.create_notes_from_link_action)
# Word list - saved
mw.parse_saved_wl_action = QAction(mw)
mw.parse_saved_wl_action.setText("Fetch new words from user wordlists")
mw.parse_saved_wl_action.setToolTip("Fetch new words from user wordlists")
mw.parse_saved_wl_action.triggered.connect(parse_saved_wl)
mw.edit_cambridge_submenu.addAction(mw.parse_saved_wl_action)
# Addon settings
mw.edit_cambridge_submenu.addSeparator()
mw.open_main_windows_action = QAction(mw)
mw.open_main_windows_action.setText("Cambridge Addon")
mw.open_main_windows_action.setToolTip("Open Cambridge Addon main window.")
mw.open_main_windows_action.triggered.connect(open_main_windows_addon)
mw.edit_cambridge_submenu.addAction(mw.open_main_windows_action)
mw.cddownloader = CDDownloader()