mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Add 'copy debug info' button to add-on startup screen
This commit is contained in:
parent
0cd0ad9b07
commit
5a07ef06e4
2 changed files with 32 additions and 16 deletions
|
@ -11,6 +11,9 @@ addons-failed-to-load2 =
|
||||||
They may need to be updated to support this version of Anki. Click the { addons-check-for-updates } button
|
They may need to be updated to support this version of Anki. Click the { addons-check-for-updates } button
|
||||||
to see if any updates are available.
|
to see if any updates are available.
|
||||||
|
|
||||||
|
You can use the { about-copy-debug-info } button to get information that you can paste in a report to
|
||||||
|
the add-on author.
|
||||||
|
|
||||||
For add-ons that don't have an update available, you can disable or delete the add-on to prevent this
|
For add-ons that don't have an update available, you can disable or delete the add-on to prevent this
|
||||||
message from appearing.
|
message from appearing.
|
||||||
addons-startup-failed = Add-on Startup Failed
|
addons-startup-failed = Add-on Startup Failed
|
||||||
|
|
|
@ -49,6 +49,7 @@ from aqt.utils import (
|
||||||
showInfo,
|
showInfo,
|
||||||
showText,
|
showText,
|
||||||
showWarning,
|
showWarning,
|
||||||
|
supportText,
|
||||||
tooltip,
|
tooltip,
|
||||||
tr,
|
tr,
|
||||||
)
|
)
|
||||||
|
@ -229,7 +230,10 @@ class AddonManager:
|
||||||
return os.path.join(root, module)
|
return os.path.join(root, module)
|
||||||
|
|
||||||
def loadAddons(self) -> None:
|
def loadAddons(self) -> None:
|
||||||
|
from aqt import mw
|
||||||
|
|
||||||
broken: list[str] = []
|
broken: list[str] = []
|
||||||
|
error_text = ""
|
||||||
for addon in self.all_addon_meta():
|
for addon in self.all_addon_meta():
|
||||||
if not addon.enabled:
|
if not addon.enabled:
|
||||||
continue
|
continue
|
||||||
|
@ -247,7 +251,9 @@ class AddonManager:
|
||||||
broken.append(f"<a href={page}>{name}</a>")
|
broken.append(f"<a href={page}>{name}</a>")
|
||||||
else:
|
else:
|
||||||
broken.append(name)
|
broken.append(name)
|
||||||
print(traceback.format_exc())
|
tb = traceback.format_exc()
|
||||||
|
print(tb)
|
||||||
|
error_text += f"When loading {name}:\n{tb}\n"
|
||||||
|
|
||||||
if broken:
|
if broken:
|
||||||
addons = "\n\n- " + "\n- ".join(broken)
|
addons = "\n\n- " + "\n- ".join(broken)
|
||||||
|
@ -260,29 +266,36 @@ class AddonManager:
|
||||||
(diag, box) = showText(
|
(diag, box) = showText(
|
||||||
html2,
|
html2,
|
||||||
type="html",
|
type="html",
|
||||||
copyBtn=True,
|
|
||||||
run=False,
|
run=False,
|
||||||
)
|
)
|
||||||
but = box.addButton(
|
|
||||||
|
def on_check() -> None:
|
||||||
|
tooltip(tr.addons_checking())
|
||||||
|
|
||||||
|
def on_done(log: list[DownloadLogEntry]) -> None:
|
||||||
|
if not log:
|
||||||
|
tooltip(tr.addons_no_updates_available())
|
||||||
|
|
||||||
|
mw.check_for_addon_updates(by_user=True, on_done=on_done)
|
||||||
|
|
||||||
|
def on_copy() -> None:
|
||||||
|
txt = supportText() + "\n" + error_text
|
||||||
|
QApplication.clipboard().setText(txt)
|
||||||
|
tooltip(tr.about_copied_to_clipboard(), parent=diag)
|
||||||
|
|
||||||
|
check = box.addButton(
|
||||||
tr.addons_check_for_updates(), QDialogButtonBox.ButtonRole.ActionRole
|
tr.addons_check_for_updates(), QDialogButtonBox.ButtonRole.ActionRole
|
||||||
)
|
)
|
||||||
but.clicked.connect(self.check_for_updates_after_load_failure)
|
check.clicked.connect(on_check)
|
||||||
from aqt import mw
|
|
||||||
|
copy = box.addButton(
|
||||||
|
tr.about_copy_debug_info(), QDialogButtonBox.ButtonRole.ActionRole
|
||||||
|
)
|
||||||
|
copy.clicked.connect(on_copy)
|
||||||
|
|
||||||
# calling show immediately appears to crash
|
# calling show immediately appears to crash
|
||||||
mw.progress.single_shot(1000, diag.show)
|
mw.progress.single_shot(1000, diag.show)
|
||||||
|
|
||||||
def check_for_updates_after_load_failure(self) -> None:
|
|
||||||
from aqt import mw
|
|
||||||
|
|
||||||
tooltip(tr.addons_checking())
|
|
||||||
|
|
||||||
def on_done(log: list[DownloadLogEntry]) -> None:
|
|
||||||
if not log:
|
|
||||||
tooltip(tr.addons_no_updates_available())
|
|
||||||
|
|
||||||
mw.check_for_addon_updates(by_user=True, on_done=on_done)
|
|
||||||
|
|
||||||
def onAddonsDialog(self) -> None:
|
def onAddonsDialog(self) -> None:
|
||||||
aqt.dialogs.open("AddonsDialog", self)
|
aqt.dialogs.open("AddonsDialog", self)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue