def qr_input(self): from vialectrum import qrscanner, get_config try: data = qrscanner.scan_barcode(get_config().get_video_device()) except BaseException as e: self.show_error(str(e)) data = '' if type(data) != str: data = '' self.setText(data) return data
def qr_input(self): from vialectrum import qrscanner, get_config try: data = qrscanner.scan_barcode(get_config().get_video_device()) except BaseException as e: self.show_error(str(e)) data = '' if not data: data = '' if self.allow_multi: new_text = self.text() + data + '\n' else: new_text = data self.setText(new_text) return data
def __init__(self, data, parent=None, title="", show_text=False): QDialog.__init__(self, parent) d = self d.setWindowTitle(title) vbox = QVBoxLayout() qrw = QRCodeWidget(data) vbox.addWidget(qrw, 1) if show_text: text = QTextEdit() text.setText(data) text.setReadOnly(True) vbox.addWidget(text) hbox = QHBoxLayout() hbox.addStretch(1) config = vialectrum.get_config() if config: filename = os.path.join(config.path, "qrcode.bmp") def print_qr(): bmp.save_qrcode(qrw.qr, filename) QMessageBox.information( None, _('Message'), _("QR code saved to file") + " " + filename, _('OK')) def copy_to_clipboard(): bmp.save_qrcode(qrw.qr, filename) self.parent().app.clipboard().setImage(QImage(filename)) QMessageBox.information(None, _('Message'), _("QR code saved to clipboard"), _('OK')) b = QPushButton(_("Copy")) hbox.addWidget(b) b.clicked.connect(copy_to_clipboard) b = QPushButton(_("Save")) hbox.addWidget(b) b.clicked.connect(print_qr) b = QPushButton(_("Close")) hbox.addWidget(b) b.clicked.connect(d.accept) b.setDefault(True) vbox.addLayout(hbox) d.setLayout(vbox)
def __init__(self, data, parent=None, title="", show_text=False): WindowModalDialog.__init__(self, parent, title) vbox = QVBoxLayout() qrw = QRCodeWidget(data) vbox.addWidget(qrw, 1) if show_text: text = QTextEdit() text.setText(data) text.setReadOnly(True) vbox.addWidget(text) hbox = QHBoxLayout() hbox.addStretch(1) config = vialectrum.get_config() if config: filename = os.path.join(config.path, "qrcode.png") def print_qr(): p = QPixmap.grabWindow(qrw.winId()) p.save(filename, 'png') self.show_message(_("QR code saved to file") + " " + filename) def copy_to_clipboard(): p = QPixmap.grabWindow(qrw.winId()) p.save(filename, 'png') QApplication.clipboard().setImage(QImage(filename)) self.show_message(_("QR code copied to clipboard")) b = QPushButton(_("Copy")) hbox.addWidget(b) b.clicked.connect(copy_to_clipboard) b = QPushButton(_("Save")) hbox.addWidget(b) b.clicked.connect(print_qr) b = QPushButton(_("Close")) hbox.addWidget(b) b.clicked.connect(self.accept) b.setDefault(True) vbox.addLayout(hbox) self.setLayout(vbox)
def __init__(self, data, parent=None, title = "", show_text=False): QDialog.__init__(self, parent) d = self d.setWindowTitle(title) vbox = QVBoxLayout() qrw = QRCodeWidget(data) vbox.addWidget(qrw, 1) if show_text: text = QTextEdit() text.setText(data) text.setReadOnly(True) vbox.addWidget(text) hbox = QHBoxLayout() hbox.addStretch(1) config = vialectrum.get_config() if config: filename = os.path.join(config.path, "qrcode.bmp") def print_qr(): bmp.save_qrcode(qrw.qr, filename) QMessageBox.information(None, _('Message'), _("QR code saved to file") + " " + filename, _('OK')) def copy_to_clipboard(): bmp.save_qrcode(qrw.qr, filename) self.parent().app.clipboard().setImage(QImage(filename)) QMessageBox.information(None, _('Message'), _("QR code saved to clipboard"), _('OK')) b = QPushButton(_("Copy")) hbox.addWidget(b) b.clicked.connect(copy_to_clipboard) b = QPushButton(_("Save")) hbox.addWidget(b) b.clicked.connect(print_qr) b = QPushButton(_("Close")) hbox.addWidget(b) b.clicked.connect(d.accept) b.setDefault(True) vbox.addLayout(hbox) d.setLayout(vbox)
def __init__(self, data, parent=None, title = "", show_text=False): WindowModalDialog.__init__(self, parent, title) vbox = QVBoxLayout() qrw = QRCodeWidget(data) vbox.addWidget(qrw, 1) if show_text: text = QTextEdit() text.setText(data) text.setReadOnly(True) vbox.addWidget(text) hbox = QHBoxLayout() hbox.addStretch(1) config = vialectrum.get_config() if config: filename = os.path.join(config.path, "qrcode.png") def print_qr(): p = qrw.grab() # FIXME also grabs neutral colored padding p.save(filename, 'png') self.show_message(_("QR code saved to file") + " " + filename) def copy_to_clipboard(): p = qrw.grab() QApplication.clipboard().setPixmap(p) self.show_message(_("QR code copied to clipboard")) b = QPushButton(_("Copy")) hbox.addWidget(b) b.clicked.connect(copy_to_clipboard) b = QPushButton(_("Save")) hbox.addWidget(b) b.clicked.connect(print_qr) b = QPushButton(_("Close")) hbox.addWidget(b) b.clicked.connect(self.accept) b.setDefault(True) vbox.addLayout(hbox) self.setLayout(vbox)