Added docstrings. Removed unused method Image.save().
This commit is contained in:
parent
0ddc56e83a
commit
0ef0e6b020
|
@ -1,4 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
A menu plugin showing QR-Code for bitmessage address in modal dialog.
|
||||||
|
"""
|
||||||
|
|
||||||
from PyQt4 import QtGui, QtCore
|
from PyQt4 import QtGui, QtCore
|
||||||
import qrcode
|
import qrcode
|
||||||
|
@ -8,6 +11,7 @@ from pybitmessage.tr import _translate
|
||||||
|
|
||||||
# http://stackoverflow.com/questions/20452486
|
# http://stackoverflow.com/questions/20452486
|
||||||
class Image(qrcode.image.base.BaseImage):
|
class Image(qrcode.image.base.BaseImage):
|
||||||
|
"""Image output class for qrcode using QPainter"""
|
||||||
def __init__(self, border, width, box_size):
|
def __init__(self, border, width, box_size):
|
||||||
self.border = border
|
self.border = border
|
||||||
self.width = width
|
self.width = width
|
||||||
|
@ -18,9 +22,11 @@ class Image(qrcode.image.base.BaseImage):
|
||||||
self._image.fill(QtCore.Qt.white)
|
self._image.fill(QtCore.Qt.white)
|
||||||
|
|
||||||
def pixmap(self):
|
def pixmap(self):
|
||||||
|
"""Get image pixmap"""
|
||||||
return QtGui.QPixmap.fromImage(self._image)
|
return QtGui.QPixmap.fromImage(self._image)
|
||||||
|
|
||||||
def drawrect(self, row, col):
|
def drawrect(self, row, col):
|
||||||
|
"""Draw a single rectangle - implementation"""
|
||||||
painter = QtGui.QPainter(self._image)
|
painter = QtGui.QPainter(self._image)
|
||||||
painter.fillRect(
|
painter.fillRect(
|
||||||
(col + self.border) * self.box_size,
|
(col + self.border) * self.box_size,
|
||||||
|
@ -28,12 +34,9 @@ class Image(qrcode.image.base.BaseImage):
|
||||||
self.box_size, self.box_size,
|
self.box_size, self.box_size,
|
||||||
QtCore.Qt.black)
|
QtCore.Qt.black)
|
||||||
|
|
||||||
def save(self, stream, kind=None):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class QRCodeDialog(QtGui.QDialog):
|
class QRCodeDialog(QtGui.QDialog):
|
||||||
|
"""The dialog"""
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
super(QRCodeDialog, self).__init__(parent)
|
super(QRCodeDialog, self).__init__(parent)
|
||||||
self.image = QtGui.QLabel(self)
|
self.image = QtGui.QLabel(self)
|
||||||
|
@ -55,9 +58,11 @@ class QRCodeDialog(QtGui.QDialog):
|
||||||
self.retranslateUi()
|
self.retranslateUi()
|
||||||
|
|
||||||
def retranslateUi(self):
|
def retranslateUi(self):
|
||||||
|
"""A conventional Qt Designer method for dynamic l10n"""
|
||||||
self.setWindowTitle(_translate("QRCodeDialog", "QR-code"))
|
self.setWindowTitle(_translate("QRCodeDialog", "QR-code"))
|
||||||
|
|
||||||
def render(self, text):
|
def render(self, text):
|
||||||
|
"""Draw QR-code and address in labels"""
|
||||||
self.label.setText(text)
|
self.label.setText(text)
|
||||||
self.image.setPixmap(
|
self.image.setPixmap(
|
||||||
qrcode.make(text, image_factory=Image).pixmap())
|
qrcode.make(text, image_factory=Image).pixmap())
|
||||||
|
@ -65,7 +70,9 @@ class QRCodeDialog(QtGui.QDialog):
|
||||||
|
|
||||||
|
|
||||||
def connect_plugin(form):
|
def connect_plugin(form):
|
||||||
|
"""Plugin entry point"""
|
||||||
def on_action_ShowQR():
|
def on_action_ShowQR():
|
||||||
|
"""A slot for popup menu action"""
|
||||||
try:
|
try:
|
||||||
dialog = form.qrcode_dialog
|
dialog = form.qrcode_dialog
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
|
Reference in New Issue
Block a user