Browse Source

improve wizard messages; skip choice screen if there is only one choice

283
ThomasV 8 years ago
parent
commit
4bc756751b
  1. 20
      gui/kivy/uix/dialogs/installwizard.py
  2. 5
      gui/qt/installwizard.py
  3. 19
      lib/base_wizard.py

20
gui/kivy/uix/dialogs/installwizard.py

@ -408,17 +408,13 @@ Builder.load_string('''
text: root.title text: root.title
SeedLabel: SeedLabel:
text: root.message text: root.message
GridLayout:
cols: 2
size_hint: 1, None
height: '27dp'
BigLabel:
text: ''
TextInput: TextInput:
id: passphrase_input id: passphrase_input
multiline: False multiline: False
size_hint: 1, None size_hint: 1, None
height: '27dp' height: '27dp'
SeedLabel:
text: root.warning
''') ''')
@ -515,6 +511,7 @@ class WizardChoiceDialog(WizardDialog):
class LineDialog(WizardDialog): class LineDialog(WizardDialog):
title = StringProperty('') title = StringProperty('')
message = StringProperty('') message = StringProperty('')
warning = StringProperty('')
def __init__(self, wizard, **kwargs): def __init__(self, wizard, **kwargs):
WizardDialog.__init__(self, wizard, **kwargs) WizardDialog.__init__(self, wizard, **kwargs)
@ -741,7 +738,14 @@ class InstallWizard(BaseWizard, Widget):
self.wallet.start_threads(self.network) self.wallet.start_threads(self.network)
self.dispatch('on_wizard_complete', self.wallet) self.dispatch('on_wizard_complete', self.wallet)
def choice_dialog(self, **kwargs): WizardChoiceDialog(self, **kwargs).open() def choice_dialog(self, **kwargs):
choices = kwargs['choices']
if len(choices) > 1:
WizardChoiceDialog(self, **kwargs).open()
else:
f = kwargs['run_next']
apply(f, (choices[0][0],))
def multisig_dialog(self, **kwargs): WizardMultisigDialog(self, **kwargs).open() def multisig_dialog(self, **kwargs): WizardMultisigDialog(self, **kwargs).open()
def show_seed_dialog(self, **kwargs): ShowSeedDialog(self, **kwargs).open() def show_seed_dialog(self, **kwargs): ShowSeedDialog(self, **kwargs).open()
def line_dialog(self, **kwargs): LineDialog(self, **kwargs).open() def line_dialog(self, **kwargs): LineDialog(self, **kwargs).open()
@ -754,7 +758,7 @@ class InstallWizard(BaseWizard, Widget):
def restore_seed_dialog(self, **kwargs): def restore_seed_dialog(self, **kwargs):
RestoreSeedDialog(self, **kwargs).open() RestoreSeedDialog(self, **kwargs).open()
def restore_keys_dialog(self, **kwargs): def add_xpub_dialog(self, **kwargs):
kwargs['message'] += ' ' + _('Use the camera button to scan a QR code.') kwargs['message'] += ' ' + _('Use the camera button to scan a QR code.')
AddXpubDialog(self, **kwargs).open() AddXpubDialog(self, **kwargs).open()

5
gui/qt/installwizard.py

@ -267,7 +267,7 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
return seed, is_bip39 return seed, is_bip39
@wizard_dialog @wizard_dialog
def restore_keys_dialog(self, title, message, is_valid, run_next): def add_xpub_dialog(self, title, message, is_valid, run_next):
return self.text_input(title, message, is_valid) return self.text_input(title, message, is_valid)
@wizard_dialog @wizard_dialog
@ -378,7 +378,7 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
return clayout.selected_index() return clayout.selected_index()
@wizard_dialog @wizard_dialog
def line_dialog(self, run_next, title, message, default, test): def line_dialog(self, run_next, title, message, warning, default, test):
vbox = QVBoxLayout() vbox = QVBoxLayout()
vbox.addWidget(WWLabel(message)) vbox.addWidget(WWLabel(message))
line = QLineEdit() line = QLineEdit()
@ -387,6 +387,7 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
self.next_button.setEnabled(test(text)) self.next_button.setEnabled(test(text))
line.textEdited.connect(f) line.textEdited.connect(f)
vbox.addWidget(line) vbox.addWidget(line)
vbox.addWidget(WWLabel(warning))
self.set_main_layout(vbox, title, next_enabled=test(default)) self.set_main_layout(vbox, title, next_enabled=test(default))
return ' '.join(unicode(line.text()).split()) return ' '.join(unicode(line.text()).split())

19
lib/base_wizard.py

@ -152,14 +152,11 @@ class BaseWizard(object):
_("To create a watching-only wallet, please enter your master public key (xpub)."), _("To create a watching-only wallet, please enter your master public key (xpub)."),
_("To create a spending wallet, please enter a master private key (xprv), or a list of Bitcoin private keys.") _("To create a spending wallet, please enter a master private key (xprv), or a list of Bitcoin private keys.")
]) ])
self.add_xpub_dialog(title=title, message=message, run_next=self.on_restore_from_key, is_valid=v)
else: else:
v = keystore.is_bip32_key v = keystore.is_bip32_key
title = _("Master public or private key") i = len(self.keystores) + 1
message = ' '.join([ self.add_cosigner_dialog(index=i, run_next=self.on_restore_from_key, is_valid=v)
_("To create a watching-only wallet, please enter your master public key (xpub)."),
_("To create a spending wallet, please enter a master private key (xprv).")
])
self.restore_keys_dialog(title=title, message=message, run_next=self.on_restore_from_key, is_valid=v)
def on_restore_from_key(self, text): def on_restore_from_key(self, text):
k = keystore.from_keys(text) k = keystore.from_keys(text)
@ -255,12 +252,13 @@ class BaseWizard(object):
message = '\n'.join([ message = '\n'.join([
_('Your seed may have a passphrase.'), _('Your seed may have a passphrase.'),
_('If that is the case, enter it here.'), _('If that is the case, enter it here.'),
'\n', ])
warning = '\n'.join([
_('Note that this is NOT your encryption password.'), _('Note that this is NOT your encryption password.'),
_('If you do not know what this is, leave this field empty.'), _('If you do not know what this is, leave this field empty.'),
]) ])
f = lambda x: self.on_restore_passphrase(seed, x, is_bip39) f = lambda x: self.on_restore_passphrase(seed, x, is_bip39)
self.line_dialog(title=_('Passphrase'), message=message, default='', test=lambda x:True, run_next=f) self.line_dialog(title=_('Passphrase'), message=message, warning=warning, default='', test=lambda x:True, run_next=f)
else: else:
self.on_restore_passphrase(seed, '', False) self.on_restore_passphrase(seed, '', False)
@ -344,12 +342,13 @@ class BaseWizard(object):
message = '\n'.join([ message = '\n'.join([
_('You may extend your seed with a passphrase.'), _('You may extend your seed with a passphrase.'),
_('This allows you to derive several wallets from the same seed.'), _('This allows you to derive several wallets from the same seed.'),
'\n', ])
warning = '\n'.join([
_('Note that this is NOT your encryption password.'), _('Note that this is NOT your encryption password.'),
_('If you do not know what this is, leave this field empty.'), _('If you do not know what this is, leave this field empty.'),
]) ])
f = lambda x: self.confirm_seed(seed, x) f = lambda x: self.confirm_seed(seed, x)
self.line_dialog(run_next=f, title=title, message=message, default='', test=lambda x:True) self.line_dialog(run_next=f, title=title, message=message, warning=warning, default='', test=lambda x:True)
def confirm_seed(self, seed, passphrase): def confirm_seed(self, seed, passphrase):
f = lambda x: self.confirm_passphrase(seed, passphrase) f = lambda x: self.confirm_passphrase(seed, passphrase)

Loading…
Cancel
Save