URI: 
       tbetter waiting dialog, with Qt signals - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit c5c1ed11f0a589b1cd3703c2cd12e994d14ac81a
   DIR parent 93ead1a90e07344aeae6f52dffe866344e94a470
  HTML Author: ThomasV <thomasv@gitorious>
       Date:   Fri, 28 Mar 2014 17:05:34 +0100
       
       better waiting dialog, with Qt signals
       
       Diffstat:
         M gui/qt/main_window.py               |      51 ++++++++++++++++++++++++++-----
         M gui/qt/util.py                      |      23 +----------------------
       
       2 files changed, 45 insertions(+), 29 deletions(-)
       ---
   DIR diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py
       t@@ -856,16 +856,53 @@ class ElectrumWindow(QMainWindow):
                self.send_tx(to_address, amount, fee, label)
        
        
       +    def waiting_dialog(self, message):
       +        d = QDialog(self)
       +        d.setWindowTitle('Please wait')
       +        l = QLabel(message)
       +        vbox = QVBoxLayout(d)
       +        vbox.addWidget(l)
       +        d.show()
       +        return d
       +
       +
            @protected
            def send_tx(self, to_address, amount, fee, label, password):
       +
       +        # first, create an unsigned tx 
       +        domain = self.get_payment_sources()
       +        outputs = [(to_address, amount)]
                try:
       -            tx = self.wallet.mktx( [(to_address, amount)], password, fee,
       -                    domain=self.get_payment_sources())
       +            tx = self.wallet.make_unsigned_transaction(outputs, fee, None, domain)
                except Exception as e:
                    traceback.print_exc(file=sys.stdout)
                    self.show_message(str(e))
                    return
        
       +        # call hook to see if plugin needs gui interaction
       +        run_hook('send_tx', tx)
       +
       +        def sign_thread():
       +            time.sleep(0.1)
       +            keypairs = {}
       +            self.wallet.add_keypairs_from_wallet(tx, keypairs, password)
       +            self.wallet.sign_transaction(tx, keypairs, password)
       +            self.signed_tx = tx
       +            self.emit(SIGNAL('send_tx2'))
       +
       +        # sign the tx
       +        dialog = self.waiting_dialog('Signing..')
       +        self.connect(self, QtCore.SIGNAL('send_tx2'), lambda: self.send_tx2(self.signed_tx, fee, label, dialog, password))
       +        threading.Thread(target=sign_thread).start()
       +
       +        # add recipient to addressbook
       +        if to_address not in self.wallet.addressbook and not self.wallet.is_mine(to_address):
       +            self.wallet.addressbook.append(to_address)
       +
       +
       +    def send_tx2(self, tx, fee, label, dialog, password):
       +        dialog.accept()
       +        
                if tx.requires_fee(self.wallet.verifier) and fee < MIN_RELAY_TX_FEE:
                    QMessageBox.warning(self, _('Error'), _("This transaction requires a higher fee, or it will not be propagated by the network."), _('OK'))
                    return
       t@@ -874,8 +911,12 @@ class ElectrumWindow(QMainWindow):
                    self.wallet.set_label(tx.hash(), label)
        
                if tx.is_complete:
       +
       +            d = self.waiting_dialog('Broadcasting...')
                    h = self.wallet.send_tx(tx)
       -            waiting_dialog(lambda: False if self.wallet.tx_event.isSet() else _("Please wait..."))
       +            self.wallet.tx_event.wait()
       +            d.accept()
       +            
                    status, msg = self.wallet.receive_tx( h, tx )
                    if status:
                        QMessageBox.information(self, '', _('Payment sent.')+'\n'+msg, _('OK'))
       t@@ -887,10 +928,6 @@ class ElectrumWindow(QMainWindow):
        
                    self.show_transaction(tx)
        
       -        # add recipient to addressbook
       -        if to_address not in self.wallet.addressbook and not self.wallet.is_mine(to_address):
       -            self.wallet.addressbook.append(to_address)
       -
        
        
        
   DIR diff --git a/gui/qt/util.py b/gui/qt/util.py
       t@@ -23,28 +23,7 @@ class EnterButton(QPushButton):
                    apply(self.func,())
        
        
       -def waiting_dialog(f, w=None):
       -
       -    s = Timer()
       -    s.start()
       -    if not w:
       -        w = QDialog()
       -        w.resize(200, 70)
       -        w.setWindowTitle('Electrum')
       -    else:
       -        if w.layout(): QWidget().setLayout(w.layout())
       -
       -    l = QLabel('')
       -    vbox = QVBoxLayout(w)
       -    vbox.addWidget(l)
       -    w.show()
       -    def ff():
       -        s = f()
       -        if s: l.setText(s)
       -        else: w.accept()
       -    w.connect(s, SIGNAL('timersignal'), ff)
       -    w.exec_()
       -    #w.destroy()
       +
        
        
        class HelpButton(QPushButton):