mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
be explicit about text format when showing add-on errors
fixes br codes showing in error messages
This commit is contained in:
parent
188d822d09
commit
139e04c7c3
2 changed files with 14 additions and 8 deletions
|
@ -553,7 +553,7 @@ class AddonsDialog(QDialog):
|
||||||
tooltip("<br>".join(log), parent=self)
|
tooltip("<br>".join(log), parent=self)
|
||||||
if errs:
|
if errs:
|
||||||
msg = _("Please report this to the respective add-on author(s).")
|
msg = _("Please report this to the respective add-on author(s).")
|
||||||
showWarning("<br><br>".join(errs + [msg]), parent=self)
|
showWarning("\n\n".join(errs + [msg]), parent=self, textFormat="plain")
|
||||||
|
|
||||||
self.redrawAddons()
|
self.redrawAddons()
|
||||||
|
|
||||||
|
@ -569,7 +569,7 @@ class AddonsDialog(QDialog):
|
||||||
if log:
|
if log:
|
||||||
tooltip("<br>".join(log), parent=self)
|
tooltip("<br>".join(log), parent=self)
|
||||||
if errs:
|
if errs:
|
||||||
showWarning("<br><br>".join(errs), parent=self)
|
showWarning("\n\n".join(errs), parent=self, textFormat="plain")
|
||||||
|
|
||||||
self.redrawAddons()
|
self.redrawAddons()
|
||||||
|
|
||||||
|
@ -627,7 +627,7 @@ class GetAddons(QDialog):
|
||||||
if log:
|
if log:
|
||||||
tooltip("<br>".join(log), parent=self.addonsDlg)
|
tooltip("<br>".join(log), parent=self.addonsDlg)
|
||||||
if errs:
|
if errs:
|
||||||
showWarning("<br><br>".join(errs))
|
showWarning("\n\n".join(errs), textFormat="plain")
|
||||||
|
|
||||||
self.addonsDlg.redrawAddons()
|
self.addonsDlg.redrawAddons()
|
||||||
QDialog.accept(self)
|
QDialog.accept(self)
|
||||||
|
|
16
aqt/utils.py
16
aqt/utils.py
|
@ -19,15 +19,15 @@ def openLink(link):
|
||||||
with noBundledLibs():
|
with noBundledLibs():
|
||||||
QDesktopServices.openUrl(QUrl(link))
|
QDesktopServices.openUrl(QUrl(link))
|
||||||
|
|
||||||
def showWarning(text, parent=None, help="", title="Anki"):
|
def showWarning(text, parent=None, help="", title="Anki", textFormat=None):
|
||||||
"Show a small warning with an OK button."
|
"Show a small warning with an OK button."
|
||||||
return showInfo(text, parent, help, "warning", title=title)
|
return showInfo(text, parent, help, "warning", title=title, textFormat=textFormat)
|
||||||
|
|
||||||
def showCritical(text, parent=None, help="", title="Anki"):
|
def showCritical(text, parent=None, help="", title="Anki", textFormat=None):
|
||||||
"Show a small critical error with an OK button."
|
"Show a small critical error with an OK button."
|
||||||
return showInfo(text, parent, help, "critical", title=title)
|
return showInfo(text, parent, help, "critical", title=title, textFormat=textFormat)
|
||||||
|
|
||||||
def showInfo(text, parent=False, help="", type="info", title="Anki"):
|
def showInfo(text, parent=False, help="", type="info", title="Anki", textFormat=None):
|
||||||
"Show a small info window with an OK button."
|
"Show a small info window with an OK button."
|
||||||
if parent is False:
|
if parent is False:
|
||||||
parent = aqt.mw.app.activeWindow() or aqt.mw
|
parent = aqt.mw.app.activeWindow() or aqt.mw
|
||||||
|
@ -38,6 +38,12 @@ def showInfo(text, parent=False, help="", type="info", title="Anki"):
|
||||||
else:
|
else:
|
||||||
icon = QMessageBox.Information
|
icon = QMessageBox.Information
|
||||||
mb = QMessageBox(parent)
|
mb = QMessageBox(parent)
|
||||||
|
if textFormat == "plain":
|
||||||
|
mb.setTextFormat(Qt.PlainText)
|
||||||
|
elif textFormat == "rich":
|
||||||
|
mb.setTextFormat(Qt.RichText)
|
||||||
|
else:
|
||||||
|
raise Exception("unexpected textFormat type")
|
||||||
mb.setText(text)
|
mb.setText(text)
|
||||||
mb.setIcon(icon)
|
mb.setIcon(icon)
|
||||||
mb.setWindowTitle(title)
|
mb.setWindowTitle(title)
|
||||||
|
|
Loading…
Reference in a new issue