commit a7a60ceaebe23af9fbacf3eb54507636a654b1eb
parent 267466b22d02ca178b0fd7cb84c7da2fd021729c
Author: thomasv <thomasv@gitorious>
Date: Thu, 29 Nov 2012 16:23:36 +0100
separate update qr code and paint event
Diffstat:
1 file changed, 24 insertions(+), 8 deletions(-)
diff --git a/lib/gui_qt.py b/lib/gui_qt.py
@@ -147,21 +147,37 @@ class QRCodeWidget(QWidget):
if self.addr != addr:
self.addr = addr
self.qr = None
+ self.update()
- def paintEvent(self, e):
- if not self.addr: return
+ def update_qr(self):
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)
+ self.update()
+
+ def paintEvent(self, e):
+
+ if not self.addr:
+ return
+
+ black = QColor(0, 0, 0, 255)
+ white = QColor(255, 255, 255, 255)
boxsize = 6
+
+ if not self.qr:
+ qp = QtGui.QPainter()
+ qp.begin(self)
+ qp.setBrush(white)
+ qp.setPen(white)
+ qp.drawRect(0, 0, 198, 198)
+ qp.end()
+ return
+
size = self.qr.getModuleCount()*boxsize
k = self.qr.getModuleCount()
- black = QColor(0, 0, 0, 255)
- white = QColor(255, 255, 255, 255)
+ qp = QtGui.QPainter()
+ qp.begin(self)
for r in range(k):
for c in range(k):
if self.qr.isDark(r, c):
@@ -337,7 +353,7 @@ class ElectrumWindow(QMainWindow):
def timer_actions(self):
if self.qr_window:
- self.qr_window.qrw.update()
+ self.qr_window.qrw.update_qr()
if self.payto_e.hasFocus():
return