forked from xxyzz/WordDumb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.py
51 lines (41 loc) · 1.8 KB
/
ui.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
#!/usr/bin/env python3
from functools import partial
from calibre.constants import ismacos
from calibre.gui2.actions import InterfaceAction
from calibre_plugins.worddumb.config import ConfigWidget
from calibre_plugins.worddumb.main import ParseBook
class WordDumb(InterfaceAction):
name = 'WordDumb'
action_spec = ('WordDumb', None, 'Good morning Krusty Crew!', None)
action_type = 'current'
action_add_menu = True
if ismacos:
action_menu_clone_qaction = 'Create Word Wise'
else:
action_menu_clone_qaction = 'Create Word Wise and X-Ray'
def genesis(self):
icon = get_icons('starfish.svg') # noqa: F821
self.qaction.setIcon(icon)
self.menu = self.qaction.menu()
if ismacos:
self.qaction.triggered.connect(partial(run, self.gui, True, False))
else:
self.qaction.triggered.connect(partial(run, self.gui, True, True))
self.create_menu_action(
self.menu, 'Word Wise', 'Create Word Wise',
triggered=partial(run, self.gui, True, False))
self.create_menu_action(
self.menu, 'X-Ray', 'Create X-Ray',
triggered=partial(run, self.gui, False, True))
self.menu.addSeparator()
self.create_menu_action(self.menu, 'Preferences', 'Preferences',
triggered=self.config)
self.menu.addSeparator()
self.create_menu_action(self.menu, 'Donate', 'Donate',
description='I need about tree-fiddy.',
triggered=ConfigWidget.donate)
self.qaction.setMenu(self.menu)
def config(self):
self.interface_action_base_plugin.do_user_config(self.gui)
def run(gui, create_ww, create_x):
ParseBook(gui).parse(create_ww, create_x)