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 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()
|
||||
hbox = QHBoxLayout()
|
||||
hbox.addWidget(QLabel(_('Wallet') + ':'))
|
||||
self.name_e = QLineEdit(text=name)
|
||||
self.name_e = QLineEdit()
|
||||
hbox.addWidget(self.name_e)
|
||||
button = QPushButton(_('Choose...'))
|
||||
button.clicked.connect(on_filename)
|
||||
hbox.addWidget(button)
|
||||
vbox.addLayout(hbox)
|
||||
self.pw_e = None
|
||||
|
||||
if not self.storage.file_exists():
|
||||
msg = _("This file does not exist.") + '\n' \
|
||||
+ _("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))
|
||||
self.msg_label = QLabel('')
|
||||
vbox.addWidget(self.msg_label)
|
||||
hbox2 = QHBoxLayout()
|
||||
self.pw_e = QLineEdit('', self)
|
||||
self.pw_e.setFixedWidth(150)
|
||||
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.addStretch()
|
||||
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:
|
||||
msg = _("Press 'Next' to open this wallet.")
|
||||
vbox.addWidget(QLabel(msg))
|
||||
|
||||
self.set_layout(vbox, title=_('Electrum wallet'))
|
||||
if self.pw_e:
|
||||
pw = False
|
||||
else:
|
||||
msg = _('Cannot read file')
|
||||
pw = False
|
||||
self.msg_label.setText(msg)
|
||||
if pw:
|
||||
self.pw_label.show()
|
||||
self.pw_e.show()
|
||||
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:
|
||||
update_layout()
|
||||
|
||||
if self.storage.file_exists() and not self.storage.is_encrypted():
|
||||
break
|
||||
|
||||
if not self.loop.exec_():
|
||||
return
|
||||
|
||||
if not self.storage.file_exists():
|
||||
break
|
||||
|
||||
if self.storage.file_exists() and self.storage.is_encrypted():
|
||||
password = unicode(self.pw_e.text())
|
||||
try:
|
||||
|
@ -217,7 +227,6 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
|
|||
QMessageBox.information(None, _('Error'), str(e), _('OK'))
|
||||
return
|
||||
|
||||
|
||||
path = self.storage.path
|
||||
if self.storage.requires_split():
|
||||
self.hide()
|
||||
|
|
Loading…
Reference in New Issue