electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit c8cd187bd4441a06e80d53f0ddaeed45589f187e
parent d8626793bc548a763741571e21131340ed2df48a
Author: ThomasV <thomasv@gitorious>
Date:   Sun,  3 Nov 2013 11:03:45 +0100

use QStackedLayout in install wizard

Diffstat:
Mgui/qt/installwizard.py | 45++++++++++++++++++++++++---------------------
Mgui/qt/password_dialog.py | 4++--
2 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/gui/qt/installwizard.py b/gui/qt/installwizard.py @@ -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) diff --git a/gui/qt/password_dialog.py b/gui/qt/password_dialog.py @@ -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):