@@ -196,13 +196,19 @@ def field_btn(self) -> None:
196196
197197 loc = QLineEdit .ActionPosition .TrailingPosition
198198 self .action_current_password_show = self .ui .current_password .addAction (icon_visibility , loc )
199- self .action_current_password_show .triggered .connect (self .act_current_password_show )
200-
201199 self .action_new_password_show = self .ui .new_password .addAction (icon_visibility , loc )
202- self .action_new_password_show .triggered .connect (self .act_new_password_show )
203-
204200 self .action_repeat_password_show = self .ui .repeat_password .addAction (icon_visibility , loc )
205- self .action_repeat_password_show .triggered .connect (self .act_repeat_password_show )
201+
202+ for field , action in [
203+ (self .ui .current_password , self .action_current_password_show ),
204+ (self .ui .new_password , self .action_new_password_show ),
205+ (self .ui .repeat_password , self .action_repeat_password_show ),
206+ ]:
207+ action .triggered .connect (
208+ lambda f = field , a = action : self ._set_password_visibility (
209+ f , a , f .echoMode () == QLineEdit .EchoMode .Password
210+ )
211+ )
206212
207213 self .show_current_password_check = self .ui .current_password .addAction (icon_check , loc )
208214 self .show_current_password_false = self .ui .current_password .addAction (icon_false , loc )
@@ -388,30 +394,11 @@ def reset_action(self) -> None:
388394
389395 def _set_password_visibility (self , field : QLineEdit , action : QAction , show : bool ) -> None :
390396 icon = SHOW_ICON if show else HIDE_ICON
391- mode = QLineEdit .Normal if show else QLineEdit .Password # type: ignore [attr-defined]
397+ mode = QLineEdit .EchoMode . Normal if show else QLineEdit .EchoMode . Password
392398 field .setEchoMode (mode )
393399 action .setIcon (icon )
394400
395- def act_current_password_show (self ) -> None :
396- show = self .ui .current_password .echoMode () == QLineEdit .Password # type: ignore [attr-defined]
397- self ._set_password_visibility (self .ui .current_password , self .action_current_password_show , show )
398-
399- def act_new_password_show (self ) -> None :
400- show = self .ui .new_password .echoMode () == QLineEdit .Password # type: ignore [attr-defined]
401- self ._set_password_visibility (self .ui .new_password , self .action_new_password_show , show )
402-
403- def act_repeat_password_show (self ) -> None :
404- show = self .ui .repeat_password .echoMode () == QLineEdit .Password # type: ignore [attr-defined]
405- self ._set_password_visibility (self .ui .repeat_password , self .action_repeat_password_show , show )
406-
407- def set_current_password_show (self , show : bool = True ) -> None :
408- self ._set_password_visibility (self .ui .current_password , self .action_current_password_show , show )
409-
410- def set_new_password_show (self , show : bool = True ) -> None :
411- self ._set_password_visibility (self .ui .new_password , self .action_new_password_show , show )
412401
413- def set_repeat_password_show (self , show : bool = True ) -> None :
414- self ._set_password_visibility (self .ui .repeat_password , self .action_repeat_password_show , show )
415402
416403 def set_device_data (
417404 self , path : str , uuid : str , version : str , variant : str , init_status : str
0 commit comments