X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=plugins%2Fqrscanner.py;h=0ff1fe936c7c83959800a0e3594f3853b547000a;hb=81d1e67253c8ca581e821a6cd9e5ee1502fffd08;hp=8599e7cb37ffa141028155705a0d8eb07ea829a4;hpb=d2cad7bbbbfa1b6b175ec39de36a76453192137d;p=electrum-nvc.git diff --git a/plugins/qrscanner.py b/plugins/qrscanner.py index 8599e7c..0ff1fe9 100644 --- a/plugins/qrscanner.py +++ b/plugins/qrscanner.py @@ -35,6 +35,8 @@ class Plugin(BasePlugin): try: proc = zbar.Processor() proc.init(video_device=self.video_device()) + except zbar.UnsupportedError: + return False except zbar.SystemError: # Cannot open video device pass @@ -44,23 +46,14 @@ class Plugin(BasePlugin): def init(self): self.win = self.gui.main_window - self.win.raw_transaction_menu.addAction(_("&From QR code"), self.read_raw_qr) - - def init_transaction_dialog(self, dialog, buttons): - b = QPushButton(_("Show QR code")) - b.clicked.connect(lambda: self.show_raw_qr(dialog.tx)) - buttons.insertWidget(1,b) def is_available(self): return self._is_available - def scan_qr_hook(self, func): - data = self.scan_qr() - if type(data) != str: - return - func(data) + def is_enabled(self): + return True - def scan_qr(self): + def scan_qr_hook(self): proc = zbar.Processor() try: proc.init(video_device=self.video_device()) @@ -82,22 +75,6 @@ class Plugin(BasePlugin): continue return r.data - def show_raw_qr(self, tx): - try: - json_text = json.dumps(tx.as_dict()).replace(' ', '') - self.win.show_qrcode(json_text, 'Transaction') - except Exception as e: - self.win.show_message(str(e)) - - - def read_raw_qr(self): - qrcode = self.scan_qr() - if not qrcode: - return - tx = self.win.tx_from_text(qrcode) - if not tx: - return - self.win.show_transaction(tx) def video_device(self): device = self.config.get("video_device", "default") @@ -141,7 +118,7 @@ class Plugin(BasePlugin): if self.config.get("video_device") == "default": self.video_device_edit.setText("") else: - self.video_device_edit.setText(self.config.get("video_device")) + self.video_device_edit.setText(self.config.get("video_device",'')) else: custom_device_label.setVisible(False) self.video_device_edit.setVisible(False)