Removed unnecessary code in qrcode plugin
This commit is contained in:
parent
4b995e7996
commit
77e779638c
|
@ -3,12 +3,7 @@
|
||||||
from PyQt4 import QtGui, QtCore
|
from PyQt4 import QtGui, QtCore
|
||||||
import qrcode
|
import qrcode
|
||||||
|
|
||||||
from pybitmessage.tr import translateText
|
from pybitmessage.tr import _translate
|
||||||
|
|
||||||
try:
|
|
||||||
_fromUtf8 = QtCore.QString.fromUtf8
|
|
||||||
except AttributeError:
|
|
||||||
_fromUtf8 = lambda s: s
|
|
||||||
|
|
||||||
|
|
||||||
# http://stackoverflow.com/questions/20452486
|
# http://stackoverflow.com/questions/20452486
|
||||||
|
@ -37,65 +32,51 @@ class Image(qrcode.image.base.BaseImage):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Ui_qrcodeDialog(object):
|
class QRCodeDialog(QtGui.QDialog):
|
||||||
def setupUi(self, qrcodeDialog):
|
|
||||||
qrcodeDialog.setObjectName(_fromUtf8("qrcodeDialog"))
|
def __init__(self, parent):
|
||||||
self.image = QtGui.QLabel(qrcodeDialog)
|
super(QRCodeDialog, self).__init__(parent)
|
||||||
self.label = QtGui.QLabel(qrcodeDialog)
|
self.image = QtGui.QLabel(self)
|
||||||
|
self.label = QtGui.QLabel(self)
|
||||||
font = QtGui.QFont()
|
font = QtGui.QFont()
|
||||||
font.setBold(True)
|
font.setBold(True)
|
||||||
font.setWeight(75)
|
font.setWeight(75)
|
||||||
self.label.setFont(font)
|
self.label.setFont(font)
|
||||||
self.label.setAlignment(
|
self.label.setAlignment(
|
||||||
QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter)
|
QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter)
|
||||||
self.buttonBox = QtGui.QDialogButtonBox(qrcodeDialog)
|
buttonBox = QtGui.QDialogButtonBox(self)
|
||||||
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
|
buttonBox.setOrientation(QtCore.Qt.Horizontal)
|
||||||
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
|
buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
|
||||||
layout = QtGui.QVBoxLayout(qrcodeDialog)
|
buttonBox.accepted.connect(self.accept)
|
||||||
|
layout = QtGui.QVBoxLayout(self)
|
||||||
layout.addWidget(self.image)
|
layout.addWidget(self.image)
|
||||||
layout.addWidget(self.label)
|
layout.addWidget(self.label)
|
||||||
layout.addWidget(self.buttonBox)
|
layout.addWidget(buttonBox)
|
||||||
|
self.retranslateUi()
|
||||||
|
|
||||||
self.retranslateUi(qrcodeDialog)
|
def retranslateUi(self):
|
||||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(
|
self.setWindowTitle(_translate("QRCodeDialog", "QR-code"))
|
||||||
_fromUtf8("accepted()")), qrcodeDialog.accept)
|
|
||||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(
|
|
||||||
_fromUtf8("rejected()")), qrcodeDialog.reject)
|
|
||||||
QtCore.QMetaObject.connectSlotsByName(qrcodeDialog)
|
|
||||||
|
|
||||||
def retranslateUi(self, qrcodeDialog):
|
|
||||||
qrcodeDialog.setWindowTitle(QtGui.QApplication.translate(
|
|
||||||
"qrcodeDialog", "QR-code",
|
|
||||||
None, QtGui.QApplication.UnicodeUTF8
|
|
||||||
))
|
|
||||||
|
|
||||||
def render(self, text):
|
def render(self, text):
|
||||||
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())
|
||||||
|
self.setFixedSize(QtGui.QWidget.sizeHint(self))
|
||||||
|
|
||||||
class qrcodeDialog(QtGui.QDialog):
|
|
||||||
|
|
||||||
def __init__(self, parent):
|
|
||||||
QtGui.QWidget.__init__(self, parent)
|
|
||||||
self.ui = Ui_qrcodeDialog()
|
|
||||||
self.ui.setupUi(self)
|
|
||||||
self.parent = parent
|
|
||||||
QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
|
|
||||||
|
|
||||||
|
|
||||||
def connect_plugin(form):
|
def connect_plugin(form):
|
||||||
def on_action_ShowQR():
|
def on_action_ShowQR():
|
||||||
form.qrcodeDialogInstance = qrcodeDialog(form)
|
try:
|
||||||
form.qrcodeDialogInstance.ui.render(
|
dialog = form.qrcode_dialog
|
||||||
str(form.getCurrentAccount())
|
except AttributeError:
|
||||||
)
|
form.qrcode_dialog = dialog = QRCodeDialog(form)
|
||||||
form.qrcodeDialogInstance.exec_()
|
dialog.render(str(form.getCurrentAccount()))
|
||||||
|
dialog.exec_()
|
||||||
|
|
||||||
|
# return
|
||||||
form.actionShowQRCode = \
|
form.actionShowQRCode = \
|
||||||
form.ui.addressContextMenuToolbarYourIdentities.addAction(
|
form.ui.addressContextMenuToolbarYourIdentities.addAction(
|
||||||
translateText("MainWindow", "Show QR-code"),
|
_translate("MainWindow", "Show QR-code"),
|
||||||
on_action_ShowQR
|
on_action_ShowQR
|
||||||
)
|
)
|
||||||
form.popMenuYourIdentities.addAction(form.actionShowQRCode)
|
form.popMenuYourIdentities.addAction(form.actionShowQRCode)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user