diff --git a/securedrop_client/gui/widgets.py b/securedrop_client/gui/widgets.py index 4d45c9e38c..b91d7ddd07 100644 --- a/securedrop_client/gui/widgets.py +++ b/securedrop_client/gui/widgets.py @@ -1369,6 +1369,10 @@ def __init__(self, parent): self.password_field = QLineEdit() self.password_field.setEchoMode(QLineEdit.Password) + self.togglepasswordAction = self.password_field.addAction(QIcon(load_icon("eye_visible.svg")), QLineEdit.TrailingPosition) + self.togglepasswordAction.triggered.connect(self.on_toggle_password_Action) + self.password_shown = False + self.tfa_label = QLabel(_('Two-Factor Code')) self.tfa_field = QLineEdit() @@ -1403,6 +1407,19 @@ def __init__(self, parent): layout.addStretch() layout.addWidget(application_version) + def on_toggle_password_Action(self): + if not self.password_shown: + self.password_field.setEchoMode(QLineEdit.Normal) + self.password_shown = True + icon = QIcon(load_icon("eye_hidden.svg")) + self.togglepasswordAction.setIcon(icon) + else: + self.password_field.setEchoMode(QLineEdit.Password) + self.password_shown = False + icon = QIcon(load_icon("eye_visible.svg")) + self.togglepasswordAction.setIcon(icon) + + def closeEvent(self, event): """ Only exit the application when the main window is not visible. diff --git a/securedrop_client/resources/images/eye_hidden.svg b/securedrop_client/resources/images/eye_hidden.svg new file mode 100644 index 0000000000..f4399de709 --- /dev/null +++ b/securedrop_client/resources/images/eye_hidden.svg @@ -0,0 +1,20 @@ + + + + Group 3 + Created with Sketch. + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/securedrop_client/resources/images/eye_visible.svg b/securedrop_client/resources/images/eye_visible.svg new file mode 100644 index 0000000000..08f11efdfb --- /dev/null +++ b/securedrop_client/resources/images/eye_visible.svg @@ -0,0 +1,11 @@ + + + + Fill 1 + Created with Sketch. + + + + + +