commit 098af027890c8450ee0327a9de63f006a4243991
parent 58a0a9b160e811ff4b1c19c05683cb4c03287977
Author: ThomasV <thomasv@electrum.org>
Date: Mon, 17 Feb 2020 09:16:29 +0100
kivy: pass message to password_dialog (follow-up d9172ade714e659d87614e0376e53d8bad155159)
Diffstat:
2 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/electrum/gui/kivy/main_window.py b/electrum/gui/kivy/main_window.py
@@ -1112,10 +1112,15 @@ class ElectrumWindow(App):
def on_fee(self, event, *arg):
self.fee_status = self.electrum_config.get_fee_status()
- def protected(self, f, args):
+ def protected(self, msg, f, args):
if self.electrum_config.get('pin_code'):
on_success = lambda pw: f(*(args + (self.password,)))
- self.password_dialog(check_password=self.check_pin_code, on_success=on_success, on_failure=lambda: None, is_password=False)
+ self.password_dialog(
+ message = msg,
+ check_password=self.check_pin_code,
+ on_success=on_success,
+ on_failure=lambda: None,
+ is_password=False)
else:
f(*(args + (self.password,)))
@@ -1177,7 +1182,7 @@ class ElectrumWindow(App):
self.load_wallet_by_name(new_path)
def show_seed(self, label):
- self.protected(self._show_seed, (label,))
+ self.protected(_("Enter PIN code to display your seed"), self._show_seed, (label,))
def _show_seed(self, label, password):
if self.wallet.has_password() and password is None:
@@ -1196,31 +1201,23 @@ class ElectrumWindow(App):
if pin != self.electrum_config.get('pin_code'):
raise InvalidPassword
- def password_dialog(self, *, check_password: Callable = None,
- on_success: Callable = None, on_failure: Callable = None,
- is_password=True):
+ def password_dialog(self, **kwargs):
if self._password_dialog is None:
self._password_dialog = PasswordDialog()
- self._password_dialog.init(
- self, check_password = check_password,
- on_success=on_success, on_failure=on_failure,
- is_password=is_password)
+ self._password_dialog.init(self, **kwargs)
self._password_dialog.open()
def change_password(self, cb):
- if self._password_dialog is None:
- self._password_dialog = PasswordDialog()
def on_success(old_password, new_password):
self.wallet.update_password(old_password, new_password)
self.password = new_password
self.show_info(_("Your password was updated"))
on_failure = lambda: self.show_error(_("Password not updated"))
- self._password_dialog.init(
- self, check_password = self.wallet.check_password,
+ self.password_dialog(
+ check_password = self.wallet.check_password,
on_success=on_success, on_failure=on_failure,
is_change=True, is_password=True,
has_password=self.wallet.has_password())
- self._password_dialog.open()
def change_pin_code(self, cb):
if self._password_dialog is None:
diff --git a/electrum/gui/kivy/uix/dialogs/password_dialog.py b/electrum/gui/kivy/uix/dialogs/password_dialog.py
@@ -115,11 +115,12 @@ class PasswordDialog(Factory.Popup):
check_password = None,
on_success: Callable = None, on_failure: Callable = None,
is_change: bool = False,
- is_password: bool = False,
- has_password: bool = False):
+ is_password: bool = True,
+ has_password: bool = False,
+ message: str = ''):
self.app = app
self.pw_check = check_password
- self.message = ''
+ self.message = message
self.on_success = on_success
self.on_failure = on_failure
self.success = False
@@ -134,7 +135,7 @@ class PasswordDialog(Factory.Popup):
def update_screen(self):
self.ids.kb.password = ''
self.ids.textinput_generic_password.text = ''
- if self.level == 0:
+ if self.level == 0 and self.message == '':
self.message = _('Enter your password') if self.is_generic else _('Enter your PIN')
elif self.level == 1:
self.message = _('Enter new password') if self.is_generic else _('Enter new PIN')