kivy: update fiat amounts when changed
This commit is contained in:
@@ -78,6 +78,10 @@ class ElectrumWindow(App):
|
|||||||
status = StringProperty('')
|
status = StringProperty('')
|
||||||
fiat_unit = StringProperty('')
|
fiat_unit = StringProperty('')
|
||||||
|
|
||||||
|
def on_fiat_unit(self, a, b):
|
||||||
|
if self.history_screen:
|
||||||
|
self.history_screen.update()
|
||||||
|
|
||||||
def decimal_point(self):
|
def decimal_point(self):
|
||||||
return base_units[self.base_unit]
|
return base_units[self.base_unit]
|
||||||
|
|
||||||
@@ -548,36 +552,9 @@ class ElectrumWindow(App):
|
|||||||
#Logger.info('orientation: {}'.format(self._orientation))
|
#Logger.info('orientation: {}'.format(self._orientation))
|
||||||
#Logger.info('ui_mode: {}'.format(self._ui_mode))
|
#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):
|
def set_send(self, address, amount, label, message):
|
||||||
self.send_payment(address, amount=amount, label=label, message=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,
|
def show_error(self, error, width='200dp', pos=None, arrow_pos=None,
|
||||||
exit=False, icon='atlas://gui/kivy/theming/light/error', duration=0,
|
exit=False, icon='atlas://gui/kivy/theming/light/error', duration=0,
|
||||||
modal=False):
|
modal=False):
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ class SettingsDialog(Factory.Popup):
|
|||||||
def cb(text):
|
def cb(text):
|
||||||
self.app._set_bu(text)
|
self.app._set_bu(text)
|
||||||
item.bu = self.app.base_unit
|
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()
|
d.open()
|
||||||
|
|
||||||
def fiat_currency_dialog(self, item):
|
def fiat_currency_dialog(self, item):
|
||||||
@@ -140,10 +140,11 @@ class SettingsDialog(Factory.Popup):
|
|||||||
if not p:
|
if not p:
|
||||||
return
|
return
|
||||||
def cb(text):
|
def cb(text):
|
||||||
self.config.set_key('currency', text, True)
|
p.set_currency(text)
|
||||||
item.status = text
|
item.status = text
|
||||||
|
self.app.fiat_unit = text
|
||||||
l = sorted(p.exchange.quotes.keys()) if p else []
|
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()
|
d.open()
|
||||||
|
|
||||||
def fiat_source(self):
|
def fiat_source(self):
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ class FxPlugin(BasePlugin, ThreadJob):
|
|||||||
|
|
||||||
def __init__(self, parent, config, name):
|
def __init__(self, parent, config, name):
|
||||||
BasePlugin.__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.history_used_spot = False
|
||||||
self.ccy_combo = None
|
self.ccy_combo = None
|
||||||
self.hist_checkbox = None
|
self.hist_checkbox = None
|
||||||
@@ -289,7 +289,7 @@ class FxPlugin(BasePlugin, ThreadJob):
|
|||||||
self.timeout = time.time() + 150
|
self.timeout = time.time() + 150
|
||||||
self.exchange.update(self.ccy)
|
self.exchange.update(self.ccy)
|
||||||
|
|
||||||
def config_ccy(self):
|
def get_currency(self):
|
||||||
'''Use when dynamic fetching is needed'''
|
'''Use when dynamic fetching is needed'''
|
||||||
return self.config.get("currency", "EUR")
|
return self.config.get("currency", "EUR")
|
||||||
|
|
||||||
@@ -302,6 +302,11 @@ class FxPlugin(BasePlugin, ThreadJob):
|
|||||||
def show_history(self):
|
def show_history(self):
|
||||||
return self.config_history() and self.exchange.history_ccys()
|
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):
|
def set_exchange(self, name):
|
||||||
class_ = self.exchanges.get(name) or self.exchanges.values()[0]
|
class_ = self.exchanges.get(name) or self.exchanges.values()[0]
|
||||||
name = class_.__name__
|
name = class_.__name__
|
||||||
|
|||||||
@@ -85,10 +85,8 @@ class Plugin(FxPlugin):
|
|||||||
'''Called when the chosen currency changes'''
|
'''Called when the chosen currency changes'''
|
||||||
ccy = str(self.ccy_combo.currentText())
|
ccy = str(self.ccy_combo.currentText())
|
||||||
if ccy and ccy != self.ccy:
|
if ccy and ccy != self.ccy:
|
||||||
self.ccy = ccy
|
self.set_currency(ccy)
|
||||||
self.config.set_key('currency', ccy, True)
|
|
||||||
self.app.emit(SIGNAL('new_fx_quotes'))
|
self.app.emit(SIGNAL('new_fx_quotes'))
|
||||||
self.get_historical_rates() # Because self.ccy changes
|
|
||||||
self.hist_checkbox_update()
|
self.hist_checkbox_update()
|
||||||
|
|
||||||
def hist_checkbox_update(self):
|
def hist_checkbox_update(self):
|
||||||
@@ -110,11 +108,11 @@ class Plugin(FxPlugin):
|
|||||||
@hook
|
@hook
|
||||||
def on_new_window(self, window):
|
def on_new_window(self, window):
|
||||||
# Additional send and receive edit boxes
|
# 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.send_grid.addWidget(send_e, 4, 2, Qt.AlignLeft)
|
||||||
window.amount_e.frozen.connect(
|
window.amount_e.frozen.connect(
|
||||||
lambda: send_e.setFrozen(window.amount_e.isReadOnly()))
|
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.receive_grid.addWidget(receive_e, 2, 2, Qt.AlignLeft)
|
||||||
window.fiat_send_e = send_e
|
window.fiat_send_e = send_e
|
||||||
window.fiat_receive_e = receive_e
|
window.fiat_receive_e = receive_e
|
||||||
|
|||||||
Reference in New Issue
Block a user