From bfc05ba96e4ae0f50ce599eab0cb8f3d337492d7 Mon Sep 17 00:00:00 2001 From: Marcus Hoffmann Date: Sat, 6 Jan 2024 19:29:45 +0100 Subject: [PATCH] LoginPage: add button to show/hide the password --- resources/icons/ui/eye-hide.svg | 3 +++ resources/icons/ui/eye-show.svg | 1 + resources/qml/pages/LoginPage.qml | 37 ++++++++++++++++++++++++------- resources/res.qrc | 2 ++ 4 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 resources/icons/ui/eye-hide.svg create mode 100644 resources/icons/ui/eye-show.svg diff --git a/resources/icons/ui/eye-hide.svg b/resources/icons/ui/eye-hide.svg new file mode 100644 index 00000000..05d26d96 --- /dev/null +++ b/resources/icons/ui/eye-hide.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/resources/icons/ui/eye-show.svg b/resources/icons/ui/eye-show.svg new file mode 100644 index 00000000..c4dabfa5 --- /dev/null +++ b/resources/icons/ui/eye-show.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/qml/pages/LoginPage.qml b/resources/qml/pages/LoginPage.qml index 86188918..8607b8dc 100644 --- a/resources/qml/pages/LoginPage.qml +++ b/resources/qml/pages/LoginPage.qml @@ -82,15 +82,36 @@ Item { visible: text wrapMode: TextEdit.Wrap } + RowLayout { - MatrixTextField { - id: passwordLabel - Layout.fillWidth: true - label: qsTr("Password") - echoMode: TextInput.Password - ToolTip.text: qsTr("Your password.") - visible: login.passwordSupported - Keys.forwardTo: [pwBtn, ssoRepeater] + MatrixTextField { + id: passwordLabel + Layout.fillWidth: true + label: qsTr("Password") + echoMode: TextInput.Password + ToolTip.text: qsTr("Your password.") + visible: login.passwordSupported + Keys.forwardTo: [pwBtn, ssoRepeater] + } + + ImageButton { + id: showPwButton + Layout.preferredWidth: 30 + Layout.preferredHeight: 30 + visible: login.passwordSupported + Layout.alignment: Qt.AlignBottom + image: passwordLabel.echoMode === TextInput.Password ? ":/icons/icons/ui/eye-show.svg" : ":/icons/icons/ui/eye-hide.svg" + ToolTip.visible: hovered + ToolTip.text: qsTr("Show/Hide Password") + onClicked: { + if (passwordLabel.echoMode === TextInput.Normal) { + passwordLabel.echoMode = TextInput.Password + } + else { + passwordLabel.echoMode = TextInput.Normal + } + } + } } MatrixTextField { diff --git a/resources/res.qrc b/resources/res.qrc index fb857d4a..642bc220 100644 --- a/resources/res.qrc +++ b/resources/res.qrc @@ -18,6 +18,8 @@ icons/ui/edit.svg icons/ui/end-call.svg icons/ui/expanded.svg + icons/ui/eye-hide.svg + icons/ui/eye-show.svg icons/ui/go-to.svg icons/ui/image-failed.svg icons/ui/image.svg