Merge pull request #14020 from wayne-chen/fixMainTextContainerQML

Login Dialog UI improvements
This commit is contained in:
Brad Hefta-Gaub 2018-10-01 16:13:59 -07:00 committed by GitHub
commit 526d69f1b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -23,6 +23,7 @@ Item {
property bool failAfterSignUp: false property bool failAfterSignUp: false
function login() { function login() {
flavorText.visible = false
mainTextContainer.visible = false mainTextContainer.visible = false
toggleLoading(true) toggleLoading(true)
loginDialog.login(usernameField.text, passwordField.text) loginDialog.login(usernameField.text, passwordField.text)
@ -43,7 +44,7 @@ Item {
function resize() { function resize() {
var targetWidth = Math.max(titleWidth, form.contentWidth); var targetWidth = Math.max(titleWidth, form.contentWidth);
var targetHeight = hifi.dimensions.contentSpacing.y + mainTextContainer.height + var targetHeight = hifi.dimensions.contentSpacing.y + flavorText.height + mainTextContainer.height +
4 * hifi.dimensions.contentSpacing.y + form.height; 4 * hifi.dimensions.contentSpacing.y + form.height;
if (additionalInformation.visible) { if (additionalInformation.visible) {
@ -106,14 +107,15 @@ Item {
ShortcutText { ShortcutText {
id: mainTextContainer id: mainTextContainer
anchors { anchors {
top: parent.top top: flavorText.bottom
left: parent.left left: parent.left
margins: 0 margins: 0
topMargin: hifi.dimensions.contentSpacing.y topMargin: 1.5 * hifi.dimensions.contentSpacing.y
} }
visible: false visible: false
text: qsTr("Username or password incorrect.") text: qsTr("Username or password incorrect.")
height: flavorText.height - 20
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
color: hifi.colors.redAccent color: hifi.colors.redAccent
lineHeight: 1 lineHeight: 1
@ -128,7 +130,7 @@ Item {
anchors { anchors {
top: mainTextContainer.bottom top: mainTextContainer.bottom
topMargin: 2 * hifi.dimensions.contentSpacing.y topMargin: 1.5 * hifi.dimensions.contentSpacing.y
} }
spacing: 2 * hifi.dimensions.contentSpacing.y spacing: 2 * hifi.dimensions.contentSpacing.y
@ -139,6 +141,7 @@ Item {
focus: true focus: true
placeholderText: "Username or Email" placeholderText: "Username or Email"
activeFocusOnPress: true activeFocusOnPress: true
onHeightChanged: d.resize(); onWidthChanged: d.resize();
ShortcutText { ShortcutText {
z: 10 z: 10
@ -172,7 +175,7 @@ Item {
width: parent.width width: parent.width
placeholderText: "Password" placeholderText: "Password"
activeFocusOnPress: true activeFocusOnPress: true
echoMode: TextInput.Password echoMode: passwordFieldMouseArea.showPassword ? TextInput.Normal : TextInput.Password
onHeightChanged: d.resize(); onWidthChanged: d.resize(); onHeightChanged: d.resize(); onWidthChanged: d.resize();
ShortcutText { ShortcutText {
@ -212,29 +215,28 @@ Item {
Image { Image {
id: showPasswordImage id: showPasswordImage
y: (passwordField.height - (passwordField.height * 16 / 23)) / 2 width: passwordField.height * 16 / 23
width: passwordField.width - (passwordField.width - (((passwordField.height) * 31/23)))
height: passwordField.height * 16 / 23 height: passwordField.height * 16 / 23
anchors { anchors {
right: parent.right right: parent.right
rightMargin: 3 rightMargin: 8
top: parent.top
topMargin: passwordFieldMouseArea.showPassword ? 6 : 8
bottom: parent.bottom
bottomMargin: passwordFieldMouseArea.showPassword ? 5 : 8
}
source: passwordFieldMouseArea.showPassword ? "../../images/eyeClosed.svg" : "../../images/eyeOpen.svg"
MouseArea {
id: passwordFieldMouseArea
anchors.fill: parent
acceptedButtons: Qt.LeftButton
property bool showPassword: false
onClicked: {
showPassword = !showPassword;
}
} }
source: "../../images/eyeOpen.svg"
} }
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";
showPasswordImage.height = showPassword ? passwordField.height : passwordField.height * 16 / 23;
showPasswordImage.y = showPassword ? 0 : (passwordField.height - showPasswordImage.height) / 2;
}
}
} }
Keys.onReturnPressed: linkAccountBody.login() Keys.onReturnPressed: linkAccountBody.login()
@ -284,7 +286,7 @@ Item {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: 200 width: 200
text: qsTr(loginDialog.isSteamRunning() ? "Link Account" : "Login") text: qsTr(loginDialog.isSteamRunning() ? "Link Account" : "Log in")
color: hifi.buttons.blue color: hifi.buttons.blue
onClicked: linkAccountBody.login() onClicked: linkAccountBody.login()
@ -336,6 +338,7 @@ Item {
if (failAfterSignUp) { if (failAfterSignUp) {
mainTextContainer.text = "Account created successfully." mainTextContainer.text = "Account created successfully."
flavorText.visible = true
mainTextContainer.visible = true mainTextContainer.visible = true
} }
@ -374,6 +377,7 @@ Item {
UserActivityLogger.logAction("encourageLoginDialog", data); UserActivityLogger.logAction("encourageLoginDialog", data);
Settings.setValue("loginDialogPoppedUp", false); Settings.setValue("loginDialogPoppedUp", false);
} }
flavorText.visible = true
mainTextContainer.visible = true mainTextContainer.visible = true
toggleLoading(false) toggleLoading(false)
} }