diff --git a/gui/kivy/__init__.py b/gui/kivy/__init__.py index 1731cfd1e..369459bc1 100644 --- a/gui/kivy/__init__.py +++ b/gui/kivy/__init__.py @@ -29,6 +29,7 @@ except ImportError: # minimum required version for kivy kivy.require('1.8.0') +from electrum.i18n import set_language from kivy.logger import Logger from main_window import ElectrumWindow @@ -39,6 +40,7 @@ class ElectrumGui: self.network = network self.config = config self.plugins = plugins + set_language(config.get('language')) def main(self): w = ElectrumWindow(config=self.config, diff --git a/gui/kivy/main.kv b/gui/kivy/main.kv index 5c3422561..e2861341a 100644 --- a/gui/kivy/main.kv +++ b/gui/kivy/main.kv @@ -358,28 +358,8 @@ Clock.schedule_once(lambda dt: self.parent.parent.dismiss() if self.parent else None, 0.05) Clock.schedule_once(lambda dt: app.popup_dialog(self.name), 0.05) - - orientation: 'vertical' - title: '' - description: '' - size_hint: 1, 1 - Label: - id: title - text: self.parent.title - size_hint: 1, 1 - bold: True - text_size: self.size - halign: 'left' - Label: - text: self.parent.description - size_hint: 1, 1 - text_size: self.width, None - color: 0.8, 0.8, 0.8, 1 - halign: 'left' - BoxLayout: - orientation: 'vertical' canvas.before: @@ -416,6 +396,9 @@ BoxLayout: ActionOverflow: id: ao + ActionOvrButton: + name: 'about' + text: _('About') ActionOvrButton: name: 'network' text: _('Network') @@ -423,15 +406,12 @@ BoxLayout: # when widget overflow drop down is shown, adjust the width parent = args[1] if parent: ao._dropdown.width = sp(200) - ActionOvrButton: - name: 'settings' - text: _('Settings') ActionOvrButton: name: 'wallets' text: _('Wallets') ActionOvrButton: - name: 'plugins' - text: _('Plugins') + name: 'settings' + text: _('Settings') ScreenManager: id: manager ScreenTabs: diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py index 4eed9318c..5b6447564 100644 --- a/gui/kivy/main_window.py +++ b/gui/kivy/main_window.py @@ -7,7 +7,7 @@ from decimal import Decimal import electrum from electrum import WalletStorage, Wallet -from electrum.i18n import _, set_language +from electrum.i18n import _ from electrum.contacts import Contacts from electrum.paymentrequest import InvoiceStore from electrum.util import profiler, InvalidPassword @@ -253,22 +253,6 @@ class ElectrumWindow(App): activity.bind(on_activity_result=on_qr_result) PythonActivity.mActivity.startActivityForResult(intent, 0) - def show_plugins(self, plugins_list): - def on_active(sw, value): - self.plugins.toggle_enabled(self.electrum_config, sw.name) - run_hook('init_kivy', self) - for item in self.plugins.descriptions: - if 'kivy' not in item.get('available_for', []): - continue - name = item.get('__name__') - label = Label(text=item.get('fullname'), height='48db', size_hint=(1, None)) - plugins_list.add_widget(label) - sw = Switch() - sw.name = name - p = self.plugins.get(name) - sw.active = (p is not None) and p.is_enabled() - sw.bind(active=on_active) - plugins_list.add_widget(sw) def build(self): return Builder.load_file('gui/kivy/main.kv') @@ -305,6 +289,7 @@ class ElectrumWindow(App): win.bind(keyboard_height=self.on_keyboard_height) self.on_size(win, win.size) + self.init_ui() self.load_wallet_by_name(self.electrum_config.get_wallet_path()) def load_wallet_by_name(self, wallet_path): @@ -324,16 +309,20 @@ class ElectrumWindow(App): # start installation wizard Logger.debug('Electrum: Wallet not found. Launching install wizard') wizard = Factory.InstallWizard(config, self.network, storage) - wizard.bind(on_wizard_complete=self.on_wizard_complete) + wizard.bind(on_wizard_complete=lambda instance, wallet: self.load_wallet(wallet)) wizard.run(action) else: wallet.start_threads(self.network) - self.on_wizard_complete(None, wallet) + self.load_wallet(wallet) + self.on_resume() - def create_wallet_dialog(self): + def create_wallet_dialog(self, l): from uix.dialogs.label_dialog import LabelDialog - d = LabelDialog(_('Enter wallet name'), '', self.load_wallet_by_name) + def f(text): + if text: + l.text = text + d = LabelDialog(_('Enter wallet name'), '', f) d.open() def settings_dialog(self): @@ -364,7 +353,6 @@ class ElectrumWindow(App): active_widg = self.root.children[0] except IndexError: return - try: fw = self._focused_widget except AttributeError: @@ -398,16 +386,6 @@ class ElectrumWindow(App): self.gui.main_gui.toggle_settings(self) return True - def on_wizard_complete(self, instance, wallet): - if not wallet: - Logger.debug('Electrum: No Wallet set/found. Exiting...') - app = App.get_running_app() - app.show_error('Electrum: No Wallet set/found. Exiting...', - exit=True) - - self.init_ui() - self.load_wallet(wallet) - def popup_dialog(self, name): if name == 'settings': self.settings_dialog() @@ -415,15 +393,12 @@ class ElectrumWindow(App): popup = Builder.load_file('gui/kivy/uix/ui_screens/'+name+'.kv') popup.open() - - @profiler def init_ui(self): ''' Initialize The Ux part of electrum. This function performs the basic tasks of setting up the ui. ''' from weakref import ref - set_language(self.electrum_config.get('language')) self.funds_error = False # setup UX @@ -540,6 +515,7 @@ class ElectrumWindow(App): @profiler def update_wallet(self, *dt): + print "update wallet" self._trigger_update_status() if self.wallet.up_to_date or not self.network or not self.network.is_connected(): self.update_history_tab() @@ -549,6 +525,7 @@ class ElectrumWindow(App): @profiler def update_history_tab(self, see_all=False): if self.history_screen: + print "blah" self.history_screen.update(see_all) def update_contacts_tab(self): diff --git a/gui/kivy/uix/dialogs/create_restore.py b/gui/kivy/uix/dialogs/create_restore.py index ff875d87f..0876933e3 100644 --- a/gui/kivy/uix/dialogs/create_restore.py +++ b/gui/kivy/uix/dialogs/create_restore.py @@ -140,11 +140,11 @@ Builder.load_string(''' height: self.minimum_height CreateAccountButton: id: create - text: _('Create a Wallet') + text: _('Create a new seed') root: root CreateAccountButton: id: restore - text: _('I already have a wallet') + text: _('I already have a seed') root: root diff --git a/gui/kivy/uix/dialogs/settings.py b/gui/kivy/uix/dialogs/settings.py index 9aadf6556..2ed996f58 100644 --- a/gui/kivy/uix/dialogs/settings.py +++ b/gui/kivy/uix/dialogs/settings.py @@ -8,6 +8,49 @@ from electrum.util import base_units from electrum.i18n import languages, set_language Builder.load_string(''' + + orientation: 'vertical' + title: '' + description: '' + size_hint: 1, 1 + Label: + id: title + text: self.parent.title + size_hint: 1, 1 + bold: True + text_size: self.size + halign: 'left' + Label: + text: self.parent.description + size_hint: 1, 1 + text_size: self.width, None + color: 0.8, 0.8, 0.8, 1 + halign: 'left' + + + orientation: 'vertical' + title: '' + description: '' + size_hint: 1, 1 + BoxLayout: + orientation: 'horizontal' + Label: + id: title + text: self.parent.title + size_hint: 1, 1 + bold: True + text_size: self.size + halign: 'left' + Switch: + id: sw + name: '' + Label: + text: self.parent.description + size_hint: 1, 1 + text_size: self.width, None + color: 0.8, 0.8, 0.8, 1 + halign: 'left' + id: settings title: _('Settings') @@ -15,13 +58,13 @@ Builder.load_string(''' orientation: 'vertical' SettingsItem: lang: settings.get_language_name() - title: _('Language') + ' (%s)'%self.lang + title: _('Language') + ': %s'%self.lang description: _("Language") on_release: settings.language_dialog(self) CardSeparator SettingsItem: - title: _('PIN Code') + ' (%s)'%('ON' if app.wallet.use_encryption else 'OFF') + title: _('PIN Code') + ': %s'%('ON' if app.wallet.use_encryption else 'OFF') description: _("Your PIN code will be required in order to spend bitcoins.") on_release: app.change_password() @@ -29,13 +72,13 @@ Builder.load_string(''' CardSeparator SettingsItem: bu: app.base_unit - title: _('Denomination') + ' (' + self.bu + ')' + title: _('Denomination') + ': ' + self.bu description: _("Base unit for Bitcoin amounts.") on_release: settings.unit_dialog(self) CardSeparator SettingsItem: - title: _('Fiat Currency') + title: _('Fiat Currency') + ': ' + app.fiat_unit description: "Select the local fiat currency." on_release: settings.fiat_dialog(self) @@ -71,9 +114,9 @@ class SettingsDialog(Factory.Popup): from choice_dialog import ChoiceDialog l = self.app.electrum_config.get('language', 'en_UK') def cb(key): - set_language(key) self.app.electrum_config.set_key("language", key, True) item.lang = self.get_language_name() + set_language(key) d = ChoiceDialog(_('Language'), languages, l, cb) d.open() @@ -98,3 +141,31 @@ class SettingsDialog(Factory.Popup): pass d = LabelDialog(_('OpenAlias'), '', callback) d.open() + + + def show_plugins(self, plugins_list): + + def on_active(sw, value): + self.plugins.toggle_enabled(self.electrum_config, sw.name) + run_hook('init_kivy', self) + + for item in self.plugins.descriptions: + if 'kivy' not in item.get('available_for', []): + continue + name = item.get('__name__') + label = Label(text=item.get('fullname'), height='48db', size_hint=(1, None)) + plugins_list.add_widget(label) + sw = Switch() + sw.name = name + p = self.plugins.get(name) + sw.active = (p is not None) and p.is_enabled() + sw.bind(active=on_active) + plugins_list.add_widget(sw) + +class PluginItem(): + def __init__(self, name): + p = self.plugins.get(name) + sw.active = (p is not None) and p.is_enabled() + sw.bind(active=on_active) + plugins_list.add_widget(sw) + diff --git a/gui/kivy/uix/ui_screens/about.kv b/gui/kivy/uix/ui_screens/about.kv new file mode 100644 index 000000000..30477b6d0 --- /dev/null +++ b/gui/kivy/uix/ui_screens/about.kv @@ -0,0 +1,12 @@ +Popup: + title: "About Electrum" + BoxLayout: + orientation: 'vertical' + spacing: '1dp' + Label: + text: "Lightweight Bitcoin Wallet" + Label: + text: "Author: Thomas Voegtlin" + Label: + text: "https://electrum.org" + Widget diff --git a/gui/kivy/uix/ui_screens/plugins.kv b/gui/kivy/uix/ui_screens/plugins.kv deleted file mode 100644 index ddf908b04..000000000 --- a/gui/kivy/uix/ui_screens/plugins.kv +++ /dev/null @@ -1,27 +0,0 @@ -Popup: - title: _('Plugins') - id: popup - BoxLayout: - orientation: 'vertical' - - GridLayout: - cols: 2 - size_hint: 1, None - height: '100dp' - id: plugins_list - on_parent: - app.show_plugins(plugins_list) - - Widget: - size_hint: 1, 1 - - BoxLayout: - Widget: - size_hint: 0.5, None - Button: - size_hint: 0.5, None - height: '48dp' - text: _('OK') - on_release: - popup.dismiss() - diff --git a/gui/kivy/uix/ui_screens/wallets.kv b/gui/kivy/uix/ui_screens/wallets.kv index 55289f523..d96969195 100644 --- a/gui/kivy/uix/ui_screens/wallets.kv +++ b/gui/kivy/uix/ui_screens/wallets.kv @@ -3,43 +3,52 @@ Popup: title: _('Wallets') id: popup + path: app.wallet.storage.path + on_path: + button.text = _('Open') if os.path.exists(popup.path) else _('Create') BoxLayout: orientation: 'vertical' - Label: - id: text_input - height: '32dp' + BoxLayout: + height: '48dp' size_hint_y: None - text: os.path.basename(app.wallet.storage.path) + orientation: 'horizontal' + Label: + text: _('Wallet') + ': ' + height: '48dp' + size_hint_y: None + Button: + id: wallet_name + height: '48dp' + size_hint_y: None + text: os.path.basename(app.wallet.storage.path) + on_release: + app.create_wallet_dialog(self) + on_text: + popup.path = os.path.join(wallet_selector.path, self.text) Widget size_hint_y: None - FileChooserListView: id: wallet_selector path: os.path.dirname(app.wallet.storage.path) on_selection: - text_input.text = os.path.basename(self.selection[0]) if self.selection else '' - size_hint: 1, 1 - + wallet_name.text = os.path.basename(self.selection[0]) if self.selection else '' + size_hint_y: 0.5 + Widget + size_hint_y: 0.1 GridLayout: - cols: 3 + cols: 2 size_hint_y: None Button: size_hint: 0.5, None height: '48dp' - text: _('Create') - on_release: - popup.dismiss() - app.create_wallet_dialog() - Button: - size_hint: 0.5, None - height: '48dp' - text: _('Open') + text: _('Cancel') on_release: popup.dismiss() - app.open_wallet(text_input.text) Button: + id: button size_hint: 0.5, None height: '48dp' - text: _('Cancel') + text: _('Open') if os.path.exists(popup.path) else _('Create') on_release: popup.dismiss() + app.load_wallet_by_name(popup.path)