electrum

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

commit 7e6bd2eb8c139fe3711fe84a4fa87e917bbbf097
parent 9aa812026a62d22a230746c87a75284afc8d6af0
Author: ThomasV <thomasv@gitorious>
Date:   Fri,  3 Apr 2015 13:10:43 +0200

give user the option to remove incomplete wallet

Diffstat:
Mgui/qt/__init__.py | 31+++++++++++++++++++++----------
Mgui/qt/main_window.py | 14+-------------
Mgui/qt/util.py | 3++-
3 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/gui/qt/__init__.py b/gui/qt/__init__.py @@ -142,10 +142,29 @@ class ElectrumGui: qtVersion = qVersion() return int(qtVersion[0]) >= 4 and int(qtVersion[2]) >= 7 - def set_url(self, uri): self.current_window.pay_from_URI(uri) + 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 util.question(msg): + if util.question(_("Do you want to delete '%s'?")%storage.path): + os.remove(storage.path) + QMessageBox.information(None, _('Warning'), _('The file was removed'), _('OK')) + return + return + wizard = installwizard.InstallWizard(self.config, self.network, storage) + wizard.show() + try: + wallet = wizard.run(action) + except BaseException as e: + traceback.print_exc(file=sys.stdout) + QMessageBox.information(None, _('Error'), str(e), _('OK')) + return + return wallet def main(self, url): @@ -171,15 +190,7 @@ class ElectrumGui: action = 'new' if action is not None: - import installwizard - wizard = installwizard.InstallWizard(self.config, self.network, storage) - wizard.show() - try: - wallet = wizard.run(action) - except BaseException as e: - traceback.print_exc(file=sys.stdout) - QMessageBox.information(None, _('Error'), str(e), _('OK')) - return + wallet = self.run_wizard(storage, action) if not wallet: return else: diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -268,22 +268,10 @@ class ElectrumWindow(QMainWindow): QMessageBox.warning(None, _('Warning'), str(e), _('OK')) return action = wallet.get_action() - # ask for confirmation - if action is not None: - if not self.question(_("This file contains an incompletely created wallet.\nDo you want to complete its creation now?")): - return self.hide() # run wizard if action is not None: - import installwizard - wizard = installwizard.InstallWizard(self.config, self.network, storage) - wizard.show() - try: - wallet = wizard.run(action) - except BaseException as e: - traceback.print_exc(file=sys.stdout) - QMessageBox.information(None, _('Error'), str(e), _('OK')) - return + wallet = self.gui_object.run_wizard(storage, action) if not wallet: self.show() return diff --git a/gui/qt/util.py b/gui/qt/util.py @@ -187,7 +187,8 @@ def text_dialog(parent, title, label, ok_label, default=None): if dialog.exec_(): return unicode(txt.toPlainText()) - +def question(msg): + return QMessageBox.question(None, _('Message'), msg, QMessageBox.Yes | QMessageBox.No, QMessageBox.No) == QMessageBox.Yes def address_field(addresses): hbox = QHBoxLayout()