Merge pull request #286 from glutanimate/about-debug-info
Add a button to copy debug info to the About screen
This commit is contained in:
commit
51ad750a63
19
aqt/about.py
19
aqt/about.py
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
import aqt.forms
|
import aqt.forms
|
||||||
from aqt.utils import versionWithBuild
|
from aqt.utils import versionWithBuild, supportText, tooltip
|
||||||
|
|
||||||
class ClosableQDialog(QDialog):
|
class ClosableQDialog(QDialog):
|
||||||
def reject(self):
|
def reject(self):
|
||||||
@ -24,6 +24,23 @@ def show(mw):
|
|||||||
mw.setupDialogGC(dialog)
|
mw.setupDialogGC(dialog)
|
||||||
abt = aqt.forms.about.Ui_About()
|
abt = aqt.forms.about.Ui_About()
|
||||||
abt.setupUi(dialog)
|
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 = "<center><img src='/_anki/imgs/anki-logo-thin.png'></center>"
|
||||||
abouttext += '<p>' + _("Anki is a friendly, intelligent spaced learning \
|
abouttext += '<p>' + _("Anki is a friendly, intelligent spaced learning \
|
||||||
system. It's free and open source.")
|
system. It's free and open source.")
|
||||||
|
@ -115,6 +115,12 @@ When loading '%(name)s':
|
|||||||
def addonName(self, dir):
|
def addonName(self, dir):
|
||||||
return self.addonMeta(dir).get("name", dir)
|
return self.addonMeta(dir).get("name", dir)
|
||||||
|
|
||||||
|
def annotatedName(self, dir):
|
||||||
|
buf = self.addonName(dir)
|
||||||
|
if not self.isEnabled(dir):
|
||||||
|
buf += _(" (disabled)")
|
||||||
|
return buf
|
||||||
|
|
||||||
# Conflict resolution
|
# Conflict resolution
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
@ -456,7 +462,7 @@ class AddonsDialog(QDialog):
|
|||||||
addonList = self.form.addonList
|
addonList = self.form.addonList
|
||||||
mgr = self.mgr
|
mgr = self.mgr
|
||||||
|
|
||||||
self.addons = [(self.annotatedName(d), d) for d in mgr.allAddons()]
|
self.addons = [(mgr.annotatedName(d), d) for d in mgr.allAddons()]
|
||||||
self.addons.sort()
|
self.addons.sort()
|
||||||
|
|
||||||
selected = set(self.selectedAddons())
|
selected = set(self.selectedAddons())
|
||||||
@ -477,12 +483,6 @@ class AddonsDialog(QDialog):
|
|||||||
addon = ''
|
addon = ''
|
||||||
self.form.viewPage.setEnabled(bool (re.match(r"^\d+$", addon)))
|
self.form.viewPage.setEnabled(bool (re.match(r"^\d+$", addon)))
|
||||||
|
|
||||||
def annotatedName(self, dir):
|
|
||||||
buf = self.mgr.addonName(dir)
|
|
||||||
if not self.mgr.isEnabled(dir):
|
|
||||||
buf += _(" (disabled)")
|
|
||||||
return buf
|
|
||||||
|
|
||||||
def selectedAddons(self):
|
def selectedAddons(self):
|
||||||
idxs = [x.row() for x in self.form.addonList.selectedIndexes()]
|
idxs = [x.row() for x in self.form.addonList.selectedIndexes()]
|
||||||
return [self.addons[idx][1] for idx in idxs]
|
return [self.addons[idx][1] for idx in idxs]
|
||||||
|
@ -7,7 +7,7 @@ import re
|
|||||||
|
|
||||||
from anki.lang import _
|
from anki.lang import _
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
from aqt.utils import showText, showWarning
|
from aqt.utils import showText, showWarning, supportText
|
||||||
from aqt import mw
|
from aqt import mw
|
||||||
|
|
||||||
if not os.environ.get("DEBUG"):
|
if not os.environ.get("DEBUG"):
|
||||||
@ -126,10 +126,10 @@ add-ons section</a> of our support site.
|
|||||||
""")
|
""")
|
||||||
if self.mw.addonManager.dirty:
|
if self.mw.addonManager.dirty:
|
||||||
txt = pluginText
|
txt = pluginText
|
||||||
error = self._supportText() + self._addonText(error) + "\n" + error
|
error = supportText() + self._addonText(error) + "\n" + error
|
||||||
else:
|
else:
|
||||||
txt = stdText
|
txt = stdText
|
||||||
error = self._supportText() + "\n" + error
|
error = supportText() + "\n" + error
|
||||||
|
|
||||||
# show dialog
|
# show dialog
|
||||||
txt = txt + "<div style='white-space: pre-wrap'>" + error + "</div>"
|
txt = txt + "<div style='white-space: pre-wrap'>" + error + "</div>"
|
||||||
@ -146,27 +146,3 @@ add-ons section</a> of our support site.
|
|||||||
# highlight importance of first add-on:
|
# highlight importance of first add-on:
|
||||||
addons[0] = "<b>{}</b>".format(addons[0])
|
addons[0] = "<b>{}</b>".format(addons[0])
|
||||||
return txt.format(", ".join(addons))
|
return txt.format(", ".join(addons))
|
||||||
|
|
||||||
def _supportText(self):
|
|
||||||
import platform
|
|
||||||
from aqt.utils import versionWithBuild
|
|
||||||
|
|
||||||
if isWin:
|
|
||||||
platname = "Windows " + platform.win32_ver()[0]
|
|
||||||
elif isMac:
|
|
||||||
platname = "Mac " + platform.mac_ver()[0]
|
|
||||||
else:
|
|
||||||
platname = "Linux"
|
|
||||||
|
|
||||||
def schedVer():
|
|
||||||
try:
|
|
||||||
return self.mw.col.schedVer()
|
|
||||||
except:
|
|
||||||
return "?"
|
|
||||||
|
|
||||||
return """\
|
|
||||||
Anki {} Python {} Qt {} PyQt {}
|
|
||||||
Platform: {}
|
|
||||||
Flags: frz={} ao={} sv={}
|
|
||||||
""".format(versionWithBuild(), platform.python_version(), QT_VERSION_STR, PYQT_VERSION_STR, platname,
|
|
||||||
getattr(sys, "frozen", False), self.mw.addonManager.dirty, schedVer())
|
|
||||||
|
27
aqt/utils.py
27
aqt/utils.py
@ -567,6 +567,33 @@ def versionWithBuild():
|
|||||||
build = "dev"
|
build = "dev"
|
||||||
return "%s (%s)" % (appVersion, build)
|
return "%s (%s)" % (appVersion, build)
|
||||||
|
|
||||||
|
def supportText():
|
||||||
|
import platform
|
||||||
|
from aqt import mw
|
||||||
|
from aqt.utils import versionWithBuild
|
||||||
|
|
||||||
|
if isWin:
|
||||||
|
platname = "Windows " + platform.win32_ver()[0]
|
||||||
|
elif isMac:
|
||||||
|
platname = "Mac " + platform.mac_ver()[0]
|
||||||
|
else:
|
||||||
|
platname = "Linux"
|
||||||
|
|
||||||
|
def schedVer():
|
||||||
|
try:
|
||||||
|
return mw.col.schedVer()
|
||||||
|
except:
|
||||||
|
return "?"
|
||||||
|
|
||||||
|
return """\
|
||||||
|
Anki {} Python {} Qt {} PyQt {}
|
||||||
|
Platform: {}
|
||||||
|
Flags: frz={} ao={} sv={}
|
||||||
|
""".format(versionWithBuild(), platform.python_version(),
|
||||||
|
QT_VERSION_STR, PYQT_VERSION_STR, platname,
|
||||||
|
getattr(sys, "frozen", False),
|
||||||
|
mw.addonManager.dirty, schedVer())
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
# adapted from version detection in qutebrowser
|
# adapted from version detection in qutebrowser
|
||||||
|
Loading…
Reference in New Issue
Block a user