From 6f4d4b9a1e3d24da4223c0c83dbe8f567ad95014 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Wed, 23 Dec 2015 18:42:01 +0900 Subject: [PATCH] Modality and centring fixes for QR codes --- gui/qt/main_window.py | 4 ++-- gui/qt/qrcodewidget.py | 16 +++++++--------- gui/qt/transaction_dialog.py | 4 ++-- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py index f3257c296..9264b433b 100644 --- a/gui/qt/main_window.py +++ b/gui/qt/main_window.py @@ -2023,10 +2023,10 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): - def show_qrcode(self, data, title = _("QR code")): + def show_qrcode(self, data, title = _("QR code"), parent=None): if not data: return - d = QRDialog(data, self, title) + d = QRDialog(data, parent or self, title) d.exec_() def show_public_keys(self, address): diff --git a/gui/qt/qrcodewidget.py b/gui/qt/qrcodewidget.py index ab1008de4..51a028470 100644 --- a/gui/qt/qrcodewidget.py +++ b/gui/qt/qrcodewidget.py @@ -1,6 +1,5 @@ from PyQt4.QtGui import * from PyQt4.QtCore import * -import PyQt4.QtCore as QtCore import PyQt4.QtGui as QtGui import os @@ -9,6 +8,7 @@ import qrcode import electrum from electrum import bmp from electrum.i18n import _ +from util import WindowModalDialog, MessageBoxMixin class QRCodeWidget(QWidget): @@ -83,13 +83,11 @@ class QRCodeWidget(QWidget): -class QRDialog(QDialog): +class QRDialog(WindowModalDialog, MessageBoxMixin): def __init__(self, data, parent=None, title = "", show_text=False): - QDialog.__init__(self, parent) + WindowModalDialog.__init__(self, parent, title) - d = self - d.setWindowTitle(title) vbox = QVBoxLayout() qrw = QRCodeWidget(data) vbox.addWidget(qrw, 1) @@ -107,12 +105,12 @@ class QRDialog(QDialog): def print_qr(): bmp.save_qrcode(qrw.qr, filename) - QMessageBox.information(None, _('Message'), _("QR code saved to file") + " " + filename, _('OK')) + self.show_message(_("QR code saved to file") + " " + filename) def copy_to_clipboard(): bmp.save_qrcode(qrw.qr, filename) QApplication.clipboard().setImage(QImage(filename)) - QMessageBox.information(None, _('Message'), _("QR code saved to clipboard"), _('OK')) + self.show_message(_("QR code copied to clipboard")) b = QPushButton(_("Copy")) hbox.addWidget(b) @@ -124,8 +122,8 @@ class QRDialog(QDialog): b = QPushButton(_("Close")) hbox.addWidget(b) - b.clicked.connect(d.accept) + b.clicked.connect(self.accept) b.setDefault(True) vbox.addLayout(hbox) - d.setLayout(vbox) + self.setLayout(vbox) diff --git a/gui/qt/transaction_dialog.py b/gui/qt/transaction_dialog.py index 180ed2c6c..a49dc1e8f 100644 --- a/gui/qt/transaction_dialog.py +++ b/gui/qt/transaction_dialog.py @@ -62,7 +62,7 @@ class TxDialog(QDialog, MessageBoxMixin): vbox.addWidget(QLabel(_("Transaction ID:"))) self.tx_hash_e = ButtonsLineEdit() - qr_show = lambda: self.parent.show_qrcode(str(self.tx_hash_e.text()), 'Transaction ID') + qr_show = lambda: self.parent.show_qrcode(str(self.tx_hash_e.text()), 'Transaction ID', parent=self) self.tx_hash_e.addButton(":icons/qrcode.png", qr_show, _("Show as QR code")) self.tx_hash_e.setReadOnly(True) vbox.addWidget(self.tx_hash_e) @@ -132,7 +132,7 @@ class TxDialog(QDialog, MessageBoxMixin): text = self.tx.raw.decode('hex') text = base_encode(text, base=43) try: - self.parent.show_qrcode(text, 'Transaction') + self.parent.show_qrcode(text, 'Transaction', parent=self) except Exception as e: self.show_message(str(e))