URI: 
       talways enable qr scanner plugin - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 81d1e67253c8ca581e821a6cd9e5ee1502fffd08
   DIR parent 4da85c00e313d3e087f52d3c7263e79553ef8147
  HTML Author: ThomasV <thomasv@gitorious>
       Date:   Sat, 12 Jul 2014 18:39:28 +0200
       
       always enable qr scanner plugin
       
       Diffstat:
         M gui/qt/main_window.py               |      16 ++++++++++++++++
         M gui/qt/qrtextedit.py                |       7 ++++---
         M plugins/qrscanner.py                |      27 +++------------------------
       
       3 files changed, 23 insertions(+), 27 deletions(-)
       ---
   DIR diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py
       t@@ -360,6 +360,7 @@ class ElectrumWindow(QMainWindow):
                raw_transaction_menu.addAction(_("&From file"), self.do_process_from_file)
                raw_transaction_menu.addAction(_("&From text"), self.do_process_from_text)
                raw_transaction_menu.addAction(_("&From the blockchain"), self.do_process_from_txid)
       +        raw_transaction_menu.addAction(_("&From QR code"), self.read_tx_from_qrcode)
                self.raw_transaction_menu = raw_transaction_menu
        
                help_menu = menubar.addMenu(_("&Help"))
       t@@ -2091,6 +2092,21 @@ class ElectrumWindow(QMainWindow):
                    QMessageBox.critical(None, _("Unable to parse transaction"), _("Electrum was unable to parse your transaction"))
        
        
       +    def read_tx_from_qrcode(self):
       +        data = run_hook('scan_qr_hook')
       +        if not data:
       +            return
       +        # transactions are binary, but qrcode seems to return utf8...
       +        z = data.decode('utf8')
       +        s = ''
       +        for b in z:
       +            s += chr(ord(b))
       +        data = s.encode('hex')
       +        tx = self.tx_from_text(data)
       +        if not tx:
       +            return
       +        self.show_transaction(tx)
       +
        
            def read_tx_from_file(self):
                fileName = self.getOpenFileName(_("Select your transaction file"), "*.txn")
   DIR diff --git a/gui/qt/qrtextedit.py b/gui/qt/qrtextedit.py
       t@@ -12,7 +12,6 @@ class QRTextEdit(QPlainTextEdit):
                self.button.setVisible(True)
                self.button.clicked.connect(lambda: self.qr_show() if self.isReadOnly() else self.qr_input())
                self.setText = self.setPlainText
       -        self.scan_f = self.setText
        
            def resizeEvent(self, e):
                o = QPlainTextEdit.resizeEvent(self, e)
       t@@ -36,5 +35,7 @@ class QRTextEdit(QPlainTextEdit):
        
            def qr_input(self):
                from electrum.plugins import run_hook
       -        if not run_hook('scan_qr_hook', self.scan_f):
       -            QMessageBox.warning(self, _('Error'), _('QR Scanner not enabled'), _('OK'))
       +        data = run_hook('scan_qr_hook')
       +        if type(data) != str:
       +            return
       +        self.setText(data)
   DIR diff --git a/plugins/qrscanner.py b/plugins/qrscanner.py
       t@@ -46,18 +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 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())
       t@@ -80,23 +76,6 @@ class Plugin(BasePlugin):
                        return r.data
                
        
       -    def read_raw_qr(self):
       -        qrcode = self.scan_qr()
       -        if not qrcode:
       -            return
       -        data = qrcode
       -
       -        # transactions are binary, but qrcode seems to return utf8...
       -        z = data.decode('utf8')
       -        s = ''
       -        for b in z:
       -            s += chr(ord(b))
       -        data = s.encode('hex')
       -        tx = self.win.tx_from_text(data)
       -        if not tx:
       -            return
       -        self.win.show_transaction(tx)
       -
            def video_device(self):
                device = self.config.get("video_device", "default")
                if device == 'default':