Browse Source

kivy: show synchronization status in the balance field

3.3.3.1
ThomasV 6 years ago
parent
commit
27caa683fe
  1. 2
      electrum/gui/kivy/main.kv
  2. 26
      electrum/gui/kivy/main_window.py
  3. 2
      electrum/gui/kivy/uix/ui_screens/status.kv

2
electrum/gui/kivy/main.kv

@ -435,7 +435,7 @@ BoxLayout:
size_hint: 1, 1 size_hint: 1, 1
bold: True bold: True
color: 0.7, 0.7, 0.7, 1 color: 0.7, 0.7, 0.7, 1
text: app.status text: app.wallet_name
font_size: '22dp' font_size: '22dp'
#minimum_width: '1dp' #minimum_width: '1dp'
on_release: app.popup_dialog('status') on_release: app.popup_dialog('status')

26
electrum/gui/kivy/main_window.py

@ -193,8 +193,8 @@ class ElectrumWindow(App):
self._trigger_update_status() self._trigger_update_status()
self._trigger_update_history() self._trigger_update_history()
wallet_name = StringProperty(_('No Wallet'))
base_unit = AliasProperty(_get_bu, _set_bu) base_unit = AliasProperty(_get_bu, _set_bu)
status = StringProperty('')
fiat_unit = StringProperty('') fiat_unit = StringProperty('')
def on_fiat_unit(self, a, b): def on_fiat_unit(self, a, b):
@ -308,9 +308,6 @@ class ElectrumWindow(App):
self._password_dialog = None self._password_dialog = None
self.fee_status = self.electrum_config.get_fee_status() self.fee_status = self.electrum_config.get_fee_status()
def wallet_name(self):
return os.path.basename(self.wallet.storage.path) if self.wallet else ' '
def on_pr(self, pr): def on_pr(self, pr):
if not self.wallet: if not self.wallet:
self.show_error(_('No wallet loaded.')) self.show_error(_('No wallet loaded.'))
@ -547,8 +544,6 @@ class ElectrumWindow(App):
else: else:
self.load_wallet(wallet) self.load_wallet(wallet)
else: else:
Logger.debug('Electrum: Wallet not found or action needed. Launching install wizard')
def launch_wizard(): def launch_wizard():
storage = WalletStorage(path, manual_upgrades=True) storage = WalletStorage(path, manual_upgrades=True)
wizard = Factory.InstallWizard(self.electrum_config, self.plugins, storage) wizard = Factory.InstallWizard(self.electrum_config, self.plugins, storage)
@ -559,7 +554,6 @@ class ElectrumWindow(App):
launch_wizard() launch_wizard()
else: else:
from .uix.dialogs.question import Question from .uix.dialogs.question import Question
def handle_answer(b: bool): def handle_answer(b: bool):
if b: if b:
launch_wizard() launch_wizard()
@ -705,6 +699,7 @@ class ElectrumWindow(App):
if self.wallet: if self.wallet:
self.stop_wallet() self.stop_wallet()
self.wallet = wallet self.wallet = wallet
self.wallet_name = wallet.basename()
self.update_wallet() self.update_wallet()
# Once GUI has been initialized check if we want to announce something # Once GUI has been initialized check if we want to announce something
# since the callback has been called before the GUI was initialized # since the callback has been called before the GUI was initialized
@ -719,13 +714,12 @@ class ElectrumWindow(App):
send_exception_to_crash_reporter(e) send_exception_to_crash_reporter(e)
def update_status(self, *dt): def update_status(self, *dt):
self.num_blocks = self.network.get_local_height()
if not self.wallet: if not self.wallet:
self.status = _("No Wallet")
return return
if self.network is None or not self.network.is_connected(): if self.network is None or not self.network.is_connected():
status = _("Offline") status = _("Offline")
elif self.network.is_connected(): elif self.network.is_connected():
self.num_blocks = self.network.get_local_height()
server_height = self.network.get_server_height() server_height = self.network.get_server_height()
server_lag = self.num_blocks - server_height server_lag = self.num_blocks - server_height
if not self.wallet.up_to_date or server_height == 0: if not self.wallet.up_to_date or server_height == 0:
@ -736,12 +730,14 @@ class ElectrumWindow(App):
status = '' status = ''
else: else:
status = _("Disconnected") status = _("Disconnected")
self.status = self.wallet.basename() + (' [size=15dp](%s)[/size]'%status if status else '') if status:
# balance self.balance = status
c, u, x = self.wallet.get_balance() self.fiat_balance = status
text = self.format_amount(c+x+u) else:
self.balance = str(text.strip()) + ' [size=22dp]%s[/size]'% self.base_unit c, u, x = self.wallet.get_balance()
self.fiat_balance = self.fx.format_amount(c+u+x) + ' [size=22dp]%s[/size]'% self.fx.ccy text = self.format_amount(c+x+u)
self.balance = str(text.strip()) + ' [size=22dp]%s[/size]'% self.base_unit
self.fiat_balance = self.fx.format_amount(c+u+x) + ' [size=22dp]%s[/size]'% self.fx.ccy
def get_max_amount(self): def get_max_amount(self):
from electrum.transaction import TxOutput from electrum.transaction import TxOutput

2
electrum/gui/kivy/uix/ui_screens/status.kv

@ -25,7 +25,7 @@ Popup:
spacing: '10dp' spacing: '10dp'
BoxLabel: BoxLabel:
text: _('Wallet Name') text: _('Wallet Name')
value: app.wallet_name() value: app.wallet_name
BoxLabel: BoxLabel:
text: _("Wallet type:") text: _("Wallet type:")
value: app.wallet.wallet_type value: app.wallet.wallet_type

Loading…
Cancel
Save