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
|
// 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.
|
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
import FontAwesome 1.0
|
||||||
import QtQuick 2.9
|
import QtQuick 2.9
|
||||||
import QtGraphicalEffects 1.0
|
import QtGraphicalEffects 1.0
|
||||||
|
|
||||||
|
@ -36,6 +37,10 @@ Item {
|
||||||
property alias input: input
|
property alias input: input
|
||||||
property alias text: input.text
|
property alias text: input.text
|
||||||
|
|
||||||
|
property bool password: false
|
||||||
|
property bool passwordHidden: true
|
||||||
|
property var passwordLinked: null
|
||||||
|
|
||||||
property alias placeholderText: placeholderLabel.text
|
property alias placeholderText: placeholderLabel.text
|
||||||
property bool placeholderCenter: false
|
property bool placeholderCenter: false
|
||||||
property string placeholderFontFamily: MoneroComponents.Style.fontRegular.name
|
property string placeholderFontFamily: MoneroComponents.Style.fontRegular.name
|
||||||
|
@ -48,7 +53,6 @@ Item {
|
||||||
property alias validator: input.validator
|
property alias validator: input.validator
|
||||||
property alias readOnly : input.readOnly
|
property alias readOnly : input.readOnly
|
||||||
property alias cursorPosition: input.cursorPosition
|
property alias cursorPosition: input.cursorPosition
|
||||||
property alias echoMode: input.echoMode
|
|
||||||
property alias inlineButton: inlineButtonId
|
property alias inlineButton: inlineButtonId
|
||||||
property alias inlineButtonText: inlineButtonId.text
|
property alias inlineButtonText: inlineButtonId.text
|
||||||
property alias inlineIcon: inlineIcon.visible
|
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 {
|
MoneroComponents.TextPlain {
|
||||||
id: inputLabel
|
id: inputLabel
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
|
@ -210,6 +239,27 @@ Item {
|
||||||
onTextChanged: item.textUpdated()
|
onTextChanged: item.textUpdated()
|
||||||
topPadding: 10
|
topPadding: 10
|
||||||
bottomPadding: 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 {
|
MoneroComponents.InlineButton {
|
||||||
|
|
|
@ -43,7 +43,6 @@ Item {
|
||||||
visible: false
|
visible: false
|
||||||
z: parent.z + 2
|
z: parent.z + 2
|
||||||
|
|
||||||
property bool isHidden: true
|
|
||||||
property alias password: passwordInput1.text
|
property alias password: passwordInput1.text
|
||||||
property string walletName
|
property string walletName
|
||||||
property string errorText
|
property string errorText
|
||||||
|
@ -61,12 +60,9 @@ Item {
|
||||||
signal closeCallback()
|
signal closeCallback()
|
||||||
|
|
||||||
function _openInit(walletName, errorText) {
|
function _openInit(walletName, errorText) {
|
||||||
isHidden = true
|
|
||||||
capsLockTextLabel.visible = oshelper.isCapsLock();
|
capsLockTextLabel.visible = oshelper.isCapsLock();
|
||||||
passwordInput1.echoMode = TextInput.Password
|
passwordInput1.reset();
|
||||||
passwordInput2.echoMode = TextInput.Password
|
passwordInput2.reset();
|
||||||
passwordInput1.text = ""
|
|
||||||
passwordInput2.text = ""
|
|
||||||
passwordInput1.forceActiveFocus();
|
passwordInput1.forceActiveFocus();
|
||||||
root.walletName = walletName ? walletName : ""
|
root.walletName = walletName ? walletName : ""
|
||||||
errorTextLabel.text = errorText ? errorText : "";
|
errorTextLabel.text = errorText ? errorText : "";
|
||||||
|
@ -116,10 +112,29 @@ Item {
|
||||||
closeCallback();
|
closeCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleIsHidden() {
|
function onOk() {
|
||||||
passwordInput1.echoMode = isHidden ? TextInput.Normal : TextInput.Password;
|
if (!passwordDialogMode && passwordInput1.text !== passwordInput2.text) {
|
||||||
passwordInput2.echoMode = isHidden ? TextInput.Normal : TextInput.Password;
|
return;
|
||||||
isHidden = !isHidden;
|
}
|
||||||
|
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 {
|
ColumnLayout {
|
||||||
|
@ -184,15 +199,11 @@ Item {
|
||||||
text: qsTr("CAPSLOCKS IS ON.") + translationManager.emptyString;
|
text: qsTr("CAPSLOCKS IS ON.") + translationManager.emptyString;
|
||||||
}
|
}
|
||||||
|
|
||||||
MoneroComponents.Input {
|
MoneroComponents.LineEdit {
|
||||||
id: passwordInput1
|
id: passwordInput1
|
||||||
|
password: true
|
||||||
Layout.topMargin: 6
|
Layout.topMargin: 6
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
horizontalAlignment: TextInput.AlignLeft
|
|
||||||
verticalAlignment: TextInput.AlignVCenter
|
|
||||||
font.family: MoneroComponents.Style.fontLight.name
|
|
||||||
font.pixelSize: 24
|
|
||||||
echoMode: TextInput.Password
|
|
||||||
KeyNavigation.tab: {
|
KeyNavigation.tab: {
|
||||||
if (passwordDialogMode) {
|
if (passwordDialogMode) {
|
||||||
return okButton
|
return okButton
|
||||||
|
@ -200,81 +211,12 @@ Item {
|
||||||
return passwordInput2
|
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();
|
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.enabled: root.visible
|
||||||
Keys.onEnterPressed: Keys.onReturnPressed(event)
|
Keys.onEnterPressed: root.onOk()
|
||||||
Keys.onReturnPressed: {
|
Keys.onReturnPressed: root.onOk()
|
||||||
if (!passwordDialogMode && passwordInput1.text !== passwordInput2.text) {
|
Keys.onEscapePressed: root.onCancel()
|
||||||
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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// padding
|
// padding
|
||||||
|
@ -298,81 +240,19 @@ Item {
|
||||||
color: MoneroComponents.Style.defaultFontColor
|
color: MoneroComponents.Style.defaultFontColor
|
||||||
}
|
}
|
||||||
|
|
||||||
MoneroComponents.Input {
|
MoneroComponents.LineEdit {
|
||||||
id: passwordInput2
|
id: passwordInput2
|
||||||
|
passwordLinked: passwordInput1
|
||||||
visible: !passwordDialogMode
|
visible: !passwordDialogMode
|
||||||
Layout.topMargin: 6
|
Layout.topMargin: 6
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
horizontalAlignment: TextInput.AlignLeft
|
|
||||||
verticalAlignment: TextInput.AlignVCenter
|
|
||||||
font.family: MoneroComponents.Style.fontLight.name
|
|
||||||
font.pixelSize: 24
|
|
||||||
echoMode: TextInput.Password
|
|
||||||
KeyNavigation.tab: okButton
|
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();
|
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.enabled: root.visible
|
||||||
Keys.onEnterPressed: Keys.onReturnPressed(event)
|
Keys.onEnterPressed: root.onOk()
|
||||||
Keys.onReturnPressed: {
|
Keys.onReturnPressed: root.onOk()
|
||||||
if (passwordInput1.text === passwordInput2.text) {
|
Keys.onEscapePressed: root.onCancel()
|
||||||
root.close()
|
|
||||||
if (newPasswordDialogMode) {
|
|
||||||
root.acceptedNewPassword()
|
|
||||||
} else if (passphraseDialogMode) {
|
|
||||||
root.acceptedPassphrase()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Keys.onEscapePressed: {
|
|
||||||
root.close()
|
|
||||||
if (newPasswordDialogMode) {
|
|
||||||
root.rejectedNewPassword()
|
|
||||||
} else if (passphraseDialogMode) {
|
|
||||||
root.rejectedPassphrase()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// padding
|
// padding
|
||||||
|
@ -397,16 +277,7 @@ Item {
|
||||||
small: true
|
small: true
|
||||||
text: qsTr("Cancel") + translationManager.emptyString
|
text: qsTr("Cancel") + translationManager.emptyString
|
||||||
KeyNavigation.tab: passwordInput1
|
KeyNavigation.tab: passwordInput1
|
||||||
onClicked: {
|
onClicked: onCancel()
|
||||||
root.close()
|
|
||||||
if (passwordDialogMode) {
|
|
||||||
root.rejected()
|
|
||||||
} else if (newPasswordDialogMode) {
|
|
||||||
root.rejectedNewPassword()
|
|
||||||
} else if (passphraseDialogMode) {
|
|
||||||
root.rejectedPassphrase()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MoneroComponents.StandardButton {
|
MoneroComponents.StandardButton {
|
||||||
|
@ -415,16 +286,7 @@ Item {
|
||||||
text: qsTr("Ok") + translationManager.emptyString
|
text: qsTr("Ok") + translationManager.emptyString
|
||||||
KeyNavigation.tab: cancelButton
|
KeyNavigation.tab: cancelButton
|
||||||
enabled: (passwordDialogMode == true) ? true : passwordInput1.text === passwordInput2.text
|
enabled: (passwordDialogMode == true) ? true : passwordInput1.text === passwordInput2.text
|
||||||
onClicked: {
|
onClicked: onOk()
|
||||||
root.close()
|
|
||||||
if (passwordDialogMode) {
|
|
||||||
root.accepted()
|
|
||||||
} else if (newPasswordDialogMode) {
|
|
||||||
root.acceptedNewPassword()
|
|
||||||
} else if (passphraseDialogMode) {
|
|
||||||
root.acceptedPassphrase()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -304,7 +304,7 @@ Rectangle{
|
||||||
labelText: qsTr("Daemon password") + translationManager.emptyString
|
labelText: qsTr("Daemon password") + translationManager.emptyString
|
||||||
text: persistentSettings.daemonPassword
|
text: persistentSettings.daemonPassword
|
||||||
placeholderText: qsTr("Password") + translationManager.emptyString
|
placeholderText: qsTr("Password") + translationManager.emptyString
|
||||||
echoMode: TextInput.Password
|
password: true
|
||||||
placeholderFontSize: 15
|
placeholderFontSize: 15
|
||||||
labelFontSize: 14
|
labelFontSize: 14
|
||||||
fontSize: 15
|
fontSize: 15
|
||||||
|
|
|
@ -225,7 +225,7 @@ Rectangle {
|
||||||
|
|
||||||
MoneroComponents.LineEdit {
|
MoneroComponents.LineEdit {
|
||||||
id: seedOffset
|
id: seedOffset
|
||||||
echoMode: TextInput.Password
|
password: true
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
placeholderFontSize: 16
|
placeholderFontSize: 16
|
||||||
placeholderText: qsTr("Passphrase") + translationManager.emptyString
|
placeholderText: qsTr("Passphrase") + translationManager.emptyString
|
||||||
|
|
Loading…
Reference in a new issue