fix #2452
This commit is contained in:
parent
064b59c65e
commit
2a53e85e8d
|
@ -147,63 +147,73 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
|
||||||
|
|
||||||
def run_and_get_wallet(self):
|
def run_and_get_wallet(self):
|
||||||
|
|
||||||
def on_filename():
|
|
||||||
wallet_folder = os.path.dirname(self.storage.path)
|
|
||||||
path = unicode(QFileDialog.getOpenFileName(self, "Select your wallet file", wallet_folder))
|
|
||||||
if path:
|
|
||||||
self.name_e.setText(path)
|
|
||||||
self.storage = WalletStorage(path)
|
|
||||||
update_layout()
|
|
||||||
def update_layout():
|
|
||||||
name = os.path.basename(self.storage.path)
|
|
||||||
vbox = QVBoxLayout()
|
vbox = QVBoxLayout()
|
||||||
hbox = QHBoxLayout()
|
hbox = QHBoxLayout()
|
||||||
hbox.addWidget(QLabel(_('Wallet') + ':'))
|
hbox.addWidget(QLabel(_('Wallet') + ':'))
|
||||||
self.name_e = QLineEdit(text=name)
|
self.name_e = QLineEdit()
|
||||||
hbox.addWidget(self.name_e)
|
hbox.addWidget(self.name_e)
|
||||||
button = QPushButton(_('Choose...'))
|
button = QPushButton(_('Choose...'))
|
||||||
button.clicked.connect(on_filename)
|
|
||||||
hbox.addWidget(button)
|
hbox.addWidget(button)
|
||||||
vbox.addLayout(hbox)
|
vbox.addLayout(hbox)
|
||||||
self.pw_e = None
|
|
||||||
|
|
||||||
if not self.storage.file_exists():
|
self.msg_label = QLabel('')
|
||||||
msg = _("This file does not exist.") + '\n' \
|
vbox.addWidget(self.msg_label)
|
||||||
+ _("Press 'Next' to create this wallet, or chose another file.")
|
|
||||||
vbox.addWidget(QLabel(msg))
|
|
||||||
|
|
||||||
elif self.storage.file_exists() and self.storage.is_encrypted():
|
|
||||||
msg = _("This file is encrypted.") + '\n' + _('Enter your password or choose another file.')
|
|
||||||
vbox.addWidget(QLabel(msg))
|
|
||||||
hbox2 = QHBoxLayout()
|
hbox2 = QHBoxLayout()
|
||||||
self.pw_e = QLineEdit('', self)
|
self.pw_e = QLineEdit('', self)
|
||||||
self.pw_e.setFixedWidth(150)
|
self.pw_e.setFixedWidth(150)
|
||||||
self.pw_e.setEchoMode(2)
|
self.pw_e.setEchoMode(2)
|
||||||
hbox2.addWidget(QLabel(_('Password') + ':'))
|
self.pw_label = QLabel(_('Password') + ':')
|
||||||
|
hbox2.addWidget(self.pw_label)
|
||||||
hbox2.addWidget(self.pw_e)
|
hbox2.addWidget(self.pw_e)
|
||||||
hbox2.addStretch()
|
hbox2.addStretch()
|
||||||
vbox.addLayout(hbox2)
|
vbox.addLayout(hbox2)
|
||||||
|
self.set_layout(vbox, title=_('Electrum wallet'))
|
||||||
|
|
||||||
|
def on_choose():
|
||||||
|
wallet_folder = os.path.dirname(self.storage.path)
|
||||||
|
path = unicode(QFileDialog.getOpenFileName(self, "Select your wallet file", wallet_folder))
|
||||||
|
if path:
|
||||||
|
self.name_e.setText(path)
|
||||||
|
|
||||||
|
def on_filename(path):
|
||||||
|
try:
|
||||||
|
self.storage = WalletStorage(unicode(path))
|
||||||
|
except IOError:
|
||||||
|
self.storage = None
|
||||||
|
if self.storage:
|
||||||
|
if not self.storage.file_exists():
|
||||||
|
msg =_("This file does not exist.") + '\n' \
|
||||||
|
+ _("Press 'Next' to create this wallet, or choose another file.")
|
||||||
|
pw = False
|
||||||
|
elif self.storage.file_exists() and self.storage.is_encrypted():
|
||||||
|
msg = _("This file is encrypted.") + '\n' + _('Enter your password or choose another file.')
|
||||||
|
pw = True
|
||||||
else:
|
else:
|
||||||
msg = _("Press 'Next' to open this wallet.")
|
msg = _("Press 'Next' to open this wallet.")
|
||||||
vbox.addWidget(QLabel(msg))
|
pw = False
|
||||||
|
else:
|
||||||
self.set_layout(vbox, title=_('Electrum wallet'))
|
msg = _('Cannot read file')
|
||||||
if self.pw_e:
|
pw = False
|
||||||
|
self.msg_label.setText(msg)
|
||||||
|
if pw:
|
||||||
|
self.pw_label.show()
|
||||||
self.pw_e.show()
|
self.pw_e.show()
|
||||||
self.pw_e.setFocus()
|
self.pw_e.setFocus()
|
||||||
|
else:
|
||||||
|
self.pw_label.hide()
|
||||||
|
self.pw_e.hide()
|
||||||
|
|
||||||
|
button.clicked.connect(on_choose)
|
||||||
|
self.name_e.textChanged.connect(on_filename)
|
||||||
|
self.name_e.setText(os.path.basename(self.storage.path))
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
update_layout()
|
|
||||||
|
|
||||||
if self.storage.file_exists() and not self.storage.is_encrypted():
|
if self.storage.file_exists() and not self.storage.is_encrypted():
|
||||||
break
|
break
|
||||||
|
|
||||||
if not self.loop.exec_():
|
if not self.loop.exec_():
|
||||||
return
|
return
|
||||||
|
|
||||||
if not self.storage.file_exists():
|
if not self.storage.file_exists():
|
||||||
break
|
break
|
||||||
|
|
||||||
if self.storage.file_exists() and self.storage.is_encrypted():
|
if self.storage.file_exists() and self.storage.is_encrypted():
|
||||||
password = unicode(self.pw_e.text())
|
password = unicode(self.pw_e.text())
|
||||||
try:
|
try:
|
||||||
|
@ -217,7 +227,6 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
|
||||||
QMessageBox.information(None, _('Error'), str(e), _('OK'))
|
QMessageBox.information(None, _('Error'), str(e), _('OK'))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
path = self.storage.path
|
path = self.storage.path
|
||||||
if self.storage.requires_split():
|
if self.storage.requires_split():
|
||||||
self.hide()
|
self.hide()
|
||||||
|
|
Loading…
Reference in New Issue