give user the option to remove incomplete wallet

This commit is contained in:
ThomasV 2015-04-03 13:10:43 +02:00
parent 9aa812026a
commit 7e6bd2eb8c
3 changed files with 24 additions and 24 deletions

View File

@ -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:

View File

@ -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

View File

@ -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()