Skip to content

Commit d29119b

Browse files
committed
Dialogs are now more readable
1 parent ee19fba commit d29119b

File tree

1 file changed

+34
-20
lines changed

1 file changed

+34
-20
lines changed

python_password/PyPassword.py

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -185,18 +185,25 @@ def add_password(self):
185185
[password_alias, encrypt(password_value)]
186186
)
187187

188-
except sqlite3.IntegrityError:
189-
Logger.info(f'Passwords: Tried to save "{password_alias}" but already exists.')
190-
result_dialog = CustomDialog(
191-
title='Whoops!',
192-
text='That password already exists.'
193-
).alert()
188+
except sqlite3.IntegrityError:
189+
Logger.info(f'Passwords: Tried to save "{password_alias}" but already exists.')
190+
result_dialog = CustomDialog(
191+
title='Whoops!',
192+
text='That password already exists or not all settings are set.'
193+
).alert()
194+
195+
else:
196+
Logger.info(f'Passwords: Password "{password_alias}" saved.')
197+
result_dialog = CustomDialog(
198+
title='Success!',
199+
text=f'Password "{password_alias}" successfully saved.'
200+
).alert()
194201

195202
else:
196203
Logger.info(f'Passwords: Password "{password_alias}" saved.')
197204
result_dialog = CustomDialog(
198-
title='Success!',
199-
text=f'Password "{password_alias}" successfully saved.'
205+
title='Whoops!',
206+
text='The entered values are too short or invalid.'
200207
).alert()
201208

202209
else:
@@ -341,12 +348,12 @@ def change_alpha(self, preset=None):
341348
else:
342349
password = preset
343350

344-
if len(password) < 6:
345-
result_dialog = CustomDialog(
346-
title='Whoops!',
347-
text='Password should be at least 6 characters long.'
348-
).alert()
349-
password_box.error = True
351+
if len(password) < 6:
352+
result_dialog = CustomDialog(
353+
title='Whoops!',
354+
text='Alpha password should be at least 6 characters long.'
355+
).alert()
356+
password_box.error = True
350357

351358
else:
352359
password_box.error = False
@@ -425,17 +432,24 @@ def change_beta(self, preset=None):
425432
if len(password) < 6:
426433
result_dialog = CustomDialog(
427434
title='Whoops!',
428-
text='Password should be at least 6 characters long.'
435+
text='Beta password should be at least 6 characters long.'
429436
).alert()
430437
password_box.error = True
431438

432439
else:
433440
password_box.error = False
434441
generate_salt(preset=password)
435-
result_dialog = CustomDialog(
442+
result_dialog = MDDialog(
436443
title='Success!',
437-
text='Password successfully saved.'
438-
).alert()
444+
text='Beta password successfully saved.',
445+
auto_dismiss=False,
446+
buttons=[
447+
MDRaisedButton(
448+
text='OK',
449+
on_release=lambda x: self.dismiss_and_back(result_dialog)
450+
)
451+
]
452+
)
439453

440454
password_box.text = ''
441455
result_dialog.open()
@@ -542,7 +556,7 @@ def dismiss_and_back(self, instance, where='passwords'):
542556
def validate_input(self, instance, length):
543557
"""
544558
Checks text input.
545-
:param instance: Which object has to be checked.
559+
:param instance: Which widget has to be checked.
546560
:param length: Minimum length of provided text.
547561
"""
548562
Logger.debug('Called: validate_input')
@@ -568,7 +582,7 @@ def validate_input(self, instance, length):
568582

569583
Config.set('kivy', 'log_dir', appdata(f'.{os.sep}logs{os.sep}'))
570584
Config.set('kivy', 'log_enable', 1)
571-
Config.set('kivy', 'log_level', 'error')
585+
Config.set('kivy', 'log_level', 'warning')
572586
Config.set('kivy', 'log_maxfiles', 10)
573587

574588
Config.write()

0 commit comments

Comments
 (0)