anki/qt/aqt/about.py

205 lines
6.0 KiB
Python
Raw Normal View History

2019-02-05 04:59:03 +01:00
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
2021-04-14 10:22:02 +02:00
2019-12-21 07:53:17 +01:00
import platform
import aqt.forms
from anki.lang import without_unicode_isolation
PEP8 for rest of pylib (#1451) * PEP8 dbproxy.py * PEP8 errors.py * PEP8 httpclient.py * PEP8 lang.py * PEP8 latex.py * Add decorator to deprectate key words * Make replacement for deprecated attribute optional * Use new helper `_print_replacement_warning()` * PEP8 media.py * PEP8 rsbackend.py * PEP8 sound.py * PEP8 stdmodels.py * PEP8 storage.py * PEP8 sync.py * PEP8 tags.py * PEP8 template.py * PEP8 types.py * Fix DeprecatedNamesMixinForModule The class methods need to be overridden with instance methods, so every module has its own dicts. * Use `# pylint: disable=invalid-name` instead of id * PEP8 utils.py * Only decorate `__getattr__` with `@no_type_check` * Fix mypy issue with snakecase Importing it from `anki._vendor` raises attribute errors. * Format * Remove inheritance of DeprecatedNamesMixin There's almost no shared code now and overriding classmethods with instance methods raises mypy issues. * Fix traceback frames of deprecation warnings * remove fn/TimedLog (dae) Neither Anki nor add-ons appear to have been using it * fix some issues with stringcase use (dae) - the wheel was depending on the PyPI version instead of our vendored version - _vendor:stringcase should not have been listed in the anki py_library. We already include the sources in py_srcs, and need to refer to them directly. By listing _vendor:stringcase as well, we were making a top-level stringcase library available, which would have only worked for distributing because the wheel definition was also incorrect. - mypy errors are what caused me to mistakenly add the above - they were because the type: ignore at the top of stringcase.py was causing mypy to completely ignore the file, so it was not aware of any attributes it contained.
2021-10-25 06:50:13 +02:00
from anki.utils import version_with_build
from aqt.errors import addon_debug_info
2019-12-20 10:19:03 +01:00
from aqt.qt import *
from aqt.utils import disable_help_button, supportText, tooltip, tr
2019-12-20 10:19:03 +01:00
class ClosableQDialog(QDialog):
2021-02-01 14:28:21 +01:00
def reject(self) -> None:
aqt.dialogs.markClosed("About")
QDialog.reject(self)
2021-02-01 14:28:21 +01:00
def accept(self) -> None:
aqt.dialogs.markClosed("About")
QDialog.accept(self)
def closeWithCallback(self, callback: Callable[[], None]) -> None:
self.reject()
callback()
2019-12-23 01:34:10 +01:00
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()
QApplication.clipboard().setText(txt)
2021-03-26 04:48:26 +01:00
tooltip(tr.about_copied_to_clipboard(), parent=dialog)
2021-03-26 04:48:26 +01:00
btn = QPushButton(tr.about_copy_debug_info())
qconnect(btn.clicked, on_copy)
abt.buttonBox.addButton(btn, QDialogButtonBox.ButtonRole.ActionRole)
abt.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setFocus()
2021-11-29 03:31:37 +01:00
# WebView cleanup
######################################################################
def on_dialog_destroyed() -> None:
abt.label.cleanup()
abt.label = None
qconnect(dialog.destroyed, on_dialog_destroyed)
# WebView contents
######################################################################
abouttext = "<center><img src='/_anki/imgs/anki-logo-thin.png'></center>"
2021-03-26 04:48:26 +01:00
abouttext += f"<p>{tr.about_anki_is_a_friendly_intelligent_spaced()}"
abouttext += f"<p>{tr.about_anki_is_licensed_under_the_agpl3()}"
PEP8 for rest of pylib (#1451) * PEP8 dbproxy.py * PEP8 errors.py * PEP8 httpclient.py * PEP8 lang.py * PEP8 latex.py * Add decorator to deprectate key words * Make replacement for deprecated attribute optional * Use new helper `_print_replacement_warning()` * PEP8 media.py * PEP8 rsbackend.py * PEP8 sound.py * PEP8 stdmodels.py * PEP8 storage.py * PEP8 sync.py * PEP8 tags.py * PEP8 template.py * PEP8 types.py * Fix DeprecatedNamesMixinForModule The class methods need to be overridden with instance methods, so every module has its own dicts. * Use `# pylint: disable=invalid-name` instead of id * PEP8 utils.py * Only decorate `__getattr__` with `@no_type_check` * Fix mypy issue with snakecase Importing it from `anki._vendor` raises attribute errors. * Format * Remove inheritance of DeprecatedNamesMixin There's almost no shared code now and overriding classmethods with instance methods raises mypy issues. * Fix traceback frames of deprecation warnings * remove fn/TimedLog (dae) Neither Anki nor add-ons appear to have been using it * fix some issues with stringcase use (dae) - the wheel was depending on the PyPI version instead of our vendored version - _vendor:stringcase should not have been listed in the anki py_library. We already include the sources in py_srcs, and need to refer to them directly. By listing _vendor:stringcase as well, we were making a top-level stringcase library available, which would have only worked for distributing because the wheel definition was also incorrect. - mypy errors are what caused me to mistakenly add the above - they were because the type: ignore at the top of stringcase.py was causing mypy to completely ignore the file, so it was not aware of any attributes it contained.
2021-10-25 06:50:13 +02:00
abouttext += f"<p>{tr.about_version(val=version_with_build())}<br>"
2019-12-23 01:34:10 +01:00
abouttext += ("Python %s Qt %s PyQt %s<br>") % (
platform.python_version(),
qVersion(),
2019-12-23 01:34:10 +01:00
PYQT_VERSION_STR,
)
abouttext += (
without_unicode_isolation(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",
"Abdo",
"Junseo Park",
"Gustavo Costa",
"余时行",
2020-12-05 07:11:47 +01:00
"叶峻峣",
2021-03-10 11:34:28 +01:00
"RumovZ",
2021-04-14 03:03:17 +02:00
"学习骇客",
2021-10-14 13:02:21 +02:00
"ready-research",
"Henrik Giesel",
"Yoonchae Lee",
"Hikaru Yoshiga",
"Matthias Metelka",
"Sergio Quintero",
"Nicholas Flint",
"Daniel Vieira Memoria10X",
"Luka Warren",
2022-10-15 02:58:43 +02:00
"Christos Longros",
"hafatsat anki",
2022-12-19 03:12:25 +01:00
"Carlos Duarte",
"Edgar Benavent Català",
"Kieran Black",
"Mateusz Wojewoda",
Integrate FSRS into Anki (#2654) * Pack FSRS data into card.data * Update FSRS card data when preset or weights change + Show FSRS stats in card stats * Show a warning when there's a limited review history * Add some translations; tweak UI * Fix default requested retention * Add browser columns, fix calculation of R * Property searches eg prop:d>0.1 * Integrate FSRS into reviewer * Warn about long learning steps * Hide minimum interval when FSRS is on * Don't apply interval multiplier to FSRS intervals * Expose memory state to Python * Don't set memory state on new cards * Port Jarret's new tests; add some helpers to make tests more compact https://github.com/open-spaced-repetition/fsrs-rs/pull/64 * Fix learning cards not being given memory state * Require update to v3 scheduler * Don't exclude single learning step when calculating memory state * Use relearning step when learning steps unavailable * Update docstring * fix single_card_revlog_to_items (#2656) * not need check the review_kind for unique_dates * add email address to CONTRIBUTORS * fix last first learn & keep early review * cargo fmt * cargo clippy --fix * Add Jarrett to about screen * Fix fsrs_memory_state being initialized to default in get_card() * Set initial memory state on graduate * Update to latest FSRS * Fix experiment.log being empty * Fix broken colpkg imports Introduced by "Update FSRS card data when preset or weights change" * Update memory state during (re)learning; use FSRS for graduating intervals * Reset memory state when cards are manually rescheduled as new * Add difficulty graph; hide eases when FSRS enabled * Add retrievability graph * Derive memory_state from revlog when it's missing and shouldn't be --------- Co-authored-by: Jarrett Ye <jarrett.ye@outlook.com>
2023-09-16 08:09:26 +02:00
"Jarrett Ye",
"Gustavo Sales",
"Akash Reddy",
"Marko Sisovic",
2019-12-23 01:34:10 +01:00
)
)
abouttext += "<p>" + tr.about_written_by_damien_elmes_with_patches(
cont=", ".join(allusers)
)
2021-03-26 04:48:26 +01:00
abouttext += f"<p>{tr.about_if_you_have_contributed_and_are()}"
abouttext += f"<p>{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