electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 5a03caf0511503fd03d51cb87c2db65252777dfb
parent a1d55fac4ebb52a77e99a84913ae60193e180184
Author: ThomasV <thomasv@electrum.org>
Date:   Thu, 21 Jan 2016 16:29:46 +0100

kivy: update fiat amounts when changed

Diffstat:
Mgui/kivy/main_window.py | 31++++---------------------------
Mgui/kivy/uix/dialogs/settings.py | 7++++---
Mplugins/exchange_rate/exchange_rate.py | 9+++++++--
Mplugins/exchange_rate/qt.py | 8+++-----
4 files changed, 18 insertions(+), 37 deletions(-)

diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py @@ -78,6 +78,10 @@ class ElectrumWindow(App): status = StringProperty('') fiat_unit = StringProperty('') + def on_fiat_unit(self, a, b): + if self.history_screen: + self.history_screen.update() + def decimal_point(self): return base_units[self.base_unit] @@ -548,36 +552,9 @@ class ElectrumWindow(App): #Logger.info('orientation: {}'.format(self._orientation)) #Logger.info('ui_mode: {}'.format(self._ui_mode)) - def save_new_contact(self, address, label): - address = unicode(address) - label = unicode(label) - global is_valid - if not is_valid: - from electrum.bitcoin import is_valid - - if is_valid(address): - if label: - self.set_label(address, text=label) - self.wallet.add_contact(address) - self.update_contacts_tab() - self.update_history_tab() - else: - self.show_error(_('Invalid Address')) - - def set_send(self, address, amount, label, message): self.send_payment(address, amount=amount, label=label, message=message) - - def set_frozen(self, entry, frozen): - if frozen: - entry.disabled = True - Factory.Animation(opacity=0).start(content) - else: - entry.disabled = False - Factory.Animation(opacity=1).start(content) - - def show_error(self, error, width='200dp', pos=None, arrow_pos=None, exit=False, icon='atlas://gui/kivy/theming/light/error', duration=0, modal=False): diff --git a/gui/kivy/uix/dialogs/settings.py b/gui/kivy/uix/dialogs/settings.py @@ -131,7 +131,7 @@ class SettingsDialog(Factory.Popup): def cb(text): self.app._set_bu(text) item.bu = self.app.base_unit - d = ChoiceDialog(_('Denomination'), base_units, self.app.base_unit, cb) + d = ChoiceDialog(_('Denomination'), base_units.keys(), self.app.base_unit, cb) d.open() def fiat_currency_dialog(self, item): @@ -140,10 +140,11 @@ class SettingsDialog(Factory.Popup): if not p: return def cb(text): - self.config.set_key('currency', text, True) + p.set_currency(text) item.status = text + self.app.fiat_unit = text l = sorted(p.exchange.quotes.keys()) if p else [] - d = ChoiceDialog(_('Fiat Currency'), l, '', cb) + d = ChoiceDialog(_('Fiat Currency'), l, p.get_currency(), cb) d.open() def fiat_source(self): diff --git a/plugins/exchange_rate/exchange_rate.py b/plugins/exchange_rate/exchange_rate.py @@ -264,7 +264,7 @@ class FxPlugin(BasePlugin, ThreadJob): def __init__(self, parent, config, name): BasePlugin.__init__(self, parent, config, name) - self.ccy = self.config_ccy() + self.ccy = self.get_currency() self.history_used_spot = False self.ccy_combo = None self.hist_checkbox = None @@ -289,7 +289,7 @@ class FxPlugin(BasePlugin, ThreadJob): self.timeout = time.time() + 150 self.exchange.update(self.ccy) - def config_ccy(self): + def get_currency(self): '''Use when dynamic fetching is needed''' return self.config.get("currency", "EUR") @@ -302,6 +302,11 @@ class FxPlugin(BasePlugin, ThreadJob): def show_history(self): return self.config_history() and self.exchange.history_ccys() + def set_currency(self, ccy): + self.ccy = ccy + self.config.set_key('currency', ccy, True) + self.get_historical_rates() # Because self.ccy changes + def set_exchange(self, name): class_ = self.exchanges.get(name) or self.exchanges.values()[0] name = class_.__name__ diff --git a/plugins/exchange_rate/qt.py b/plugins/exchange_rate/qt.py @@ -85,10 +85,8 @@ class Plugin(FxPlugin): '''Called when the chosen currency changes''' ccy = str(self.ccy_combo.currentText()) if ccy and ccy != self.ccy: - self.ccy = ccy - self.config.set_key('currency', ccy, True) + self.set_currency(ccy) self.app.emit(SIGNAL('new_fx_quotes')) - self.get_historical_rates() # Because self.ccy changes self.hist_checkbox_update() def hist_checkbox_update(self): @@ -110,11 +108,11 @@ class Plugin(FxPlugin): @hook def on_new_window(self, window): # Additional send and receive edit boxes - send_e = AmountEdit(self.config_ccy) + send_e = AmountEdit(self.get_currency) window.send_grid.addWidget(send_e, 4, 2, Qt.AlignLeft) window.amount_e.frozen.connect( lambda: send_e.setFrozen(window.amount_e.isReadOnly())) - receive_e = AmountEdit(self.config_ccy) + receive_e = AmountEdit(self.get_currency) window.receive_grid.addWidget(receive_e, 2, 2, Qt.AlignLeft) window.fiat_send_e = send_e window.fiat_receive_e = receive_e