From 78fa52285f25ebbd68f3318b724fe4bd8c8f726f Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 5 Sep 2018 23:48:21 -0700 Subject: [PATCH] adding show password toggle in textfield --- interface/resources/images/eyeClosed.svg | 5 +++ interface/resources/images/eyeOpen.svg | 4 +++ .../qml/LoginDialog/LinkAccountBody.qml | 36 +++++++++++++++---- 3 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 interface/resources/images/eyeClosed.svg create mode 100644 interface/resources/images/eyeOpen.svg diff --git a/interface/resources/images/eyeClosed.svg b/interface/resources/images/eyeClosed.svg new file mode 100644 index 0000000000..6719471b3d --- /dev/null +++ b/interface/resources/images/eyeClosed.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/interface/resources/images/eyeOpen.svg b/interface/resources/images/eyeOpen.svg new file mode 100644 index 0000000000..ec5ceb5238 --- /dev/null +++ b/interface/resources/images/eyeOpen.svg @@ -0,0 +1,4 @@ + + + + diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 423f6cc73b..c40dff61ee 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -86,7 +86,7 @@ Item { width: 48 height: 48 } - + ShortcutText { id: mainTextContainer anchors { @@ -142,6 +142,7 @@ Item { onLinkActivated: loginDialog.openUrl(link) } + onFocusChanged: { root.text = ""; } @@ -151,7 +152,6 @@ Item { id: passwordField width: parent.width placeholderText: "Password" - echoMode: showPassword.checked ? TextInput.Normal : TextInput.Password activeFocusOnPress: true ShortcutText { @@ -177,12 +177,34 @@ Item { root.isPassword = true; } - Keys.onReturnPressed: linkAccountBody.login() - } + Image { + id: showPasswordImage + x: parent.width - 40 + height: parent.height + width: parent.width - (parent.width - 40) + source: "../../images/eyeOpen.svg" + } - CheckBox { - id: showPassword - text: "Show password" + Rectangle { + z: 10 + x: parent.width - 40 + width: parent.width - (parent.width - 40) + height: parent.height + color: "transparent" + MouseArea { + id: passwordFieldMouseArea + anchors.fill: parent + acceptedButtons: Qt.LeftButton + property bool showPassword: false + onClicked: { + showPassword = !showPassword; + passwordField.echoMode = showPassword ? TextInput.Normal : TextInput.Password; + showPasswordImage.source = showPassword ? "../../images/eyeClosed.svg" : "../../images/eyeOpen.svg"; + } + } + } + + Keys.onReturnPressed: linkAccountBody.login() } InfoItem {