URI: 
       tHave fields update as exchange rates do - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit f5a8da43e93b97687660a94bb9f953bb3f45f15b
   DIR parent cd83b93e98693e63cc6d31ccab71f032ae38d461
  HTML Author: Neil Booth <kyuupichan@gmail.com>
       Date:   Mon, 31 Aug 2015 20:14:44 +0900
       
       Have fields update as exchange rates do
       
       Currently the exchange rates plugin shows the converted
       rate at the time of last user input.  If the fx rate
       changes the send and receive tabs do not update.
       
       This makes them update.  It also means that when enabling
       tthe plugin, if the user had input a BTC amount in the send
       or receive, the other fields will refresh.  This didn't
       used to happen - they stayed blank.
       
       Diffstat:
         M plugins/exchange_rate.py            |      10 ++++++++++
       
       1 file changed, 10 insertions(+), 0 deletions(-)
       ---
   DIR diff --git a/plugins/exchange_rate.py b/plugins/exchange_rate.py
       t@@ -95,6 +95,7 @@ class Exchanger(threading.Thread):
                with self.lock:
                    self.quote_currencies = rates
                    self.parent.set_currencies(rates)
       +        self.parent.refresh_fields()
        
            def run(self):
                self.is_running = True
       t@@ -190,6 +191,7 @@ class Plugin(BasePlugin):
                self.exchanger.start()
                self.win = None
                self.resp_hist = {}
       +        self.fields = {}
        
            @hook
            def init_qt(self, gui):
       t@@ -496,6 +498,11 @@ class Plugin(BasePlugin):
            def fiat_unit(self):
                return self.config.get("currency", "EUR")
        
       +    def refresh_fields(self):
       +        '''Update the display at the new rate'''
       +        for field in self.fields.values():
       +            field.textEdited.emit(field.text())
       +
            def add_send_edit(self):
                self.send_fiat_e = AmountEdit(self.fiat_unit)
                btc_e = self.win.amount_e
       t@@ -513,6 +520,7 @@ class Plugin(BasePlugin):
            def connect_fields(self, btc_e, fiat_e, fee_e):
                def fiat_changed():
                    fiat_e.setStyleSheet(BLACK_FG)
       +            self.fields[(fiat_e, btc_e)] = fiat_e
                    try:
                        fiat_amount = Decimal(str(fiat_e.text()))
                    except:
       t@@ -528,6 +536,7 @@ class Plugin(BasePlugin):
                fiat_e.textEdited.connect(fiat_changed)
                def btc_changed():
                    btc_e.setStyleSheet(BLACK_FG)
       +            self.fields[(fiat_e, btc_e)] = btc_e
                    if self.exchanger is None:
                        return
                    btc_amount = btc_e.get_amount()
       t@@ -541,6 +550,7 @@ class Plugin(BasePlugin):
                        fiat_e.setCursorPosition(pos)
                        fiat_e.setStyleSheet(BLUE_FG)
                btc_e.textEdited.connect(btc_changed)
       +        self.fields[(fiat_e, btc_e)] = btc_e
        
            @hook
            def do_clear(self):