Add a button to copy debug information to About dialog

Supplies information on platform, app, toolkit, and installed add-ons.
Should come in useful to troubleshoot issues that do not produce an
error message, especially for add-on developers.
This commit is contained in:
Glutanimate 2019-02-24 14:55:55 +01:00
parent c45ea26cd6
commit 4fd5a9c176

View file

@ -4,7 +4,7 @@
from aqt.qt import *
import aqt.forms
from aqt.utils import versionWithBuild
from aqt.utils import versionWithBuild, supportText, tooltip
class ClosableQDialog(QDialog):
def reject(self):
@ -24,6 +24,23 @@ def show(mw):
mw.setupDialogGC(dialog)
abt = aqt.forms.about.Ui_About()
abt.setupUi(dialog)
# Copy debug info
######################################################################
def onCopy():
addmgr = mw.addonManager
addons = "\n".join(addmgr.annotatedName(d) for d in addmgr.allAddons())
info = "\n".join((supportText(), "Add-ons:\n\n{}".format(addons)))
QApplication.clipboard().setText(info)
tooltip(_("Copied to clipboard"), parent=dialog)
btn = QPushButton(_("Copy Debug Info"))
btn.clicked.connect(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>"
abouttext += '<p>' + _("Anki is a friendly, intelligent spaced learning \
system. It's free and open source.")