commit 267466b22d02ca178b0fd7cb84c7da2fd021729c
parent 882ee0ded4e030bc551cb9479a4449b5c73ac49c
Author: thomasv <thomasv@gitorious>
Date: Thu, 29 Nov 2012 16:14:07 +0100
use timer signal to render qr code
Diffstat:
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/lib/gui_qt.py b/lib/gui_qt.py
@@ -137,19 +137,23 @@ class StatusBarButton(QPushButton):
class QRCodeWidget(QWidget):
- def __init__(self, addr):
- super(QRCodeWidget, self).__init__()
+ def __init__(self):
+ QWidget.__init__(self)
self.setMinimumSize(210, 210)
- self.set_addr(addr)
+ self.addr = None
+ self.qr = None
def set_addr(self, addr):
- self.addr = addr
- self.qr = pyqrnative.QRCode(4, pyqrnative.QRErrorCorrectLevel.L)
- self.qr.addData(self.addr)
- self.qr.make()
-
+ if self.addr != addr:
+ self.addr = addr
+ self.qr = None
+
def paintEvent(self, e):
if not self.addr: return
+ if not self.qr:
+ self.qr = pyqrnative.QRCode(4, pyqrnative.QRErrorCorrectLevel.L)
+ self.qr.addData(self.addr)
+ self.qr.make()
qp = QtGui.QPainter()
qp.begin(self)
@@ -184,7 +188,7 @@ class QR_Window(QWidget):
main_box = QHBoxLayout()
- self.qrw = QRCodeWidget('')
+ self.qrw = QRCodeWidget()
main_box.addWidget(self.qrw)
vbox = QVBoxLayout()
@@ -232,7 +236,6 @@ class QR_Window(QWidget):
msg += '?label=%s'%(self.label)
self.qrw.set_addr( msg )
- self.qrw.update()
@@ -329,10 +332,13 @@ class ElectrumWindow(QMainWindow):
def connect_slots(self, sender):
if self.wallet.seed:
- self.connect(sender, QtCore.SIGNAL('timersignal'), self.check_recipient)
+ self.connect(sender, QtCore.SIGNAL('timersignal'), self.timer_actions)
self.previous_payto_e=''
- def check_recipient(self):
+ def timer_actions(self):
+ if self.qr_window:
+ self.qr_window.qrw.update()
+
if self.payto_e.hasFocus():
return
r = unicode( self.payto_e.text() )