1
0

wizard: implement confirm seed and wallet password pages

some styling improvements
This commit is contained in:
Sander van Grieken
2023-07-27 14:38:01 +02:00
parent 113d698e42
commit ffbddb9208
3 changed files with 68 additions and 9 deletions

View File

@@ -59,6 +59,7 @@ class WCProxyAsk(WizardComponent):
choices = [_("Yes"), _("No")]
self.clayout = ChoicesLayout(message, choices)
self.layout().addLayout(self.clayout.layout())
self._valid = True
def apply(self):
r = self.clayout.selected_index()

View File

@@ -47,7 +47,7 @@ class QENewWalletWizard(NewWalletWizard, QEAbstractWizard):
'multisig_cosigner_seed': { 'gui': 'WCHaveSeed' },
'multisig_cosigner_bip39_refine': { 'gui': 'WCBIP39Refine' },
'imported': { 'gui': 'WCImport' },
'wallet_password': { 'gui': 'WCWalletPassword' }
'wallet_password': { 'gui': WCWalletPassword }
})
# insert seed extension entry/confirm as separate views
@@ -290,6 +290,7 @@ class WCCreateSeed(WizardComponent):
self.wizard_data['seed_type'] = self.seed_type
self.wizard_data['seed_extend'] = self.slayout.is_ext
self.wizard_data['seed_variant'] = 'electrum'
self.wizard_data['seed_extra_words'] = '' # empty default
def create_seed(self):
self.busy = True
@@ -317,9 +318,21 @@ class WCConfirmSeed(WizardComponent):
_('To make sure that you have properly saved your seed, please retype it here.')
])
self.layout().addWidget(QLabel(message))
self.layout().addWidget(WWLabel(message))
self._valid = True
# TODO: SeedLayout assumes too much in parent, refactor SeedLayout
# for now, fake parent.next_button.setEnabled
class Hack:
def setEnabled(self2, b):
self.valid = b
self.next_button = Hack()
self.slayout = SeedLayout(
is_seed=lambda x: x == self.wizard_data['seed'],
parent=self,
config=self.wizard.config,
)
self.layout().addLayout(self.slayout)
def apply(self):
pass
@@ -341,6 +354,7 @@ class WCCreateExt(WizardComponent):
self.ext_edit = SeedExtensionEdit(self, message=message, warning=warning)
self.ext_edit.textEdited.connect(self.on_text_edited)
self.layout().addWidget(self.ext_edit)
self.layout().addStretch(1)
def on_text_edited(self, text):
self.ext_edit.warn_issue4566 = self.wizard_data['keystore_type'] == 'haveseed' and \
@@ -361,6 +375,7 @@ class WCConfirmExt(WizardComponent):
self.ext_edit = SeedExtensionEdit(self, message=message)
self.ext_edit.textEdited.connect(self.on_text_edited)
self.layout().addWidget(self.ext_edit)
self.layout().addStretch(1)
def on_text_edited(self, text):
self.valid = text == self.wizard_data['seed_extra_words']
@@ -369,6 +384,32 @@ class WCConfirmExt(WizardComponent):
pass
class WCWalletPassword(WizardComponent):
def __init__(self, parent, wizard):
WizardComponent.__init__(self, parent, wizard, title=_('Wallet Password'))
# TODO: PasswordLayout assumes a button, refactor PasswordLayout
# for now, fake next_button.setEnabled
class Hack:
def setEnabled(self2, b):
self.valid = b
self.next_button = Hack()
self.pw_layout = PasswordLayout(
msg=MSG_ENTER_PASSWORD,
kind=PW_NEW,
OK_button=self.next_button,
# force_disable_encrypt_cb=force_disable_encrypt_cb
)
self.pw_layout.encrypt_cb.setChecked(True)
self.layout().addLayout(self.pw_layout.layout())
self.layout().addStretch(1)
def apply(self):
self.wizard_data['password'] = self.pw_layout.new_password()
self.wizard_data['encrypt'] = self.pw_layout.encrypt_cb.isChecked()
class SeedExtensionEdit(QWidget):
def __init__(self, parent, *, message: str = None, warning: str = None, warn_issue4566: bool = False):
super().__init__(parent)

View File

@@ -1,7 +1,7 @@
from abc import abstractmethod
from typing import Dict, Any
from PyQt5.QtCore import Qt, QTimer, pyqtSignal, pyqtSlot
from PyQt5.QtCore import Qt, QTimer, pyqtSignal, pyqtSlot, QSize
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import (QDialog, QApplication, QPushButton, QWidget, QLabel, QVBoxLayout, QScrollArea,
QHBoxLayout, QLayout, QStackedWidget)
@@ -21,26 +21,32 @@ class QEAbstractWizard(QDialog):
self.config = config
# self.gui_thread = gui_object.gui_thread
self.setMinimumSize(600, 400)
self.title = QLabel()
self.main_widget = QStackedWidget(self)
self.back_button = QPushButton(_("Back"), self)
self.back_button.clicked.connect(self.on_back_button_clicked)
self.next_button = QPushButton(_("Next"), self)
self.next_button.clicked.connect(self.on_next_button_clicked)
self.next_button.setDefault(True)
self.logo = QLabel()
self.please_wait_layout = QVBoxLayout()
self.please_wait_layout.addStretch(1)
self.please_wait = QLabel(_("Please wait..."))
self.please_wait.setAlignment(Qt.AlignCenter)
self.please_wait.setVisible(False)
self.icon_filename = None
self.please_wait_layout.addWidget(self.please_wait)
self.please_wait_layout.addStretch(1)
outer_vbox = QVBoxLayout(self)
inner_vbox = QVBoxLayout()
inner_vbox.addWidget(self.title)
inner_vbox.addWidget(self.main_widget)
inner_vbox.addStretch(1)
inner_vbox.addWidget(self.please_wait)
inner_vbox.addStretch(1)
inner_vbox.addLayout(self.please_wait_layout)
scroll_widget = QWidget()
scroll_widget.setLayout(inner_vbox)
scroll = QScrollArea()
@@ -58,7 +64,10 @@ class QEAbstractWizard(QDialog):
hbox.setStretchFactor(scroll, 1)
outer_vbox.addLayout(hbox)
outer_vbox.addLayout(Buttons(self.back_button, self.next_button))
self.icon_filename = None
self.set_icon('electrum.png')
self.show()
self.raise_()
@@ -72,13 +81,20 @@ class QEAbstractWizard(QDialog):
# self.app.processEvents()
# self.app.processEvents()
def sizeHint(self) -> QSize:
return QSize(800, 600)
def strt(self):
view = self.start_wizard()
self.load_next_component(view)
def load_next_component(self, view, wdata={}):
comp = self.view_to_component(view)
page = comp(self.main_widget, self)
try:
page = comp(self.main_widget, self)
except Exception as e:
self._logger.error(f'not a class: {comp!r}')
raise e
page.wizard_data = wdata
page.config = self.config
page.updated.connect(self.on_page_updated)
@@ -107,6 +123,7 @@ class QEAbstractWizard(QDialog):
def update(self):
page = self.main_widget.currentWidget()
self.title.setText(page.title)
self.title.setText(f'<b>{page.title}</b>' if page.title else '')
self.back_button.setText(_('Back') if self.can_go_back() else _('Cancel'))
self.next_button.setText(_('Next') if not self.is_last(page.wizard_data) else _('Finish'))
self.next_button.setEnabled(page.valid)