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
|
||||
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
|
||||
message from appearing.
|
||||
addons-startup-failed = Add-on Startup Failed
|
||||
|
|
|
@ -49,6 +49,7 @@ from aqt.utils import (
|
|||
showInfo,
|
||||
showText,
|
||||
showWarning,
|
||||
supportText,
|
||||
tooltip,
|
||||
tr,
|
||||
)
|
||||
|
@ -229,7 +230,10 @@ class AddonManager:
|
|||
return os.path.join(root, module)
|
||||
|
||||
def loadAddons(self) -> None:
|
||||
from aqt import mw
|
||||
|
||||
broken: list[str] = []
|
||||
error_text = ""
|
||||
for addon in self.all_addon_meta():
|
||||
if not addon.enabled:
|
||||
continue
|
||||
|
@ -247,7 +251,9 @@ class AddonManager:
|
|||
broken.append(f"<a href={page}>{name}</a>")
|
||||
else:
|
||||
broken.append(name)
|
||||
print(traceback.format_exc())
|
||||
tb = traceback.format_exc()
|
||||
print(tb)
|
||||
error_text += f"When loading {name}:\n{tb}\n"
|
||||
|
||||
if broken:
|
||||
addons = "\n\n- " + "\n- ".join(broken)
|
||||
|
@ -260,29 +266,36 @@ class AddonManager:
|
|||
(diag, box) = showText(
|
||||
html2,
|
||||
type="html",
|
||||
copyBtn=True,
|
||||
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
|
||||
)
|
||||
but.clicked.connect(self.check_for_updates_after_load_failure)
|
||||
from aqt import mw
|
||||
check.clicked.connect(on_check)
|
||||
|
||||
copy = box.addButton(
|
||||
tr.about_copy_debug_info(), QDialogButtonBox.ButtonRole.ActionRole
|
||||
)
|
||||
copy.clicked.connect(on_copy)
|
||||
|
||||
# calling show immediately appears to crash
|
||||
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:
|
||||
aqt.dialogs.open("AddonsDialog", self)
|
||||
|
||||
|
|
Loading…
Reference in a new issue