fix get_pubkeys call
[electrum-nvc.git] / plugins / qrscanner.py
index 0da8bfd..0ff1fe9 100644 (file)
@@ -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,22 +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)
-        b = QPushButton(_("Scan QR code"))
-        b.clicked.connect(lambda: self.win.pay_from_URI(self.scan_qr()))
-        self.win.send_grid.addWidget(b, 1, 5)
-        self.win.send_grid.setColumnStretch(5, 0)
-        self.win.send_grid.setColumnStretch(6, 1)
-
-    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(self):
+    def is_enabled(self):
+        return True
+
+    def scan_qr_hook(self):
         proc = zbar.Processor()
         try:
             proc.init(video_device=self.video_device())
@@ -81,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, 'Unsigned 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")
@@ -140,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)