Modality and centring fixes for QR codes

This commit is contained in:
Neil Booth 2015-12-23 18:42:01 +09:00
parent 9484b6371f
commit 6f4d4b9a1e
3 changed files with 11 additions and 13 deletions

View File

@ -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):

View File

@ -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)

View File

@ -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))