commit 85aa633269b6bc8026f379df1e010ad54159737c
parent 0e853a6769b556113ab761c72f8bd505dd4cae1d
Author: ThomasV <thomasv@electrum.org>
Date: Sat, 21 May 2016 18:43:41 +0200
simplify wizard handling of hardware wallets. fixes #1793
Diffstat:
2 files changed, 16 insertions(+), 25 deletions(-)
diff --git a/gui/qt/installwizard.py b/gui/qt/installwizard.py
@@ -260,7 +260,7 @@ class InstallWizard(QDialog, MessageBoxMixin, WizardBase):
'restore', and kind the index of the wallet kind chosen."""
actions = [_("Create a new wallet"),
- _("Restore a wallet or import keys")]
+ _("Restore a wallet from seed words or from keys")]
title = _("Electrum could not find an existing wallet.")
actions_clayout = ChoicesLayout(_("What do you want to do?"), actions)
wallet_clayout = ChoicesLayout(_("Wallet kind:"), wallet_kinds)
@@ -273,25 +273,15 @@ class InstallWizard(QDialog, MessageBoxMixin, WizardBase):
action = ['create', 'restore'][actions_clayout.selected_index()]
return action, wallet_clayout.selected_index()
- def query_hw_wallet_choice(self, msg, action, choices):
- actions = [_("Initialize a new or wiped device"),
- _("Use a device you have already set up"),
- _("Restore Electrum wallet from device seed words")]
- default_action = 1 if action == 'create' else 2
- actions_clayout = ChoicesLayout(_("What do you want to do?"), actions,
- checked_index=default_action)
- wallet_clayout = ChoicesLayout(msg, choices)
-
+ def query_hw_wallet_choice(self, msg, choices):
vbox = QVBoxLayout()
- vbox.addLayout(actions_clayout.layout())
- vbox.addLayout(wallet_clayout.layout())
- self.set_main_layout(vbox, next_enabled=len(choices) != 0)
-
- if actions_clayout.selected_index() == 2:
- action = 'restore'
+ if choices:
+ wallet_clayout = ChoicesLayout(msg, choices)
+ vbox.addLayout(wallet_clayout.layout())
else:
- action = 'create'
- return action, wallet_clayout.selected_index()
+ vbox.addWidget(QLabel(msg, wordWrap=True))
+ self.set_main_layout(vbox, next_enabled=len(choices) != 0)
+ return wallet_clayout.selected_index() if choices else 0
def request_many(self, n, xpub_hot=None):
vbox = QVBoxLayout()
diff --git a/lib/wizard.py b/lib/wizard.py
@@ -209,19 +209,20 @@ class WizardBase(PrintError):
kinds, descriptions = zip(*[pair for pair in WizardBase.wallet_kinds
if pair[0] in registered_kinds])
action, kind_index = self.query_create_or_restore(descriptions)
-
assert action in WizardBase.user_actions
-
kind = kinds[kind_index]
if kind == 'multisig':
wallet_type = self.query_multisig(action)
elif kind == 'hardware':
- # The create/restore distinction is not obvious for hardware
- # wallets; so we ask for the action again and default based
- # on the prior choice :)
hw_wallet_types, choices = self.plugins.hardware_wallets(action)
- msg = _('Select the type of hardware wallet: ')
- action, choice = self.query_hw_wallet_choice(msg, action, choices)
+ if choices:
+ msg = _('Select the type of hardware wallet: ')
+ else:
+ msg = ' '.join([
+ _('No hardware wallet support found on your system.'),
+ _('Please install the relevant libraries (eg python-trezor for Trezor).'),
+ ])
+ choice = self.query_hw_wallet_choice(msg, choices)
wallet_type = hw_wallet_types[choice]
elif kind == 'twofactor':
wallet_type = '2fa'