anki/qt/aqt/about.py

222 lines
6.6 KiB
Python
Raw Normal View History

2019-02-05 04:59:03 +01:00
# Copyright: Ankitects Pty Ltd and contributors
# -*- coding: utf-8 -*-
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
2019-12-21 07:53:17 +01:00
import platform
2020-02-03 02:17:10 +01:00
import time
import aqt.forms
from anki.lang import without_unicode_isolation
2019-02-27 23:37:42 +01:00
from anki.utils import versionWithBuild
2020-02-04 02:46:57 +01:00
from aqt.addons import AddonManager, AddonMeta
2019-12-20 10:19:03 +01:00
from aqt.qt import *
from aqt.utils import TR, disable_help_button, supportText, tooltip, tr
2019-12-20 10:19:03 +01:00
class ClosableQDialog(QDialog):
def reject(self):
aqt.dialogs.markClosed("About")
QDialog.reject(self)
def accept(self):
aqt.dialogs.markClosed("About")
QDialog.accept(self)
def closeWithCallback(self, callback):
self.reject()
callback()
2019-12-23 01:34:10 +01:00
def show(mw):
dialog = ClosableQDialog(mw)
disable_help_button(dialog)
mw.setupDialogGC(dialog)
abt = aqt.forms.about.Ui_About()
abt.setupUi(dialog)
# Copy debug info
######################################################################
2020-02-04 08:06:50 +01:00
def addon_fmt(addmgr: AddonManager, addon: AddonMeta) -> str:
if addon.installed_at:
installed = time.strftime(
"%Y-%m-%dT%H:%M", time.localtime(addon.installed_at)
)
2020-02-03 02:17:10 +01:00
else:
2020-02-04 08:06:50 +01:00
installed = "0"
if addon.provided_name:
name = addon.provided_name
2020-02-03 02:17:10 +01:00
else:
2020-02-04 08:06:50 +01:00
name = "''"
user = addmgr.getConfig(addon.dir_name)
default = addmgr.addonConfigDefaults(addon.dir_name)
2020-02-03 02:17:10 +01:00
if user == default:
2020-02-04 08:06:50 +01:00
modified = "''"
2020-02-03 02:17:10 +01:00
else:
2020-02-04 08:06:50 +01:00
modified = "mod"
return f"{name} ['{addon.dir_name}', {installed}, '{addon.human_version}', {modified}]"
2020-02-03 02:17:10 +01:00
def onCopy():
addmgr = mw.addonManager
2020-02-03 02:17:10 +01:00
active = []
activeids = []
inactive = []
2020-02-04 08:06:50 +01:00
for addon in addmgr.all_addon_meta():
if addon.enabled:
active.append(addon_fmt(addmgr, addon))
if addon.ankiweb_id():
activeids.append(addon.dir_name)
2020-02-03 02:17:10 +01:00
else:
2020-02-04 08:06:50 +01:00
inactive.append(addon_fmt(addmgr, addon))
2020-02-03 02:17:10 +01:00
newline = "\n"
info = f"""
{supportText()}
===Add-ons (active)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
{newline.join(sorted(active))}
2020-02-04 08:06:41 +01:00
===IDs of active AnkiWeb add-ons===
2020-02-03 02:17:10 +01:00
{" ".join(activeids)}
===Add-ons (inactive)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
{newline.join(sorted(inactive))}
"""
info = " " + " ".join(info.splitlines(True))
QApplication.clipboard().setText(info)
tooltip(tr(TR.ABOUT_COPIED_TO_CLIPBOARD), parent=dialog)
btn = QPushButton(tr(TR.ABOUT_COPY_DEBUG_INFO))
qconnect(btn.clicked, onCopy)
abt.buttonBox.addButton(btn, QDialogButtonBox.ActionRole)
abt.buttonBox.button(QDialogButtonBox.Ok).setFocus()
# WebView contents
######################################################################
abouttext = "<center><img src='/_anki/imgs/anki-logo-thin.png'></center>"
2020-11-18 02:32:22 +01:00
abouttext += "<p>" + tr(TR.ABOUT_ANKI_IS_A_FRIENDLY_INTELLIGENT_SPACED)
abouttext += "<p>" + tr(TR.ABOUT_ANKI_IS_LICENSED_UNDER_THE_AGPL3)
abouttext += "<p>" + tr(TR.ABOUT_VERSION, val=versionWithBuild()) + "<br>"
2019-12-23 01:34:10 +01:00
abouttext += ("Python %s Qt %s PyQt %s<br>") % (
platform.python_version(),
QT_VERSION_STR,
PYQT_VERSION_STR,
)
abouttext += (
without_unicode_isolation(tr(TR.ABOUT_VISIT_WEBSITE, val=aqt.appWebsite))
+ "</span>"
)
# automatically sorted; add new lines at the end
2019-12-23 01:34:10 +01:00
allusers = sorted(
(
"Aaron Harsh",
"Alex Fraser",
"Andreas Klauer",
"Andrew Wright",
"Aristotelis P.",
"Bernhard Ibertsberger",
"C. van Rooyen",
"Charlene Barina",
"Christian Krause",
"Christian Rusche",
"Dave Druelinger",
"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",
"Timm Preetz",
"Timo Paulssen",
"Ursus",
"Victor Suba",
"Volker Jansen",
"Volodymyr Goncharenko",
"Xtru",
"Ádám Szegi",
"赵金鹏",
"黃文龍",
"David Bailey",
"Arman High",
"Arthur Milchior",
2019-12-25 01:25:57 +01:00
"Rai (Michael Pokorny)",
2020-01-03 18:37:50 +01:00
"AMBOSS MD Inc.",
"Erez Volk",
"Tobias Predel",
"Thomas Kahn",
"zjosua",
"Ijgnd",
"Evandro Coan",
"Alan Du",
"ANH",
"Junseo Park",
"Gustavo Costa",
"余时行",
2020-12-05 07:11:47 +01:00
"叶峻峣",
2019-12-23 01:34:10 +01:00
)
)
abouttext += "<p>" + tr(
TR.ABOUT_WRITTEN_BY_DAMIEN_ELMES_WITH_PATCHES, cont=", ".join(allusers)
)
2020-11-18 02:32:22 +01:00
abouttext += "<p>" + tr(TR.ABOUT_IF_YOU_HAVE_CONTRIBUTED_AND_ARE)
abouttext += "<p>" + tr(TR.ABOUT_A_BIG_THANKS_TO_ALL_THE)
2018-10-25 07:47:17 +02:00
abt.label.setMinimumWidth(800)
abt.label.setMinimumHeight(600)
dialog.show()
2020-02-12 22:20:30 +01:00
abt.label.stdHtml(abouttext, js=[])
return dialog