-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
Copy pathabout.py
231 lines (213 loc) · 6.95 KB
/
about.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import platform
from collections.abc import Callable
import aqt.forms
from anki.lang import without_unicode_isolation
from anki.utils import version_with_build
from aqt.errors import addon_debug_info
from aqt.qt import *
from aqt.utils import disable_help_button, supportText, tooltip, tr
class ClosableQDialog(QDialog):
def reject(self) -> None:
aqt.dialogs.markClosed("About")
QDialog.reject(self)
def accept(self) -> None:
aqt.dialogs.markClosed("About")
QDialog.accept(self)
def closeWithCallback(self, callback: Callable[[], None]) -> None:
self.reject()
callback()
def show(mw: aqt.AnkiQt) -> QDialog:
dialog = ClosableQDialog(mw)
disable_help_button(dialog)
mw.garbage_collect_on_dialog_finish(dialog)
abt = aqt.forms.about.Ui_About()
abt.setupUi(dialog)
def on_copy() -> None:
txt = supportText()
if mw.addonManager.dirty:
txt += "\n" + addon_debug_info()
clipboard = QApplication.clipboard()
assert clipboard is not None
clipboard.setText(txt)
tooltip(tr.about_copied_to_clipboard(), parent=dialog)
btn = QPushButton(tr.about_copy_debug_info())
qconnect(btn.clicked, on_copy)
abt.buttonBox.addButton(btn, QDialogButtonBox.ButtonRole.ActionRole)
ok_button = abt.buttonBox.button(QDialogButtonBox.StandardButton.Ok)
assert ok_button is not None
ok_button.setFocus()
btnLayout = abt.buttonBox.layout()
assert btnLayout is not None
btnLayout.setContentsMargins(12, 12, 12, 12)
# WebView cleanup
######################################################################
def on_dialog_destroyed() -> None:
abt.label.cleanup()
abt.label = None # type: ignore
qconnect(dialog.destroyed, on_dialog_destroyed)
# WebView contents
######################################################################
abouttext = "<center><img src='/_anki/imgs/anki-logo-thin.png'></center>"
abouttext += f"<p>{tr.about_anki_is_a_friendly_intelligent_spaced()}"
abouttext += f"<p>{tr.about_anki_is_licensed_under_the_agpl3()}"
abouttext += f"<p>{tr.about_version(val=version_with_build())}<br>"
abouttext += ("Python %s Qt %s PyQt %s<br>") % (
platform.python_version(),
qVersion(),
PYQT_VERSION_STR,
)
abouttext += (
without_unicode_isolation(tr.about_visit_website(val=aqt.appWebsite))
+ "</span>"
)
# Automatically sorted; add new lines at the end.
# This is a list of users who want to appear in the dialog, and includes people who have
# contributed in non-code ways, like providing support on the forums, so it cannot be
# generated from the CONTRIBUTORS file.
allusers = sorted(
(
"Aaron Harsh",
"Alex Fraser",
"Andreas Klauer",
"Andrew Wright",
"Aristotelis P.",
"Ben Nguyen",
"Bernhard Ibertsberger",
"C. van Rooyen",
"Cenaris Mori",
"Charlene Barina",
"Christian Krause",
"Christian Rusche",
"Dave Druelinger",
"David Culley",
"David Smith",
"Dmitry Mikheev",
"Dotan Cohen",
"Emilio Wuerges",
"Emmanuel Jarri",
"Frank Harper",
"Gregor Skumavc",
"Guillem Palau Salvà",
"H. Mijail",
"Henrik Enggaard Hansen",
"Houssam Salem",
"Ian Lewis",
"Immanuel Asmus",
"Iroiro",
"Jarvik7",
"Jin Eun-Deok",
"Jo Nakashima",
"Johanna Lindh",
"Joseph Lorimer",
"Julien Baley",
"Jussi Määttä",
"Kieran Clancy",
"LaC",
"Laurent Steffan",
"Luca Ban",
"Luciano Esposito",
"Marco Giancotti",
"Marcus Rubeus",
"Mari Egami",
"Mark Wilbur",
"Matthew Duggan",
"Matthew Holtz",
"Meelis Vasser",
"Michael Jürges",
"Michael Keppler",
"Michael Montague",
"Michael Penkov",
"Michal Čadil",
"Morteza Salehi",
"Nathanael Law",
"Nguyễn Hào Khôi",
"Nick Cook",
"Niklas Laxström",
"Norbert Nagold",
"Ole Guldberg",
"Pcsl88",
"Petr Michalec",
"Piotr Kubowicz",
"Richard Colley",
"Roland Sieker",
"Samson Melamed",
"Silja Ijas",
"Snezana Lukic",
"Soren Bjornstad",
"Stefaan De Pooter",
"Susanna Björverud",
"Sylvain Durand",
"Tacutu",
"Taylor Obyen",
"Timm Preetz",
"Timo Paulssen",
"Ursus",
"Victor Suba",
"Volker Jansen",
"Volodymyr Goncharenko",
"Xtru",
"Ádám Szegi",
"赵金鹏",
"黃文龍",
"David Bailey",
"Arman High",
"Arthur Milchior",
"Rai (Michael Pokorny)",
"AMBOSS MD Inc.",
"Erez Volk",
"Tobias Predel",
"Thomas Kahn",
"zjosua",
"Ijgnd",
"Evandro Coan",
"Alan Du",
"Abdo",
"Junseo Park",
"Gustavo Costa",
"余时行",
"叶峻峣",
"RumovZ",
"学习骇客",
"ready-research",
"Henrik Giesel",
"Yoonchae Lee",
"Hikaru Yoshiga",
"Matthias Metelka",
"Sergio Quintero",
"Nicholas Flint",
"Daniel Vieira Memoria10X",
"Luka Warren",
"Christos Longros",
"hafatsat anki",
"Carlos Duarte",
"Edgar Benavent Català",
"Kieran Black",
"Mateusz Wojewoda",
"Jarrett Ye",
"Gustavo Sales",
"Akash Reddy",
"Marko Sisovic",
"Lucas Scharenbroch",
"Antoine Q.",
"Ian Samir Yep Manzano",
"Asuka Minato",
"Eros Cardoso",
"Gregory Abrasaldo",
"Danika_Dakika",
"Marcelo Vasconcelos",
"Mumtaz Hajjo Alrifai",
"Thomas Lenz",
)
)
abouttext += "<p>" + tr.about_written_by_damien_elmes_with_patches(
cont=", ".join(allusers)
)
abouttext += f"<p>{tr.about_if_you_have_contributed_and_are()}"
abouttext += f"<p>{tr.about_a_big_thanks_to_all_the()}"
abt.label.setMinimumWidth(800)
abt.label.setMinimumHeight(600)
dialog.show()
abt.label.stdHtml(abouttext, js=[])
return dialog