Modality and centring fixes for QR codes
This commit is contained in:
parent
9484b6371f
commit
6f4d4b9a1e
|
@ -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:
|
if not data:
|
||||||
return
|
return
|
||||||
d = QRDialog(data, self, title)
|
d = QRDialog(data, parent or self, title)
|
||||||
d.exec_()
|
d.exec_()
|
||||||
|
|
||||||
def show_public_keys(self, address):
|
def show_public_keys(self, address):
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
from PyQt4.QtGui import *
|
from PyQt4.QtGui import *
|
||||||
from PyQt4.QtCore import *
|
from PyQt4.QtCore import *
|
||||||
import PyQt4.QtCore as QtCore
|
|
||||||
import PyQt4.QtGui as QtGui
|
import PyQt4.QtGui as QtGui
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -9,6 +8,7 @@ import qrcode
|
||||||
import electrum
|
import electrum
|
||||||
from electrum import bmp
|
from electrum import bmp
|
||||||
from electrum.i18n import _
|
from electrum.i18n import _
|
||||||
|
from util import WindowModalDialog, MessageBoxMixin
|
||||||
|
|
||||||
|
|
||||||
class QRCodeWidget(QWidget):
|
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):
|
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()
|
vbox = QVBoxLayout()
|
||||||
qrw = QRCodeWidget(data)
|
qrw = QRCodeWidget(data)
|
||||||
vbox.addWidget(qrw, 1)
|
vbox.addWidget(qrw, 1)
|
||||||
|
@ -107,12 +105,12 @@ class QRDialog(QDialog):
|
||||||
|
|
||||||
def print_qr():
|
def print_qr():
|
||||||
bmp.save_qrcode(qrw.qr, filename)
|
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():
|
def copy_to_clipboard():
|
||||||
bmp.save_qrcode(qrw.qr, filename)
|
bmp.save_qrcode(qrw.qr, filename)
|
||||||
QApplication.clipboard().setImage(QImage(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"))
|
b = QPushButton(_("Copy"))
|
||||||
hbox.addWidget(b)
|
hbox.addWidget(b)
|
||||||
|
@ -124,8 +122,8 @@ class QRDialog(QDialog):
|
||||||
|
|
||||||
b = QPushButton(_("Close"))
|
b = QPushButton(_("Close"))
|
||||||
hbox.addWidget(b)
|
hbox.addWidget(b)
|
||||||
b.clicked.connect(d.accept)
|
b.clicked.connect(self.accept)
|
||||||
b.setDefault(True)
|
b.setDefault(True)
|
||||||
|
|
||||||
vbox.addLayout(hbox)
|
vbox.addLayout(hbox)
|
||||||
d.setLayout(vbox)
|
self.setLayout(vbox)
|
||||||
|
|
|
@ -62,7 +62,7 @@ class TxDialog(QDialog, MessageBoxMixin):
|
||||||
|
|
||||||
vbox.addWidget(QLabel(_("Transaction ID:")))
|
vbox.addWidget(QLabel(_("Transaction ID:")))
|
||||||
self.tx_hash_e = ButtonsLineEdit()
|
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.addButton(":icons/qrcode.png", qr_show, _("Show as QR code"))
|
||||||
self.tx_hash_e.setReadOnly(True)
|
self.tx_hash_e.setReadOnly(True)
|
||||||
vbox.addWidget(self.tx_hash_e)
|
vbox.addWidget(self.tx_hash_e)
|
||||||
|
@ -132,7 +132,7 @@ class TxDialog(QDialog, MessageBoxMixin):
|
||||||
text = self.tx.raw.decode('hex')
|
text = self.tx.raw.decode('hex')
|
||||||
text = base_encode(text, base=43)
|
text = base_encode(text, base=43)
|
||||||
try:
|
try:
|
||||||
self.parent.show_qrcode(text, 'Transaction')
|
self.parent.show_qrcode(text, 'Transaction', parent=self)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.show_message(str(e))
|
self.show_message(str(e))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue