mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-11-16 15:58:11 +00:00
Merge pull request #2870
2195c67
LineEdit: password mode, linking. PasswordDialog: use LineEdit (xiphon)
This commit is contained in:
commit
9aef3bab33
4 changed files with 90 additions and 178 deletions
|
@ -26,6 +26,7 @@
|
|||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import FontAwesome 1.0
|
||||
import QtQuick 2.9
|
||||
import QtGraphicalEffects 1.0
|
||||
|
||||
|
@ -36,6 +37,10 @@ Item {
|
|||
property alias input: input
|
||||
property alias text: input.text
|
||||
|
||||
property bool password: false
|
||||
property bool passwordHidden: true
|
||||
property var passwordLinked: null
|
||||
|
||||
property alias placeholderText: placeholderLabel.text
|
||||
property bool placeholderCenter: false
|
||||
property string placeholderFontFamily: MoneroComponents.Style.fontRegular.name
|
||||
|
@ -48,7 +53,6 @@ Item {
|
|||
property alias validator: input.validator
|
||||
property alias readOnly : input.readOnly
|
||||
property alias cursorPosition: input.cursorPosition
|
||||
property alias echoMode: input.echoMode
|
||||
property alias inlineButton: inlineButtonId
|
||||
property alias inlineButtonText: inlineButtonId.text
|
||||
property alias inlineIcon: inlineIcon.visible
|
||||
|
@ -109,6 +113,31 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
function isPasswordHidden() {
|
||||
if (password) {
|
||||
return passwordHidden;
|
||||
}
|
||||
if (passwordLinked) {
|
||||
return passwordLinked.passwordHidden;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function reset() {
|
||||
text = "";
|
||||
if (!passwordLinked) {
|
||||
passwordHidden = true;
|
||||
}
|
||||
}
|
||||
|
||||
function passwordToggle() {
|
||||
if (passwordLinked) {
|
||||
passwordLinked.passwordHidden = !passwordLinked.passwordHidden;
|
||||
} else {
|
||||
passwordHidden = !passwordHidden;
|
||||
}
|
||||
}
|
||||
|
||||
MoneroComponents.TextPlain {
|
||||
id: inputLabel
|
||||
anchors.top: parent.top
|
||||
|
@ -210,6 +239,27 @@ Item {
|
|||
onTextChanged: item.textUpdated()
|
||||
topPadding: 10
|
||||
bottomPadding: 10
|
||||
echoMode: isPasswordHidden() ? TextInput.Password : TextInput.Normal
|
||||
|
||||
MoneroComponents.Label {
|
||||
visible: password || passwordLinked
|
||||
fontSize: 20
|
||||
text: isPasswordHidden() ? FontAwesome.eye : FontAwesome.eyeSlash
|
||||
opacity: eyeMouseArea.containsMouse ? 0.9 : 0.7
|
||||
fontFamily: FontAwesome.fontFamily
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 15
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.verticalCenterOffset: 1
|
||||
|
||||
MouseArea {
|
||||
id: eyeMouseArea
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
hoverEnabled: true
|
||||
onClicked: passwordToggle()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MoneroComponents.InlineButton {
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -304,7 +304,7 @@ Rectangle{
|
|||
labelText: qsTr("Daemon password") + translationManager.emptyString
|
||||
text: persistentSettings.daemonPassword
|
||||
placeholderText: qsTr("Password") + translationManager.emptyString
|
||||
echoMode: TextInput.Password
|
||||
password: true
|
||||
placeholderFontSize: 15
|
||||
labelFontSize: 14
|
||||
fontSize: 15
|
||||
|
|
|
@ -225,7 +225,7 @@ Rectangle {
|
|||
|
||||
MoneroComponents.LineEdit {
|
||||
id: seedOffset
|
||||
echoMode: TextInput.Password
|
||||
password: true
|
||||
Layout.fillWidth: true
|
||||
placeholderFontSize: 16
|
||||
placeholderText: qsTr("Passphrase") + translationManager.emptyString
|
||||
|
|
Loading…
Reference in a new issue