commit 5071d7591223f8b2ebe3450677800c6cf1d68e9f
parent a4a2eb9b5c6c67e2873bd3eb165f237b4f929990
Author: Neil Booth <kyuupichan@gmail.com>
Date: Sat, 26 Sep 2015 17:19:42 +0900
Clean up install wizard a little
Also fixes #1462
Diffstat:
2 files changed, 32 insertions(+), 54 deletions(-)
diff --git a/gui/qt/__init__.py b/gui/qt/__init__.py
@@ -34,6 +34,8 @@ from electrum.plugins import run_hook
from electrum import SimpleConfig, Wallet, WalletStorage
from electrum.paymentrequest import InvoiceStore
from electrum.contacts import Contacts
+from installwizard import InstallWizard
+
try:
import icons_rc
@@ -119,31 +121,6 @@ class ElectrumGui:
for window in self.windows:
window.close()
- def run_wizard(self, storage, action):
- import installwizard
- if storage.file_exists and action != 'new':
- msg = _("The file '%s' contains an incompletely created wallet.")%storage.path + '\n'\
- + _("Do you want to complete its creation now?")
- if not self.question(msg):
- if self.question(_("Do you want to delete '%s'?")%storage.path):
- os.remove(storage.path)
- QMessageBox.information(self, _('Warning'), _('The file was removed'), _('OK'))
- return
- return
- wizard = installwizard.InstallWizard(self.config, self.network, storage, self)
- wizard.show()
- if action == 'new':
- action, wallet_type = wizard.restore_or_create()
- else:
- wallet_type = None
- try:
- wallet = wizard.run(action, wallet_type)
- except BaseException as e:
- traceback.print_exc(file=sys.stdout)
- QMessageBox.information(None, _('Error'), str(e), _('OK'))
- return
- return wallet
-
def load_wallet_file(self, filename):
try:
storage = WalletStorage(filename)
@@ -166,7 +143,8 @@ class ElectrumGui:
action = wallet.get_action()
# run wizard
if action is not None:
- wallet = self.run_wizard(storage, action)
+ wizard = InstallWizard(self.config, self.network, storage)
+ wallet = wizard.run(action)
# keep current wallet
if not wallet:
return
@@ -180,7 +158,6 @@ class ElectrumGui:
return os.path.dirname(os.path.abspath(self.config.get_wallet_path()))
def new_wallet(self):
- import installwizard
wallet_folder = self.get_wallet_folder()
i = 1
while True:
@@ -197,11 +174,8 @@ class ElectrumGui:
if storage.file_exists:
QMessageBox.critical(None, "Error", _("File exists"))
return
- wizard = installwizard.InstallWizard(self.config, self.network, storage, self.app)
- action, wallet_type = wizard.restore_or_create()
- if not action:
- return
- wallet = wizard.run(action, wallet_type)
+ wizard = InstallWizard(self.config, self.network, storage)
+ wallet = wizard.run('new')
if wallet:
self.new_window(full_path)
diff --git a/gui/qt/installwizard.py b/gui/qt/installwizard.py
@@ -64,9 +64,8 @@ class CosignWidget(QWidget):
class InstallWizard(QDialog):
- def __init__(self, config, network, storage, app):
+ def __init__(self, config, network, storage):
QDialog.__init__(self)
- self.app = app
self.config = config
self.network = network
self.storage = storage
@@ -400,24 +399,6 @@ class InstallWizard(QDialog):
wallet_type = '%dof%d'%(m,n)
return wallet_type
-
- def question(self, msg, yes_label=_('OK'), no_label=_('Cancel'), icon=None):
- vbox = QVBoxLayout()
- self.set_layout(vbox)
- if icon:
- logo = QLabel()
- logo.setPixmap(icon)
- vbox.addWidget(logo)
- label = QLabel(msg)
- label.setWordWrap(True)
- vbox.addWidget(label)
- vbox.addStretch(1)
- vbox.addLayout(Buttons(CancelButton(self, no_label), OkButton(self, yes_label)))
- if not self.exec_():
- return None
- return True
-
-
def show_seed(self, seed, sid):
vbox = seed_dialog.show_seed_box_msg(seed, sid)
vbox.addLayout(Buttons(CancelButton(self), OkButton(self, _("Next"))))
@@ -432,9 +413,32 @@ class InstallWizard(QDialog):
self.set_layout( make_password_dialog(self, None, msg) )
return run_password_dialog(self, None, self)[2]
+ def run(self, action):
+ if self.storage.file_exists and action != 'new':
+ path = self.storage.path
+ msg = _("The file '%s' contains an incompletely created wallet.\n"
+ "Do you want to complete its creation now?") % path
+ if not question(msg):
+ if question(_("Do you want to delete '%s'?") % path):
+ os.remove(path)
+ QMessageBox.information(self, _('Warning'),
+ _('The file was removed'), _('OK'))
+ return
+ return
+ self.show()
+ if action == 'new':
+ action, wallet_type = self.restore_or_create()
+ else:
+ wallet_type = None
+ try:
+ wallet = self.run_wallet_type(action, wallet_type)
+ except BaseException as e:
+ traceback.print_exc(file=sys.stdout)
+ QMessageBox.information(None, _('Error'), str(e), _('OK'))
+ return
+ return wallet
- def run(self, action, wallet_type):
-
+ def run_wallet_type(self, action, wallet_type):
if action in ['create', 'restore']:
if wallet_type == 'multisig':
wallet_type = self.multisig_choice()