Browse Source

show popup if qr scanner not enabled

283
ThomasV 11 years ago
parent
commit
e2d03f1cc9
  1. 5
      gui/qt/paytoedit.py
  2. 11
      gui/qt/qrtextedit.py
  3. 6
      lib/plugins.py

5
gui/qt/paytoedit.py

@ -45,10 +45,7 @@ class PayToEdit(QRTextEdit):
self.textChanged.connect(self.check_text) self.textChanged.connect(self.check_text)
self.outputs = [] self.outputs = []
self.is_pr = False self.is_pr = False
self.scan_f = self.win.pay_from_URI
def qr_input(self):
from electrum.plugins import run_hook
run_hook('scan_qr_hook', lambda x: self.win.pay_from_URI(x))
def lock_amount(self): def lock_amount(self):
self.amount_edit.setFrozen(True) self.amount_edit.setFrozen(True)

11
gui/qt/qrtextedit.py

@ -11,11 +11,8 @@ class QRTextEdit(QTextEdit):
self.button.setStyleSheet("QToolButton { border: none; padding: 0px; }") self.button.setStyleSheet("QToolButton { border: none; padding: 0px; }")
self.button.setVisible(True) self.button.setVisible(True)
self.button.clicked.connect(lambda: self.qr_show() if self.isReadOnly() else self.qr_input()) self.button.clicked.connect(lambda: self.qr_show() if self.isReadOnly() else self.qr_input())
#frameWidth = self.style().pixelMetric(QStyle.PM_DefaultFrameWidth) self.scan_f = self.setText
#self.setStyleSheet(QString("QLineEdit { padding-right: %1px; } ").arg(self.button.sizeHint().width() + frameWidth + 1))
#msz = self.minimumSizeHint()
#self.setMinimumSize(max(msz.width(), self.button.sizeHint().height() + frameWidth * 2 + 2),
# max(msz.height(), self.button.sizeHint().height() + frameWidth * 2 + 2))
def resizeEvent(self, e): def resizeEvent(self, e):
o = QTextEdit.resizeEvent(self, e) o = QTextEdit.resizeEvent(self, e)
@ -39,5 +36,5 @@ class QRTextEdit(QTextEdit):
def qr_input(self): def qr_input(self):
from electrum.plugins import run_hook from electrum.plugins import run_hook
run_hook('scan_qr_hook', self.setText) if not run_hook('scan_qr_hook', self.scan_f):
QMessageBox.warning(self, _('Error'), _('QR Scanner not enabled'), _('OK'))

6
lib/plugins.py

@ -34,6 +34,8 @@ def run_hook(name, *args):
global plugins global plugins
found = 0
for p in plugins: for p in plugins:
if not p.is_enabled(): if not p.is_enabled():
@ -43,13 +45,15 @@ def run_hook(name, *args):
if not callable(f): if not callable(f):
continue continue
found += 1
try: try:
f(*args) f(*args)
except Exception: except Exception:
print_error("Plugin error") print_error("Plugin error")
traceback.print_exc(file=sys.stdout) traceback.print_exc(file=sys.stdout)
return return found

Loading…
Cancel
Save