use QStackedLayout in install wizard

This commit is contained in:
ThomasV 2013-11-03 11:03:45 +01:00
parent d8626793bc
commit c8cd187bd4
2 changed files with 26 additions and 23 deletions

View File

@ -24,6 +24,15 @@ class InstallWizard(QDialog):
self.setWindowTitle('Electrum')
self.connect(self, QtCore.SIGNAL('accept'), self.accept)
self.stack = QStackedLayout()
self.setLayout(self.stack)
def set_layout(self, layout):
w = QWidget()
w.setLayout(layout)
self.stack.setCurrentIndex(self.stack.addWidget(w))
def restore_or_create(self):
@ -51,9 +60,10 @@ class InstallWizard(QDialog):
grid.addWidget(b2,2,0)
grid.addWidget(b3,3,0)
vbox = QVBoxLayout(self)
vbox.addLayout(grid)
vbox = QVBoxLayout()
self.set_layout(vbox)
vbox.addLayout(grid)
vbox.addStretch(1)
vbox.addLayout(ok_cancel_buttons(self, _('Next')))
@ -84,9 +94,7 @@ class InstallWizard(QDialog):
def seed_dialog(self, is_restore=True):
if self.layout(): QWidget().setLayout(self.layout())
vbox = QVBoxLayout(self)
vbox = QVBoxLayout()
if is_restore:
msg = _("Please enter your wallet seed.") + "\n"
else:
@ -111,10 +119,10 @@ class InstallWizard(QDialog):
vbox.addLayout(grid)
vbox.addStretch(1)
vbox.addLayout(ok_cancel_buttons(self, _('Next')))
self.set_layout(vbox)
if not self.exec_():
return
@ -133,10 +141,10 @@ class InstallWizard(QDialog):
task()
self.emit(QtCore.SIGNAL('accept'))
if self.layout(): QWidget().setLayout(self.layout())
vbox = QVBoxLayout(self)
vbox = QVBoxLayout()
self.waiting_label = QLabel(msg)
vbox.addWidget(self.waiting_label)
self.set_layout(vbox)
t = threading.Thread(target = target)
t.start()
self.exec_()
@ -145,10 +153,7 @@ class InstallWizard(QDialog):
def mpk_dialog(self):
if self.layout(): QWidget().setLayout(self.layout())
vbox = QVBoxLayout(self)
vbox = QVBoxLayout()
vbox.addWidget(QLabel(_("Please enter your master public key.")))
grid = QGridLayout()
@ -171,6 +176,7 @@ class InstallWizard(QDialog):
vbox.addStretch(1)
vbox.addLayout(ok_cancel_buttons(self, _('Next')))
self.set_layout(vbox)
if not self.exec_(): return None, None
mpk = str(mpk_e.toPlainText()).strip()
@ -180,8 +186,6 @@ class InstallWizard(QDialog):
def network_dialog(self):
if self.layout(): QWidget().setLayout(self.layout())
grid = QGridLayout()
grid.setSpacing(5)
@ -206,12 +210,13 @@ class InstallWizard(QDialog):
grid.addWidget(b2,2,0)
#grid.addWidget(b3,3,0)
vbox = QVBoxLayout(self)
vbox = QVBoxLayout()
vbox.addLayout(grid)
vbox.addStretch(1)
vbox.addLayout(ok_cancel_buttons(self, _('Next')))
self.set_layout(vbox)
if not self.exec_():
return
@ -227,7 +232,7 @@ class InstallWizard(QDialog):
self.config.set_key('auto_cycle', False, True)
return
def show_seed(self, wallet):
from seed_dialog import make_seed_dialog
@ -235,9 +240,7 @@ class InstallWizard(QDialog):
vbox = make_seed_dialog(wallet.get_mnemonic(None), wallet.imported_keys)
vbox.addLayout(ok_cancel_buttons(self, _("Next")))
if self.layout(): QWidget().setLayout(self.layout())
self.setLayout(vbox)
self.set_layout(vbox)
if not self.exec_():
exit()
@ -246,8 +249,8 @@ class InstallWizard(QDialog):
msg = _("Please choose a password to encrypt your wallet keys.")+'\n'\
+_("Leave these fields empty if you want to disable encryption.")
from password_dialog import make_password_dialog, run_password_dialog
if self.layout(): QWidget().setLayout(self.layout())
make_password_dialog(self, wallet, msg)
self.set_layout( make_password_dialog(self, wallet, msg) )
run_password_dialog(self, wallet, self)

View File

@ -68,7 +68,7 @@ def make_password_dialog(self, wallet, msg):
vbox.addStretch(1)
vbox.addLayout(ok_cancel_buttons(self))
self.setLayout(vbox)
return vbox
def run_password_dialog(self, wallet, parent):
@ -119,7 +119,7 @@ class PasswordDialog(QDialog):
msg = (_('Your wallet is encrypted. Use this dialog to change your password.') + ' '\
+_('To disable wallet encryption, enter an empty new password.')) \
if wallet.use_encryption else _('Your wallet keys are not encrypted')
make_password_dialog(self, wallet, msg)
self.setLayout(make_password_dialog(self, wallet, msg))
def run(self):