electrum

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

commit 9161d3a5a1418ca984c72858a3063fa7cc96f253
parent 6702c335e879e62e08cd3757ad5acca9bff4f6f4
Author: ghost43 <somber.night@protonmail.com>
Date:   Fri, 22 Mar 2019 19:03:07 +0100

Merge pull request #5162 from kpstar/master

android all currencies with history checkbox
Diffstat:
Melectrum/exchange_rate.py | 4++--
Melectrum/gui/kivy/uix/dialogs/fx_dialog.py | 40++++++++++++++++++++++++++++++++--------
2 files changed, 34 insertions(+), 10 deletions(-)

diff --git 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 @@ -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(''' @@ -27,7 +27,20 @@ Builder.load_string(''' on_text: popup.on_currency(self.text) Widget: - size_hint: 1, 0.1 + size_hint: 1, 0.05 + + BoxLayout: + orientation: 'horizontal' + size_hint: 1, 0.2 + Label: + text: _('History rates') + CheckBox: + id:hist + active: popup.has_history_rates + on_active: popup.on_checkbox_history(self.active) + + Widget: + size_hint: 1, 0.05 BoxLayout: orientation: 'horizontal' @@ -41,7 +54,7 @@ Builder.load_string(''' on_text: popup.on_exchange(self.text) Widget: - size_hint: 1, 0.2 + size_hint: 1, 0.1 BoxLayout: orientation: 'horizontal' @@ -72,17 +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(True) + 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(), True)) 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 '' @@ -94,11 +112,17 @@ class FxDialog(Factory.Popup): self.fx.set_exchange(text) def add_currencies(self): - currencies = [_('None')] + self.fx.get_currencies(True) + 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.has_history_rates = checked + self.add_currencies() + self.on_currency(self.ids.ccy.text) + def on_currency(self, ccy): b = (ccy != _('None')) self.fx.set_enabled(b)