From 5dc240d4ed39796bec72ac115d920160865b3ec5 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Fri, 21 Dec 2018 20:46:47 +0100 Subject: [PATCH] qt: show_message and friends display plaintext by default --- electrum/gui/qt/main_window.py | 2 +- electrum/gui/qt/util.py | 25 +++++++++++++++---------- electrum/plugins/revealer/qt.py | 12 ++++++++---- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py index 5e0283419..ddcf20b13 100644 --- a/electrum/gui/qt/main_window.py +++ b/electrum/gui/qt/main_window.py @@ -610,7 +610,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): _("Before reporting a bug, upgrade to the most recent version of Electrum (latest release or git HEAD), and include the version number in your report."), _("Try to explain not only what the bug is, but how it occurs.") ]) - self.show_message(msg, title="Electrum - " + _("Reporting Bugs")) + self.show_message(msg, title="Electrum - " + _("Reporting Bugs"), rich_text=True) def notify_transactions(self): if self.tx_notification_queue.qsize() == 0: diff --git a/electrum/gui/qt/util.py b/electrum/gui/qt/util.py index bfdf751a5..a8358ba57 100644 --- a/electrum/gui/qt/util.py +++ b/electrum/gui/qt/util.py @@ -190,24 +190,24 @@ class MessageBoxMixin(object): parent, title or '', msg, buttons=Yes|No, defaultButton=No) == Yes - def show_warning(self, msg, parent=None, title=None): + def show_warning(self, msg, parent=None, title=None, **kwargs): return self.msg_box(QMessageBox.Warning, parent, - title or _('Warning'), msg) + title or _('Warning'), msg, **kwargs) - def show_error(self, msg, parent=None): + def show_error(self, msg, parent=None, **kwargs): return self.msg_box(QMessageBox.Warning, parent, - _('Error'), msg) + _('Error'), msg, **kwargs) - def show_critical(self, msg, parent=None, title=None): + def show_critical(self, msg, parent=None, title=None, **kwargs): return self.msg_box(QMessageBox.Critical, parent, - title or _('Critical Error'), msg) + title or _('Critical Error'), msg, **kwargs) - def show_message(self, msg, parent=None, title=None): + def show_message(self, msg, parent=None, title=None, **kwargs): return self.msg_box(QMessageBox.Information, parent, - title or _('Information'), msg) + title or _('Information'), msg, **kwargs) def msg_box(self, icon, parent, title, text, buttons=QMessageBox.Ok, - defaultButton=QMessageBox.NoButton): + defaultButton=QMessageBox.NoButton, rich_text=False): parent = parent or self.top_level_window() if type(icon) is QPixmap: d = QMessageBox(QMessageBox.Information, title, str(text), buttons, parent) @@ -216,7 +216,12 @@ class MessageBoxMixin(object): d = QMessageBox(icon, title, str(text), buttons, parent) d.setWindowModality(Qt.WindowModal) d.setDefaultButton(defaultButton) - d.setTextInteractionFlags(Qt.TextSelectableByMouse | Qt.LinksAccessibleByMouse) + if rich_text: + d.setTextInteractionFlags(Qt.TextSelectableByMouse| Qt.LinksAccessibleByMouse) + d.setTextFormat(Qt.RichText) + else: + d.setTextInteractionFlags(Qt.TextSelectableByMouse) + d.setTextFormat(Qt.PlainText) return d.exec_() class WindowModalDialog(QDialog, MessageBoxMixin): diff --git a/electrum/plugins/revealer/qt.py b/electrum/plugins/revealer/qt.py index cfcf85f82..1c55ae891 100644 --- a/electrum/plugins/revealer/qt.py +++ b/electrum/plugins/revealer/qt.py @@ -170,19 +170,22 @@ class Plugin(RevealerPlugin): code_id = self.versioned_seed.checksum dialog.show_message(''.join([_("{} encrypted for Revealer {}_{} saved as PNG and PDF at: ").format(self.was, version, code_id), "", self.get_path_to_revealer_file(), "", "
", - "
", "", _("Always check you backups.")])) + "
", "", _("Always check you backups.")]), + rich_text=True) dialog.close() def ext_warning(self, dialog): dialog.show_message(''.join(["",_("Warning"), ": ", - _("your seed extension will not be included in the encrypted backup.")])) + _("your seed extension will not be included in the encrypted backup.")]), + rich_text=True) dialog.close() def bdone(self, dialog): version = self.versioned_seed.version code_id = self.versioned_seed.checksum dialog.show_message(''.join([_("Digital Revealer ({}_{}) saved as PNG and PDF at:").format(version, code_id), - "
","", self.get_path_to_revealer_file(), ''])) + "
","", self.get_path_to_revealer_file(), '']), + rich_text=True) def customtxt_limits(self): @@ -208,7 +211,8 @@ class Plugin(RevealerPlugin): .format(warning=_("Warning"), ver0=_("Revealers starting with 0 are not secure due to a vulnerability."), url=_("More info at: {}").format(f'{link}'), - risk=_("Proceed at your own risk."))) + risk=_("Proceed at your own risk.")), + rich_text=True) def cypherseed_dialog(self, window): self.warn_old_revealer()