qt: refactor please_wait layout to widget to better control UI, add in-page error view
This commit is contained in:
@@ -43,6 +43,7 @@ class WCAutoConnect(WizardComponent):
|
||||
choices = [_("Auto connect"), _("Select server manually")]
|
||||
self.clayout = ChoicesLayout(message, choices, on_clicked=self.on_updated)
|
||||
self.layout().addLayout(self.clayout.layout())
|
||||
self.layout().addStretch(1)
|
||||
self._valid = True
|
||||
|
||||
def apply(self):
|
||||
@@ -65,6 +66,7 @@ class WCProxyAsk(WizardComponent):
|
||||
choices = [_("Yes"), _("No")]
|
||||
self.clayout = ChoicesLayout(message, choices)
|
||||
self.layout().addLayout(self.clayout.layout())
|
||||
self.layout().addStretch(1)
|
||||
self._valid = True
|
||||
|
||||
def apply(self):
|
||||
@@ -77,6 +79,7 @@ class WCProxyConfig(WizardComponent):
|
||||
WizardComponent.__init__(self, parent, wizard, title=_("Proxy"))
|
||||
pw = ProxyWidget(self)
|
||||
self.layout().addWidget(pw)
|
||||
self.layout().addStretch(1)
|
||||
|
||||
def apply(self):
|
||||
# TODO
|
||||
@@ -88,6 +91,7 @@ class WCServerConfig(WizardComponent):
|
||||
WizardComponent.__init__(self, parent, wizard, title=_("Server"))
|
||||
sw = ServerWidget(self)
|
||||
self.layout().addWidget(sw)
|
||||
self.layout().addStretch(1)
|
||||
|
||||
def apply(self):
|
||||
# TODO
|
||||
|
||||
@@ -180,6 +180,7 @@ class WCWalletName(WizardComponent):
|
||||
widget_create_new.setLayout(vbox_create_new)
|
||||
vbox_create_new.setContentsMargins(0, 0, 0, 0)
|
||||
self.layout().addWidget(widget_create_new)
|
||||
self.layout().addStretch(1)
|
||||
|
||||
temp_storage = None # type: Optional[WalletStorage]
|
||||
wallet_folder = os.path.dirname(path)
|
||||
@@ -268,6 +269,7 @@ class WCWalletType(WizardComponent):
|
||||
c_titles = [x[1] for x in choices]
|
||||
self.clayout = ChoicesLayout(message, c_titles)
|
||||
self.layout().addLayout(self.clayout.layout())
|
||||
self.layout().addStretch(1)
|
||||
self._valid = True
|
||||
|
||||
def apply(self):
|
||||
@@ -289,6 +291,7 @@ class WCKeystoreType(WizardComponent):
|
||||
c_titles = [x[1] for x in choices]
|
||||
self.clayout = ChoicesLayout(message, c_titles)
|
||||
self.layout().addLayout(self.clayout.layout())
|
||||
self.layout().addStretch(1)
|
||||
self._valid = True
|
||||
|
||||
def apply(self):
|
||||
@@ -327,6 +330,7 @@ class WCCreateSeed(WizardComponent):
|
||||
config=self.wizard.config,
|
||||
)
|
||||
self.layout().addLayout(self.slayout)
|
||||
self.layout().addStretch(1)
|
||||
self.busy = False
|
||||
self.valid = True
|
||||
|
||||
@@ -466,6 +470,7 @@ class WCHaveSeed(WizardComponent):
|
||||
self.slayout.updated.connect(self.validate)
|
||||
|
||||
self.layout().addLayout(self.slayout)
|
||||
self.layout().addStretch(1)
|
||||
|
||||
def is_seed(self, x):
|
||||
if self.wizard_data['wallet_type'] == 'standard':
|
||||
@@ -780,6 +785,7 @@ class WCMultisig(WizardComponent):
|
||||
self.layout().addLayout(grid)
|
||||
self.layout().addSpacing(2 * char_width_in_lineedit())
|
||||
self.layout().addWidget(backup_warning_label)
|
||||
self.layout().addStretch(1)
|
||||
|
||||
self.n_edit = n_edit
|
||||
self.m_edit = m_edit
|
||||
|
||||
@@ -41,19 +41,34 @@ class QEAbstractWizard(QDialog):
|
||||
|
||||
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.please_wait_layout.addWidget(self.please_wait)
|
||||
self.please_wait_layout.addStretch(1)
|
||||
please_wait_layout = QVBoxLayout()
|
||||
please_wait_layout.addStretch(1)
|
||||
please_wait_l = QLabel(_("Please wait..."))
|
||||
please_wait_l.setAlignment(Qt.AlignCenter)
|
||||
please_wait_layout.addWidget(please_wait_l)
|
||||
please_wait_layout.addStretch(1)
|
||||
self.please_wait = QWidget()
|
||||
self.please_wait.setLayout(please_wait_layout)
|
||||
|
||||
error_layout = QVBoxLayout()
|
||||
error_layout.addStretch(1)
|
||||
error_l = QLabel(_("Error!"))
|
||||
error_l.setAlignment(Qt.AlignCenter)
|
||||
error_layout.addWidget(error_l)
|
||||
self.error_msg = QLabel()
|
||||
self.error_msg.setAlignment(Qt.AlignCenter)
|
||||
error_layout.addWidget(self.error_msg)
|
||||
error_layout.addStretch(1)
|
||||
self.error = QWidget()
|
||||
self.error.setLayout(error_layout)
|
||||
|
||||
outer_vbox = QVBoxLayout(self)
|
||||
inner_vbox = QVBoxLayout()
|
||||
inner_vbox.addWidget(self.title)
|
||||
inner_vbox.addWidget(self.main_widget)
|
||||
inner_vbox.addLayout(self.please_wait_layout)
|
||||
inner_vbox.addWidget(self.please_wait)
|
||||
inner_vbox.addWidget(self.error)
|
||||
|
||||
scroll_widget = QWidget()
|
||||
scroll_widget.setLayout(inner_vbox)
|
||||
scroll = QScrollArea()
|
||||
@@ -139,8 +154,10 @@ class QEAbstractWizard(QDialog):
|
||||
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)
|
||||
self.main_widget.setVisible(not page.busy)
|
||||
self.main_widget.setVisible(not page.busy and not bool(page.error))
|
||||
self.please_wait.setVisible(page.busy)
|
||||
self.error_msg.setText(str(page.error))
|
||||
self.error.setVisible(not page.busy and bool(page.error))
|
||||
icon = page.params.get('icon', icon_path('electrum.png'))
|
||||
if icon != self.icon_filename:
|
||||
self.set_icon(icon)
|
||||
@@ -195,6 +212,7 @@ class WizardComponent(QWidget):
|
||||
self.wizard_data = {}
|
||||
self.title = title if title is not None else 'No title'
|
||||
self.wizard = wizard
|
||||
self.error = ''
|
||||
self._valid = False
|
||||
self._busy = False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user