qt wizard: minor clean-up
This commit is contained in:
@@ -221,9 +221,8 @@ class ElectrumGui(PrintError):
|
|||||||
wallet = self.daemon.load_wallet(path, None)
|
wallet = self.daemon.load_wallet(path, None)
|
||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
traceback.print_exc(file=sys.stdout)
|
traceback.print_exc(file=sys.stdout)
|
||||||
d = QMessageBox(QMessageBox.Warning, _('Error'),
|
QMessageBox.warning(None, _('Error'),
|
||||||
_('Cannot load wallet') + ' (1):\n' + str(e))
|
_('Cannot load wallet') + ' (1):\n' + str(e))
|
||||||
d.exec_()
|
|
||||||
# if app is starting, still let wizard to appear
|
# if app is starting, still let wizard to appear
|
||||||
if not app_is_starting:
|
if not app_is_starting:
|
||||||
return
|
return
|
||||||
@@ -233,29 +232,27 @@ class ElectrumGui(PrintError):
|
|||||||
return
|
return
|
||||||
# create or raise window
|
# create or raise window
|
||||||
try:
|
try:
|
||||||
for w in self.windows:
|
for window in self.windows:
|
||||||
if w.wallet.storage.path == wallet.storage.path:
|
if window.wallet.storage.path == wallet.storage.path:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
w = self._create_window_for_wallet(wallet)
|
window = self._create_window_for_wallet(wallet)
|
||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
traceback.print_exc(file=sys.stdout)
|
traceback.print_exc(file=sys.stdout)
|
||||||
d = QMessageBox(QMessageBox.Warning, _('Error'),
|
QMessageBox.warning(None, _('Error'),
|
||||||
_('Cannot create window for wallet') + ':\n' + str(e))
|
_('Cannot create window for wallet') + ':\n' + str(e))
|
||||||
d.exec_()
|
|
||||||
if app_is_starting:
|
if app_is_starting:
|
||||||
wallet_dir = os.path.dirname(path)
|
wallet_dir = os.path.dirname(path)
|
||||||
path = os.path.join(wallet_dir, get_new_wallet_name(wallet_dir))
|
path = os.path.join(wallet_dir, get_new_wallet_name(wallet_dir))
|
||||||
self.start_new_window(path, uri)
|
self.start_new_window(path, uri)
|
||||||
return
|
return
|
||||||
if uri:
|
if uri:
|
||||||
w.pay_to_URI(uri)
|
window.pay_to_URI(uri)
|
||||||
w.bring_to_top()
|
window.bring_to_top()
|
||||||
w.setWindowState(w.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive)
|
window.setWindowState(window.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive)
|
||||||
|
|
||||||
# this will activate the window
|
window.activateWindow()
|
||||||
w.activateWindow()
|
return window
|
||||||
return w
|
|
||||||
|
|
||||||
def _start_wizard_to_select_or_create_wallet(self, path) -> Optional[Abstract_Wallet]:
|
def _start_wizard_to_select_or_create_wallet(self, path) -> Optional[Abstract_Wallet]:
|
||||||
wizard = InstallWizard(self.config, self.app, self.plugins)
|
wizard = InstallWizard(self.config, self.app, self.plugins)
|
||||||
@@ -274,9 +271,8 @@ class ElectrumGui(PrintError):
|
|||||||
return e.wallet
|
return e.wallet
|
||||||
except (WalletFileException, BitcoinException) as e:
|
except (WalletFileException, BitcoinException) as e:
|
||||||
traceback.print_exc(file=sys.stderr)
|
traceback.print_exc(file=sys.stderr)
|
||||||
d = QMessageBox(QMessageBox.Warning, _('Error'),
|
QMessageBox.warning(None, _('Error'),
|
||||||
_('Cannot load wallet') + ' (2):\n' + str(e))
|
_('Cannot load wallet') + ' (2):\n' + str(e))
|
||||||
d.exec_()
|
|
||||||
return
|
return
|
||||||
finally:
|
finally:
|
||||||
wizard.terminate()
|
wizard.terminate()
|
||||||
|
|||||||
@@ -212,32 +212,28 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
|
|||||||
traceback.print_exc(file=sys.stderr)
|
traceback.print_exc(file=sys.stderr)
|
||||||
self.temp_storage = None
|
self.temp_storage = None
|
||||||
self.next_button.setEnabled(False)
|
self.next_button.setEnabled(False)
|
||||||
|
user_needs_to_enter_password = False
|
||||||
if self.temp_storage:
|
if self.temp_storage:
|
||||||
if not self.temp_storage.file_exists():
|
if not self.temp_storage.file_exists():
|
||||||
msg =_("This file does not exist.") + '\n' \
|
msg =_("This file does not exist.") + '\n' \
|
||||||
+ _("Press 'Next' to create this wallet, or choose another file.")
|
+ _("Press 'Next' to create this wallet, or choose another file.")
|
||||||
pw = False
|
|
||||||
elif not wallet_from_memory:
|
elif not wallet_from_memory:
|
||||||
if self.temp_storage.is_encrypted_with_user_pw():
|
if self.temp_storage.is_encrypted_with_user_pw():
|
||||||
msg = _("This file is encrypted with a password.") + '\n' \
|
msg = _("This file is encrypted with a password.") + '\n' \
|
||||||
+ _('Enter your password or choose another file.')
|
+ _('Enter your password or choose another file.')
|
||||||
pw = True
|
user_needs_to_enter_password = True
|
||||||
elif self.temp_storage.is_encrypted_with_hw_device():
|
elif self.temp_storage.is_encrypted_with_hw_device():
|
||||||
msg = _("This file is encrypted using a hardware device.") + '\n' \
|
msg = _("This file is encrypted using a hardware device.") + '\n' \
|
||||||
+ _("Press 'Next' to choose device to decrypt.")
|
+ _("Press 'Next' to choose device to decrypt.")
|
||||||
pw = False
|
|
||||||
else:
|
else:
|
||||||
msg = _("Press 'Next' to open this wallet.")
|
msg = _("Press 'Next' to open this wallet.")
|
||||||
pw = False
|
|
||||||
else:
|
else:
|
||||||
msg = _("This file is already open in memory.") + "\n" \
|
msg = _("This file is already open in memory.") + "\n" \
|
||||||
+ _("Press 'Next' to create/focus window.")
|
+ _("Press 'Next' to create/focus window.")
|
||||||
pw = False
|
|
||||||
else:
|
else:
|
||||||
msg = _('Cannot read file')
|
msg = _('Cannot read file')
|
||||||
pw = False
|
|
||||||
self.msg_label.setText(msg)
|
self.msg_label.setText(msg)
|
||||||
if pw:
|
if user_needs_to_enter_password:
|
||||||
self.pw_label.show()
|
self.pw_label.show()
|
||||||
self.pw_e.show()
|
self.pw_e.show()
|
||||||
self.pw_e.setFocus()
|
self.pw_e.setFocus()
|
||||||
|
|||||||
Reference in New Issue
Block a user