1
0

qt: wizard back button disabled while busy. Wrap error texts

This commit is contained in:
Sander van Grieken
2023-08-31 19:38:24 +02:00
parent 53b12cb086
commit bb8b82cc7e
2 changed files with 7 additions and 3 deletions

View File

@@ -16,7 +16,7 @@ from electrum.i18n import _
from electrum.keystore import bip44_derivation, bip39_to_seed, purpose48_derivation, ScriptTypeNotSupported
from electrum.plugin import run_hook, HardwarePluginLibraryUnavailable
from electrum.storage import StorageReadWriteError
from electrum.util import WalletFileException, get_new_wallet_name, UserCancelled
from electrum.util import WalletFileException, get_new_wallet_name, UserCancelled, UserFacingException
from electrum.wallet import wallet_types
from .wizard import QEAbstractWizard, WizardComponent
from electrum.logging import get_logger, Logger
@@ -1271,6 +1271,9 @@ class WCHWXPub(WizardComponent, Logger):
self.root_fingerprint = client.request_root_fingerprint_from_device()
self.label = client.label()
self.soft_device_id = client.get_soft_device_id()
except UserFacingException as e:
self.error = str(e)
self.logger.error(repr(e))
except Exception as e:
self.error = repr(e) # TODO: handle user interaction exceptions (e.g. invalid pin) more gracefully
self.logger.error(repr(e))

View File

@@ -10,7 +10,7 @@ from PyQt5.QtWidgets import (QDialog, QPushButton, QWidget, QLabel, QVBoxLayout,
from electrum.i18n import _
from electrum.logging import get_logger
from electrum.gui.qt.util import Buttons, icon_path, MessageBoxMixin
from electrum.gui.qt.util import Buttons, icon_path, MessageBoxMixin, WWLabel
if TYPE_CHECKING:
from electrum.simple_config import SimpleConfig
@@ -58,7 +58,7 @@ class QEAbstractWizard(QDialog, MessageBoxMixin):
error_l = QLabel(_("Error!"))
error_l.setAlignment(Qt.AlignCenter)
error_layout.addWidget(error_l)
self.error_msg = QLabel()
self.error_msg = WWLabel()
self.error_msg.setAlignment(Qt.AlignCenter)
error_layout.addWidget(self.error_msg)
error_layout.addStretch(1)
@@ -161,6 +161,7 @@ class QEAbstractWizard(QDialog, MessageBoxMixin):
page = self.main_widget.currentWidget()
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.back_button.setEnabled(not page.busy)
self.next_button.setText(_('Next') if not self.is_last(page.wizard_data) else _('Finish'))
self.next_button.setEnabled(page.valid)
self.main_widget.setVisible(not page.busy and not bool(page.error))