Browse Source

use get_config instead of passing window to ScanQRTextEdit

283
ThomasV 10 years ago
parent
commit
1cb6c08a13
  1. 5
      gui/qt/paytoedit.py
  2. 16
      gui/qt/qrtextedit.py
  3. 3
      gui/qt/seed_dialog.py
  4. 2
      gui/qt/util.py

5
gui/qt/paytoedit.py

@ -31,8 +31,9 @@ frozen_style = "QWidget { background-color:none; border:none;}"
normal_style = "QPlainTextEdit { }"
class PayToEdit(ScanQRTextEdit):
def __init__(self, win):
super(PayToEdit,self).__init__(win=win)
ScanQRTextEdit.__init__(self)
self.amount_edit = win.amount_e
self.document().contentsChanged.connect(self.update_size)
self.heightMin = 0
@ -42,7 +43,7 @@ class PayToEdit(ScanQRTextEdit):
self.outputs = []
self.errors = []
self.is_pr = False
self.scan_f = self.win.pay_from_URI
self.scan_f = win.pay_from_URI
self.update_size()
self.payto_address = None

16
gui/qt/qrtextedit.py

@ -7,8 +7,9 @@ from util import ButtonsTextEdit
class ShowQRTextEdit(ButtonsTextEdit):
def __init__(self, text=None):
super(ShowQRTextEdit, self).__init__(text)
ButtonsTextEdit__init__(self, text)
self.setReadOnly(1)
self.addButton(":icons/qrcode.png", self.qr_show, _("Show as QR code"))
run_hook('show_text_edit', self)
@ -28,13 +29,10 @@ class ShowQRTextEdit(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.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/qrcode.png", self.qr_input, _("Read QR code"))
run_hook('scan_text_edit', self)
@ -48,9 +46,9 @@ class ScanQRTextEdit(ButtonsTextEdit):
self.setText(data)
def qr_input(self):
from electrum import qrscanner
from electrum import qrscanner, get_config
try:
data = qrscanner.scan_qr(self.win.config)
data = qrscanner.scan_qr(get_config())
except BaseException, e:
QMessageBox.warning(self, _('Error'), _(e), _('OK'))
return ""

3
gui/qt/seed_dialog.py

@ -23,7 +23,6 @@ from electrum.i18n import _
from electrum import mnemonic
from util import *
from qrcodewidget import QRCodeWidget, QRDialog
from qrtextedit import ShowQRTextEdit, ScanQRTextEdit
class SeedDialog(QDialog):
@ -73,7 +72,7 @@ def enter_seed_box(msg, window, sid=None, text=None):
label = QLabel(msg)
label.setWordWrap(True)
if not text:
seed_e = ScanQRTextEdit(win=window)
seed_e = ScanQRTextEdit()
seed_e.setTabChangesFocus(True)
else:
seed_e = ShowQRTextEdit(text=text)

2
gui/qt/util.py

@ -200,7 +200,7 @@ def text_dialog(parent, title, label, ok_label, default=None):
l = QVBoxLayout()
dialog.setLayout(l)
l.addWidget(QLabel(label))
txt = ScanQRTextEdit(parent)
txt = ScanQRTextEdit()
if default:
txt.setText(default)
l.addWidget(txt)

Loading…
Cancel
Save