From 6311aa24a89f66120bab3d5749afb4585239db52 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Fri, 22 Mar 2019 18:52:57 +0100 Subject: [PATCH] follow-up prev --- electrum/exchange_rate.py | 4 ++-- electrum/gui/kivy/uix/dialogs/fx_dialog.py | 22 ++++++++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/electrum/exchange_rate.py b/electrum/exchange_rate.py index e05f15377..228d020ed 100644 --- a/electrum/exchange_rate.py +++ b/electrum/exchange_rate.py @@ -513,8 +513,8 @@ class FxThread(ThreadJob): self.config.set_key('use_exchange_rate', bool(b)) self.trigger_update() - def get_history_config(self): - return bool(self.config.get('history_rates')) + def get_history_config(self, *, default=False): + return bool(self.config.get('history_rates', default)) def set_history_config(self, b): self.config.set_key('history_rates', bool(b)) diff --git a/electrum/gui/kivy/uix/dialogs/fx_dialog.py b/electrum/gui/kivy/uix/dialogs/fx_dialog.py index 1c4873d5c..502a60dff 100644 --- a/electrum/gui/kivy/uix/dialogs/fx_dialog.py +++ b/electrum/gui/kivy/uix/dialogs/fx_dialog.py @@ -1,6 +1,6 @@ from kivy.app import App from kivy.factory import Factory -from kivy.properties import ObjectProperty +from kivy.properties import ObjectProperty, BooleanProperty from kivy.lang import Builder Builder.load_string(''' @@ -36,6 +36,7 @@ Builder.load_string(''' text: _('History rates') CheckBox: id:hist + active: popup.has_history_rates on_active: popup.on_checkbox_history(self.active) Widget: @@ -84,18 +85,22 @@ from functools import partial class FxDialog(Factory.Popup): def __init__(self, app, plugins, config, callback): - Factory.Popup.__init__(self) self.app = app self.config = config self.callback = callback self.fx = self.app.fx - self.fx.set_history_config(False) - self.ids.hist.active = False + self.has_history_rates = self.fx.get_history_config(default=True) + + Factory.Popup.__init__(self) self.add_currencies() def add_exchanges(self): - exchanges = sorted(self.fx.get_exchanges_by_ccy(self.fx.get_currency(), self.ids.hist.active)) if self.fx.is_enabled() else [] - mx = self.fx.exchange.name() if self.fx.is_enabled() else '' + if self.fx.is_enabled(): + exchanges = sorted(self.fx.get_exchanges_by_ccy(self.fx.get_currency(), self.has_history_rates)) + mx = self.fx.exchange.name() + else: + exchanges = [] + mx = '' ex = self.ids.exchanges ex.values = exchanges ex.text = (mx if mx in exchanges else exchanges[0]) if self.fx.is_enabled() else '' @@ -107,15 +112,16 @@ class FxDialog(Factory.Popup): self.fx.set_exchange(text) def add_currencies(self): - currencies = [_('None')] + self.fx.get_currencies(self.ids.hist.active) + currencies = [_('None')] + self.fx.get_currencies(self.has_history_rates) my_ccy = self.fx.get_currency() if self.fx.is_enabled() else _('None') self.ids.ccy.values = currencies self.ids.ccy.text = my_ccy def on_checkbox_history(self, checked): self.fx.set_history_config(checked) - self.ids.hist.active = checked + self.has_history_rates = checked self.add_currencies() + self.on_currency(self.ids.ccy.text) def on_currency(self, ccy): b = (ccy != _('None'))