wizard: (qt) add dedicated button to create new wallet
This commit is contained in:
@@ -7,6 +7,7 @@ import sys
|
||||
import threading
|
||||
import traceback
|
||||
from typing import Tuple, List, Callable, NamedTuple, Optional, TYPE_CHECKING
|
||||
from functools import partial
|
||||
|
||||
from PyQt5.QtCore import QRect, QEventLoop, Qt, pyqtSignal
|
||||
from PyQt5.QtGui import QPalette, QPen, QPainter, QPixmap
|
||||
@@ -16,7 +17,7 @@ from PyQt5.QtWidgets import (QWidget, QDialog, QLabel, QHBoxLayout, QMessageBox,
|
||||
|
||||
from electrum.wallet import Wallet, Abstract_Wallet
|
||||
from electrum.storage import WalletStorage, StorageReadWriteError
|
||||
from electrum.util import UserCancelled, InvalidPassword, WalletFileException
|
||||
from electrum.util import UserCancelled, InvalidPassword, WalletFileException, get_new_wallet_name
|
||||
from electrum.base_wizard import BaseWizard, HWD_SETUP_DECRYPT_WALLET, GoBack
|
||||
from electrum.i18n import _
|
||||
|
||||
@@ -191,6 +192,18 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
|
||||
hbox2.addWidget(self.pw_e)
|
||||
hbox2.addStretch()
|
||||
vbox.addLayout(hbox2)
|
||||
|
||||
vbox.addSpacing(50)
|
||||
vbox_create_new = QVBoxLayout()
|
||||
vbox_create_new.addWidget(QLabel(_('Alternatively') + ':'), alignment=Qt.AlignLeft)
|
||||
button_create_new = QPushButton(_('Create New Wallet'))
|
||||
button_create_new.setMinimumWidth(120)
|
||||
vbox_create_new.addWidget(button_create_new, alignment=Qt.AlignLeft)
|
||||
widget_create_new = QWidget()
|
||||
widget_create_new.setLayout(vbox_create_new)
|
||||
vbox_create_new.setContentsMargins(0, 0, 0, 0)
|
||||
vbox.addWidget(widget_create_new)
|
||||
|
||||
self.set_layout(vbox, title=_('Electrum wallet'))
|
||||
|
||||
temp_storage = None # type: Optional[WalletStorage]
|
||||
@@ -240,6 +253,7 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
|
||||
if msg is None:
|
||||
msg = _('Cannot read file')
|
||||
self.msg_label.setText(msg)
|
||||
widget_create_new.setVisible(temp_storage and temp_storage.file_exists())
|
||||
if user_needs_to_enter_password:
|
||||
self.pw_label.show()
|
||||
self.pw_e.show()
|
||||
@@ -249,6 +263,10 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
|
||||
self.pw_e.hide()
|
||||
|
||||
button.clicked.connect(on_choose)
|
||||
button_create_new.clicked.connect(
|
||||
partial(
|
||||
self.name_e.setText,
|
||||
get_new_wallet_name(wallet_folder)))
|
||||
self.name_e.textChanged.connect(on_filename)
|
||||
self.name_e.setText(os.path.basename(path))
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ class WalletStorage(Logger):
|
||||
Logger.__init__(self)
|
||||
self.lock = threading.RLock()
|
||||
self.path = standardize_path(path)
|
||||
self._file_exists = self.path and os.path.exists(self.path)
|
||||
self._file_exists = bool(self.path and os.path.exists(self.path))
|
||||
|
||||
DB_Class = JsonDB
|
||||
self.logger.info(f"wallet path {self.path}")
|
||||
@@ -139,7 +139,7 @@ class WalletStorage(Logger):
|
||||
self.logger.info(f"saved {self.path}")
|
||||
self.db.set_modified(False)
|
||||
|
||||
def file_exists(self):
|
||||
def file_exists(self) -> bool:
|
||||
return self._file_exists
|
||||
|
||||
def is_past_initial_decryption(self):
|
||||
|
||||
Reference in New Issue
Block a user