use get_config instead of passing window to ScanQRTextEdit
This commit is contained in:
parent
f2c2f9d738
commit
1cb6c08a13
|
@ -31,8 +31,9 @@ frozen_style = "QWidget { background-color:none; border:none;}"
|
||||||
normal_style = "QPlainTextEdit { }"
|
normal_style = "QPlainTextEdit { }"
|
||||||
|
|
||||||
class PayToEdit(ScanQRTextEdit):
|
class PayToEdit(ScanQRTextEdit):
|
||||||
|
|
||||||
def __init__(self, win):
|
def __init__(self, win):
|
||||||
super(PayToEdit,self).__init__(win=win)
|
ScanQRTextEdit.__init__(self)
|
||||||
self.amount_edit = win.amount_e
|
self.amount_edit = win.amount_e
|
||||||
self.document().contentsChanged.connect(self.update_size)
|
self.document().contentsChanged.connect(self.update_size)
|
||||||
self.heightMin = 0
|
self.heightMin = 0
|
||||||
|
@ -42,7 +43,7 @@ class PayToEdit(ScanQRTextEdit):
|
||||||
self.outputs = []
|
self.outputs = []
|
||||||
self.errors = []
|
self.errors = []
|
||||||
self.is_pr = False
|
self.is_pr = False
|
||||||
self.scan_f = self.win.pay_from_URI
|
self.scan_f = win.pay_from_URI
|
||||||
self.update_size()
|
self.update_size()
|
||||||
self.payto_address = None
|
self.payto_address = None
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,9 @@ from util import ButtonsTextEdit
|
||||||
|
|
||||||
|
|
||||||
class ShowQRTextEdit(ButtonsTextEdit):
|
class ShowQRTextEdit(ButtonsTextEdit):
|
||||||
|
|
||||||
def __init__(self, text=None):
|
def __init__(self, text=None):
|
||||||
super(ShowQRTextEdit, self).__init__(text)
|
ButtonsTextEdit__init__(self, text)
|
||||||
self.setReadOnly(1)
|
self.setReadOnly(1)
|
||||||
self.addButton(":icons/qrcode.png", self.qr_show, _("Show as QR code"))
|
self.addButton(":icons/qrcode.png", self.qr_show, _("Show as QR code"))
|
||||||
run_hook('show_text_edit', self)
|
run_hook('show_text_edit', self)
|
||||||
|
@ -28,13 +29,10 @@ class ShowQRTextEdit(ButtonsTextEdit):
|
||||||
|
|
||||||
|
|
||||||
class ScanQRTextEdit(ButtonsTextEdit):
|
class ScanQRTextEdit(ButtonsTextEdit):
|
||||||
def __init__(self, win, text=""):
|
|
||||||
super(ScanQRTextEdit,self).__init__(text)
|
def __init__(self, text=""):
|
||||||
|
ButtonsTextEdit.__init__(self, text)
|
||||||
self.setReadOnly(0)
|
self.setReadOnly(0)
|
||||||
self.win = win
|
|
||||||
assert win, "You must pass a window with access to the config to ScanQRTextEdit constructor."
|
|
||||||
if win:
|
|
||||||
assert hasattr(win,"config"), "You must pass a window with access to the config to ScanQRTextEdit constructor."
|
|
||||||
self.addButton(":icons/file.png", self.file_input, _("Read file"))
|
self.addButton(":icons/file.png", self.file_input, _("Read file"))
|
||||||
self.addButton(":icons/qrcode.png", self.qr_input, _("Read QR code"))
|
self.addButton(":icons/qrcode.png", self.qr_input, _("Read QR code"))
|
||||||
run_hook('scan_text_edit', self)
|
run_hook('scan_text_edit', self)
|
||||||
|
@ -48,9 +46,9 @@ class ScanQRTextEdit(ButtonsTextEdit):
|
||||||
self.setText(data)
|
self.setText(data)
|
||||||
|
|
||||||
def qr_input(self):
|
def qr_input(self):
|
||||||
from electrum import qrscanner
|
from electrum import qrscanner, get_config
|
||||||
try:
|
try:
|
||||||
data = qrscanner.scan_qr(self.win.config)
|
data = qrscanner.scan_qr(get_config())
|
||||||
except BaseException, e:
|
except BaseException, e:
|
||||||
QMessageBox.warning(self, _('Error'), _(e), _('OK'))
|
QMessageBox.warning(self, _('Error'), _(e), _('OK'))
|
||||||
return ""
|
return ""
|
||||||
|
|
|
@ -23,7 +23,6 @@ from electrum.i18n import _
|
||||||
from electrum import mnemonic
|
from electrum import mnemonic
|
||||||
|
|
||||||
from util import *
|
from util import *
|
||||||
from qrcodewidget import QRCodeWidget, QRDialog
|
|
||||||
from qrtextedit import ShowQRTextEdit, ScanQRTextEdit
|
from qrtextedit import ShowQRTextEdit, ScanQRTextEdit
|
||||||
|
|
||||||
class SeedDialog(QDialog):
|
class SeedDialog(QDialog):
|
||||||
|
@ -73,7 +72,7 @@ def enter_seed_box(msg, window, sid=None, text=None):
|
||||||
label = QLabel(msg)
|
label = QLabel(msg)
|
||||||
label.setWordWrap(True)
|
label.setWordWrap(True)
|
||||||
if not text:
|
if not text:
|
||||||
seed_e = ScanQRTextEdit(win=window)
|
seed_e = ScanQRTextEdit()
|
||||||
seed_e.setTabChangesFocus(True)
|
seed_e.setTabChangesFocus(True)
|
||||||
else:
|
else:
|
||||||
seed_e = ShowQRTextEdit(text=text)
|
seed_e = ShowQRTextEdit(text=text)
|
||||||
|
|
|
@ -200,7 +200,7 @@ def text_dialog(parent, title, label, ok_label, default=None):
|
||||||
l = QVBoxLayout()
|
l = QVBoxLayout()
|
||||||
dialog.setLayout(l)
|
dialog.setLayout(l)
|
||||||
l.addWidget(QLabel(label))
|
l.addWidget(QLabel(label))
|
||||||
txt = ScanQRTextEdit(parent)
|
txt = ScanQRTextEdit()
|
||||||
if default:
|
if default:
|
||||||
txt.setText(default)
|
txt.setText(default)
|
||||||
l.addWidget(txt)
|
l.addWidget(txt)
|
||||||
|
|
Loading…
Reference in New Issue