kivy: update fiat amounts when changed
This commit is contained in:
@@ -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__
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user