66from cryptography .fernet import InvalidToken
77from kivy import Config , require as kivy_require
88from kivy .lang import Builder
9- from kivy .properties import ObjectProperty , StringProperty
9+ from kivy .properties import ObjectProperty , StringProperty , ListProperty
1010from kivy .uix .boxlayout import BoxLayout
1111from kivymd .app import MDApp
1212from kivymd .uix .button import MDRectangleFlatIconButton , MDRaisedButton , MDFillRoundFlatIconButton , \
2222
2323class SimpleDialog :
2424 """Simple dialogs."""
25+
2526 def __init__ (self , title , text , alert_text = 'OK' , ** kwargs ):
2627 super ().__init__ (** kwargs )
2728 self .title = title
@@ -62,14 +63,16 @@ def change_screen(self, name):
6263
6364class PyPassword (MDApp ):
6465 """Main application wrapper."""
66+
6567 def __init__ (self , ** kwargs ):
6668 super ().__init__ (** kwargs )
67-
69+ self .theme_cls .primary_palette = 'Indigo'
70+ self .theme_cls .theme_style = 'Dark'
71+ self .text_color_hex = 'ffffff'
6872 self .passwords = []
69-
7073 self .info = {
7174 'name' : 'Python Password' ,
72- 'version' : '0.2.2 ' ,
75+ 'version' : '0.2.3 ' ,
7376 'author' : 'Jakub Suchenek' ,
7477 'github' : 'https://github.com/AnonymousX86/Python-Password' ,
7578 'faq' : 'https://github.com/AnonymousX86/Python-Password/blob/master/docs/FAQ.md' ,
@@ -78,16 +81,18 @@ def __init__(self, **kwargs):
7881 'rd_party' : 'UPX, Kivy and KivyMD'
7982 }
8083
84+ # It has to be outside ``__init__``
85+ text_color_hsl = ListProperty ([1 , 1 , 1 , 1 ])
86+
8187 def build (self ):
82- self .theme_cls .primary_palette = 'Indigo'
83- self .theme_cls .theme_style = 'Light'
8488 with open (f'kv_templates{ sep } PyPassword.kv' , encoding = 'utf8' ) as fd :
8589 kv = Builder .load_string (fd .read ())
8690 return kv
8791
8892 def on_start (self ):
8993 self .update_passwords_list ()
9094 self .masters_ok ()
95+ # self.switch_theme()
9196
9297 # ================================
9398 # Information
@@ -96,7 +101,7 @@ def on_start(self):
96101 def ctx_password (self , instance ):
97102 """Shows dialog with options what to do with password."""
98103 ctx_dialog = MDDialog (
99- title = instance .text .capitalize (),
104+ title = f'[color=# { self . text_color_hex } ] { instance .text .capitalize ()} [/color]' ,
100105 text = 'Choose what do you want to do wth this password.' ,
101106 auto_dismiss = False ,
102107 buttons = [
@@ -128,7 +133,8 @@ def ctx_password(self, instance):
128133 def detailed_info (self , name ):
129134 """Opens dialog about specific info about program in ``info`` screen."""
130135 info_dialog = MDDialog (
131- title = name .capitalize () if name != 'rd_party' else '3rd party software' ,
136+ title = f'[color={ self .text_color_hex } ]' +
137+ (name .capitalize () if name != 'rd_party' else '3rd party software' ) + '[/color]' ,
132138 text = self .info [name ],
133139 auto_dismiss = False ,
134140 buttons = [
@@ -138,8 +144,8 @@ def detailed_info(self, name):
138144 text = 'Freepik' , icon = 'web' ,
139145 on_release = lambda x :
140146 self .open_url ('https://www.freepik.com/' )
141- ) if name == 'icon' else None ,
142- ]
147+ ) if name == 'icon' else None
148+ ]
143149 )
144150 info_dialog .open ()
145151
@@ -488,13 +494,22 @@ def update_passwords_list(self):
488494 # Misc
489495 # ================================
490496
491- def switch_theme (self ):
492- current = self .theme_cls .theme_style
493- if current == 'Light' :
494- set_to = 'Dark'
497+ def switch_theme (self , force = None ):
498+ if force is not None :
499+ self .theme_cls .theme_style = force
500+
501+ elif self .theme_cls .theme_style == 'Light' :
502+ self .theme_cls .theme_style = 'Dark'
503+ self .text_color_hex = 'ffffff'
504+ self .text_color_hsl = (1 , 1 , 1 , 1 )
505+
506+ elif self .theme_cls .theme_style == 'Dark' :
507+ self .theme_cls .theme_style = 'Light'
508+ self .text_color_hex = '111111'
509+ self .text_color_hsl = (.06 , .06 , .06 , 1 )
510+
495511 else :
496- set_to = 'Light'
497- self .theme_cls .theme_style = set_to
512+ raise NameError ('No theme found' )
498513
499514 def open_url (self , url ):
500515 open_new_tab (url )
@@ -523,7 +538,7 @@ def validate_input(self, instance, length):
523538
524539 Config .set ('kivy' , 'log_dir' , appdata (f'.{ sep } logs{ sep } ' ))
525540 Config .set ('kivy' , 'log_enable' , 1 )
526- Config .set ('kivy' , 'log_level' , 'debug ' )
541+ Config .set ('kivy' , 'log_level' , 'warning ' )
527542 Config .set ('kivy' , 'log_maxfiles' , 10 )
528543
529544 Config .write ()
0 commit comments