diff options
| author | xiphon <xiphon@protonmail.com> | 2020-04-28 12:15:18 +0000 |
|---|---|---|
| committer | xiphon <xiphon@protonmail.com> | 2020-04-28 20:44:53 +0000 |
| commit | 2195c67f58b242d5c6be8df66b73d9731cad7a4c (patch) | |
| tree | cb22810b9cf28abc64b2fd1cd86093a2b2922dd1 /components/PasswordDialog.qml | |
| parent | 585fb2810dc0d9b79255b9bd479559b36aa087d8 (diff) | |
| download | monzero-gui-2195c67f58b242d5c6be8df66b73d9731cad7a4c.tar.gz monzero-gui-2195c67f58b242d5c6be8df66b73d9731cad7a4c.tar.xz monzero-gui-2195c67f58b242d5c6be8df66b73d9731cad7a4c.zip | |
LineEdit: password mode, linking. PasswordDialog: use LineEdit
Diffstat (limited to 'components/PasswordDialog.qml')
| -rw-r--r-- | components/PasswordDialog.qml | 212 |
1 files changed, 37 insertions, 175 deletions
diff --git a/components/PasswordDialog.qml b/components/PasswordDialog.qml index 43d2a2e6..f9ea5569 100644 --- a/components/PasswordDialog.qml +++ b/components/PasswordDialog.qml @@ -43,7 +43,6 @@ Item { visible: false z: parent.z + 2 - property bool isHidden: true property alias password: passwordInput1.text property string walletName property string errorText @@ -61,12 +60,9 @@ Item { signal closeCallback() function _openInit(walletName, errorText) { - isHidden = true capsLockTextLabel.visible = oshelper.isCapsLock(); - passwordInput1.echoMode = TextInput.Password - passwordInput2.echoMode = TextInput.Password - passwordInput1.text = "" - passwordInput2.text = "" + passwordInput1.reset(); + passwordInput2.reset(); passwordInput1.forceActiveFocus(); root.walletName = walletName ? walletName : "" errorTextLabel.text = errorText ? errorText : ""; @@ -116,10 +112,29 @@ Item { closeCallback(); } - function toggleIsHidden() { - passwordInput1.echoMode = isHidden ? TextInput.Normal : TextInput.Password; - passwordInput2.echoMode = isHidden ? TextInput.Normal : TextInput.Password; - isHidden = !isHidden; + function onOk() { + if (!passwordDialogMode && passwordInput1.text !== passwordInput2.text) { + return; + } + root.close() + if (passwordDialogMode) { + root.accepted() + } else if (newPasswordDialogMode) { + root.acceptedNewPassword() + } else if (passphraseDialogMode) { + root.acceptedPassphrase() + } + } + + function onCancel() { + root.close() + if (passwordDialogMode) { + root.rejected() + } else if (newPasswordDialogMode) { + root.rejectedNewPassword() + } else if (passphraseDialogMode) { + root.rejectedPassphrase() + } } ColumnLayout { @@ -184,15 +199,11 @@ Item { text: qsTr("CAPSLOCKS IS ON.") + translationManager.emptyString; } - MoneroComponents.Input { + MoneroComponents.LineEdit { id: passwordInput1 + password: true Layout.topMargin: 6 Layout.fillWidth: true - horizontalAlignment: TextInput.AlignLeft - verticalAlignment: TextInput.AlignVCenter - font.family: MoneroComponents.Style.fontLight.name - font.pixelSize: 24 - echoMode: TextInput.Password KeyNavigation.tab: { if (passwordDialogMode) { return okButton @@ -200,81 +211,12 @@ Item { return passwordInput2 } } - implicitHeight: 50 - bottomPadding: 10 - leftPadding: 10 - topPadding: 10 - color: MoneroComponents.Style.defaultFontColor - selectionColor: MoneroComponents.Style.textSelectionColor - selectedTextColor: MoneroComponents.Style.textSelectedColor onTextChanged: capsLockTextLabel.visible = oshelper.isCapsLock(); - background: Rectangle { - radius: 2 - color: MoneroComponents.Style.blackTheme ? "black" : "#A9FFFFFF" - border.color: MoneroComponents.Style.inputBorderColorInActive - border.width: 1 - - MoneroEffects.ColorTransition { - targetObj: parent - blackColor: "black" - whiteColor: "#A9FFFFFF" - } - - MoneroComponents.Label { - fontSize: 20 - text: isHidden ? FontAwesome.eye : FontAwesome.eyeSlash - opacity: 0.7 - fontFamily: FontAwesome.fontFamily - anchors.right: parent.right - anchors.rightMargin: 15 - anchors.verticalCenter: parent.verticalCenter - anchors.verticalCenterOffset: 1 - - MouseArea { - anchors.fill: parent - cursorShape: Qt.PointingHandCursor - hoverEnabled: true - onClicked: { - toggleIsHidden(); - } - onEntered: { - parent.opacity = 0.9 - parent.fontSize = 24 - } - onExited: { - parent.opacity = 0.7 - parent.fontSize = 20 - } - } - } - } - Keys.enabled: root.visible - Keys.onEnterPressed: Keys.onReturnPressed(event) - Keys.onReturnPressed: { - if (!passwordDialogMode && passwordInput1.text !== passwordInput2.text) { - return; - } - root.close() - if (passwordDialogMode) { - root.accepted() - } else if (newPasswordDialogMode) { - root.acceptedNewPassword() - } else if (passphraseDialogMode) { - root.acceptedPassphrase() - } - } - Keys.onEscapePressed: { - root.close() - if (passwordDialogMode) { - root.rejected() - } else if (newPasswordDialogMode) { - root.rejectedNewPassword() - } else if (passphraseDialogMode) { - root.rejectedPassphrase() - } - } + Keys.onEnterPressed: root.onOk() + Keys.onReturnPressed: root.onOk() + Keys.onEscapePressed: root.onCancel() } // padding @@ -298,81 +240,19 @@ Item { color: MoneroComponents.Style.defaultFontColor } - MoneroComponents.Input { + MoneroComponents.LineEdit { id: passwordInput2 + passwordLinked: passwordInput1 visible: !passwordDialogMode Layout.topMargin: 6 Layout.fillWidth: true - horizontalAlignment: TextInput.AlignLeft - verticalAlignment: TextInput.AlignVCenter - font.family: MoneroComponents.Style.fontLight.name - font.pixelSize: 24 - echoMode: TextInput.Password KeyNavigation.tab: okButton - implicitHeight: 50 - bottomPadding: 10 - leftPadding: 10 - topPadding: 10 - color: MoneroComponents.Style.defaultFontColor - selectionColor: MoneroComponents.Style.textSelectionColor - selectedTextColor: MoneroComponents.Style.textSelectedColor onTextChanged: capsLockTextLabel.visible = oshelper.isCapsLock(); - background: Rectangle { - radius: 2 - border.color: MoneroComponents.Style.inputBorderColorInActive - border.width: 1 - color: MoneroComponents.Style.blackTheme ? "black" : "#A9FFFFFF" - - MoneroComponents.Label { - fontSize: 20 - text: isHidden ? FontAwesome.eye : FontAwesome.eyeSlash - opacity: 0.7 - fontFamily: FontAwesome.fontFamily - anchors.right: parent.right - anchors.rightMargin: 15 - anchors.verticalCenter: parent.verticalCenter - anchors.verticalCenterOffset: 1 - - MouseArea { - anchors.fill: parent - cursorShape: Qt.PointingHandCursor - hoverEnabled: true - onClicked: { - toggleIsHidden() - } - onEntered: { - parent.opacity = 0.9 - parent.fontSize = 24 - } - onExited: { - parent.opacity = 0.7 - parent.fontSize = 20 - } - } - } - } - Keys.enabled: root.visible - Keys.onEnterPressed: Keys.onReturnPressed(event) - Keys.onReturnPressed: { - if (passwordInput1.text === passwordInput2.text) { - root.close() - if (newPasswordDialogMode) { - root.acceptedNewPassword() - } else if (passphraseDialogMode) { - root.acceptedPassphrase() - } - } - } - Keys.onEscapePressed: { - root.close() - if (newPasswordDialogMode) { - root.rejectedNewPassword() - } else if (passphraseDialogMode) { - root.rejectedPassphrase() - } - } + Keys.onEnterPressed: root.onOk() + Keys.onReturnPressed: root.onOk() + Keys.onEscapePressed: root.onCancel() } // padding @@ -397,16 +277,7 @@ Item { small: true text: qsTr("Cancel") + translationManager.emptyString KeyNavigation.tab: passwordInput1 - onClicked: { - root.close() - if (passwordDialogMode) { - root.rejected() - } else if (newPasswordDialogMode) { - root.rejectedNewPassword() - } else if (passphraseDialogMode) { - root.rejectedPassphrase() - } - } + onClicked: onCancel() } MoneroComponents.StandardButton { @@ -415,16 +286,7 @@ Item { text: qsTr("Ok") + translationManager.emptyString KeyNavigation.tab: cancelButton enabled: (passwordDialogMode == true) ? true : passwordInput1.text === passwordInput2.text - onClicked: { - root.close() - if (passwordDialogMode) { - root.accepted() - } else if (newPasswordDialogMode) { - root.acceptedNewPassword() - } else if (passphraseDialogMode) { - root.acceptedPassphrase() - } - } + onClicked: onOk() } } } |
