Browse Source

follow-up prev

regtest_lnd
SomberNight 6 years ago
parent
commit
6311aa24a8
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 4
      electrum/exchange_rate.py
  2. 22
      electrum/gui/kivy/uix/dialogs/fx_dialog.py

4
electrum/exchange_rate.py

@ -513,8 +513,8 @@ class FxThread(ThreadJob):
self.config.set_key('use_exchange_rate', bool(b)) self.config.set_key('use_exchange_rate', bool(b))
self.trigger_update() self.trigger_update()
def get_history_config(self): def get_history_config(self, *, default=False):
return bool(self.config.get('history_rates')) return bool(self.config.get('history_rates', default))
def set_history_config(self, b): def set_history_config(self, b):
self.config.set_key('history_rates', bool(b)) self.config.set_key('history_rates', bool(b))

22
electrum/gui/kivy/uix/dialogs/fx_dialog.py

@ -1,6 +1,6 @@
from kivy.app import App from kivy.app import App
from kivy.factory import Factory from kivy.factory import Factory
from kivy.properties import ObjectProperty from kivy.properties import ObjectProperty, BooleanProperty
from kivy.lang import Builder from kivy.lang import Builder
Builder.load_string(''' Builder.load_string('''
@ -36,6 +36,7 @@ Builder.load_string('''
text: _('History rates') text: _('History rates')
CheckBox: CheckBox:
id:hist id:hist
active: popup.has_history_rates
on_active: popup.on_checkbox_history(self.active) on_active: popup.on_checkbox_history(self.active)
Widget: Widget:
@ -84,18 +85,22 @@ from functools import partial
class FxDialog(Factory.Popup): class FxDialog(Factory.Popup):
def __init__(self, app, plugins, config, callback): def __init__(self, app, plugins, config, callback):
Factory.Popup.__init__(self)
self.app = app self.app = app
self.config = config self.config = config
self.callback = callback self.callback = callback
self.fx = self.app.fx self.fx = self.app.fx
self.fx.set_history_config(False) self.has_history_rates = self.fx.get_history_config(default=True)
self.ids.hist.active = False
Factory.Popup.__init__(self)
self.add_currencies() self.add_currencies()
def add_exchanges(self): 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 [] if self.fx.is_enabled():
mx = self.fx.exchange.name() if self.fx.is_enabled() else '' 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 = self.ids.exchanges
ex.values = exchanges ex.values = exchanges
ex.text = (mx if mx in exchanges else exchanges[0]) if self.fx.is_enabled() else '' 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) self.fx.set_exchange(text)
def add_currencies(self): 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') my_ccy = self.fx.get_currency() if self.fx.is_enabled() else _('None')
self.ids.ccy.values = currencies self.ids.ccy.values = currencies
self.ids.ccy.text = my_ccy self.ids.ccy.text = my_ccy
def on_checkbox_history(self, checked): def on_checkbox_history(self, checked):
self.fx.set_history_config(checked) self.fx.set_history_config(checked)
self.ids.hist.active = checked self.has_history_rates = checked
self.add_currencies() self.add_currencies()
self.on_currency(self.ids.ccy.text)
def on_currency(self, ccy): def on_currency(self, ccy):
b = (ccy != _('None')) b = (ccy != _('None'))

Loading…
Cancel
Save