some work to profile screen

This commit is contained in:
Wayne Chen 2018-10-23 22:19:54 -07:00
parent c34d18065c
commit 3522fe5263
3 changed files with 280 additions and 463 deletions

View file

@ -12,108 +12,243 @@ import Hifi 1.0
import QtQuick 2.4 import QtQuick 2.4
import QtQuick.Controls.Styles 1.4 as OriginalStyles import QtQuick.Controls.Styles 1.4 as OriginalStyles
import controlsUit 1.0 import controlsUit 1.0 as HifiControlsUit
import stylesUit 1.0 import stylesUit 1.0 as HifiStylesUit
Item { Item {
id: completeProfileBody id: completeProfileBody
clip: true clip: true
width: root.pane.width width: root.pane.width
height: root.pane.height height: root.pane.height
readonly property string termsContainerText: qsTr("By creating this user profile, you agree to High Fidelity's Terms of Service")
readonly property string fontFamily: "Cairo"
readonly property int fontSize: 24
readonly property bool fontBold: true
QtObject { QtObject {
id: d id: d
readonly property int minWidth: 480 readonly property int minWidth: 480
readonly property int maxWidth: 1280 readonly property int minWidthButton: !root.isTablet ? 256 : 174
property int maxWidth: root.isTablet ? 1280 : Window.innerWidth
readonly property int minHeight: 120 readonly property int minHeight: 120
readonly property int maxHeight: 720 readonly property int minHeightButton: !root.isTablet ? 56 : 42
property int maxHeight: root.isTablet ? 720 : Window.innerHeight
function resize() { function resize() {
maxWidth = root.isTablet ? 1280 : Window.innerWidth;
maxHeight = root.isTablet ? 720 : Window.innerHeight;
if (root.isTablet === false) { if (root.isTablet === false) {
var targetWidth = Math.max(titleWidth, Math.max(additionalTextContainer.contentWidth, var targetWidth = Math.max(Math.max(titleWidth, Math.max(additionalTextContainer.contentWidth,
termsContainer.contentWidth)) termsContainer.contentWidth)), mainContainer.width)
parent.width = root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)) parent.width = root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth))
} }
var targetHeight = 5 * hifi.dimensions.contentSpacing.y + buttons.height + additionalTextContainer.height + termsContainer.height var targetHeight = Math.max(5 * hifi.dimensions.contentSpacing.y + buttons.height + additionalTextContainer.height + termsContainer.height, d.maxHeight)
parent.height = root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) parent.height = root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight))
} }
} }
Row { // timer to kill the dialog upon login success
id: buttons Timer {
anchors { id: successTimer
top: parent.top interval: 500;
horizontalCenter: parent.horizontalCenter running: false;
margins: 0 repeat: false;
topMargin: 2 * hifi.dimensions.contentSpacing.y onTriggered: {
root.tryDestroy();
} }
spacing: hifi.dimensions.contentSpacing.x }
function hideContents(hide) {
additionalTextContainer.visible = !hide;
termsContainer.visible = !hide;
buttons.visible = !hide;
}
function loginSuccess(success) {
loginErrorMessage.visible = true;
loggedInGlyph.visible = success;
loginErrorMessage.text = success ? "You are now logged into Steam!" : "Error logging into Steam."
loginErrorMessage.color = success ? "white" : "red";
loginErrorMessage.font.pixelSize = success ? 24 : 12;
loginErrorMessage.anchors.leftMargin = (mainContainer.width - loginErrorMessageTextMetrics.width) / 2;
completeProfileBody.hideContents(success);
if (success) {
successTimer.start();
}
}
Item {
id: mainContainer
width: root.pane.width
height: root.pane.height
onHeightChanged: d.resize(); onWidthChanged: d.resize(); onHeightChanged: d.resize(); onWidthChanged: d.resize();
Button { Rectangle {
anchors.verticalCenter: parent.verticalCenter id: opaqueRect
width: 200 height: parent.height
width: parent.width
text: qsTr("Create your profile") opacity: 0.9
color: hifi.buttons.blue color: "black"
onClicked: loginDialog.createAccountFromStream()
} }
Button { Item {
anchors.verticalCenter: parent.verticalCenter id: bannerContainer
text: qsTr("Cancel") width: parent.width
onClicked: root.tryDestroy() height: banner.height
anchors {
top: parent.top
topMargin: 85
}
Image {
id: banner
anchors.centerIn: parent
source: "../../images/high-fidelity-banner.svg"
horizontalAlignment: Image.AlignHCenter
}
} }
} Item {
id: contentItem
anchors.fill: parent
ShortcutText { TextMetrics {
id: additionalTextContainer id: loginErrorMessageTextMetrics
anchors { font: loginErrorMessage.font
top: buttons.bottom text: loginErrorMessage.text
horizontalCenter: parent.horizontalCenter }
margins: 0 Text {
topMargin: hifi.dimensions.contentSpacing.y id: loginErrorMessage
anchors.top: parent.top;
// above buttons.
anchors.topMargin: (parent.height - additionalTextContainer.height) / 2 - hifi.dimensions.contentSpacing.y - buttons.height
anchors.left: parent.left;
color: "red";
font.family: "Cairo"
font.pixelSize: 12
text: ""
visible: true
}
HifiStylesUit.HiFiGlyphs {
id: loggedInGlyph;
text: hifi.glyphs.steamSquare;
// color
color: "white"
// Size
size: 78;
// Anchors
anchors.left: parent.left;
anchors.leftMargin: (parent.width - loggedInGlyph.size) / 2;
anchors.top: loginErrorMessage.bottom
anchors.topMargin: 2 * hifi.dimensions.contentSpacing.y
// Alignment
horizontalAlignment: Text.AlignHCenter;
verticalAlignment: Text.AlignVCenter;
visible: false;
}
Row {
id: buttons
anchors {
top: parent.top
topMargin: (parent.height - additionalTextContainer.height) / 2 - hifi.dimensions.contentSpacing.y
horizontalCenter: parent.horizontalCenter
margins: 0
}
spacing: hifi.dimensions.contentSpacing.x
onHeightChanged: d.resize(); onWidthChanged: d.resize();
HifiControlsUit.Button {
id: profileButton
anchors.verticalCenter: parent.verticalCenter
width: 256
text: qsTr("Create your profile")
color: hifi.buttons.blue
fontFamily: completeProfileBody.fontFamily
fontSize: completeProfileBody.fontSize
fontBold: completeProfileBody.fontBold
onClicked: {
loginErrorMessage.visible = false;
loginDialog.createAccountFromStream()
}
}
HifiControlsUit.Button {
id: cancelButton
anchors.verticalCenter: parent.verticalCenter
text: qsTr("Cancel")
fontFamily: completeProfileBody.fontFamily
fontSize: completeProfileBody.fontSize
fontBold: completeProfileBody.fontBold
onClicked: {
bodyLoader.setSource("LinkAccountBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader });
}
}
}
HifiStylesUit.ShortcutText {
id: additionalTextContainer
anchors {
top: buttons.bottom
horizontalCenter: parent.horizontalCenter
margins: 0
topMargin: hifi.dimensions.contentSpacing.y
}
text: "<a href='https://fake.link'>Already have a High Fidelity profile? Link to an existing profile here.</a>"
font.family: completeProfileBody.fontFamily
font.pixelSize: 14
font.bold: completeProfileBody.fontBold
wrapMode: Text.WordWrap
lineHeight: 2
lineHeightMode: Text.ProportionalHeight
horizontalAlignment: Text.AlignHCenter
onLinkActivated: {
loginDialog.atSignIn = true;
loginDialog.isLogIn = true;
bodyLoader.setSource("SignInBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader });
}
}
TextMetrics {
id: termsContainerTextMetrics
font: termsContainer.font
text: completeProfileBody.termsContainerText
Component.onCompleted: {
// with the link.
termsContainer.text = qsTr("By creating this user profile, you agree to <a href='https://highfidelity.com/terms'>High Fidelity's Terms of Service</a>")
}
}
HifiStylesUit.InfoItem {
id: termsContainer
anchors {
top: additionalTextContainer.bottom
margins: 0
topMargin: 2 * hifi.dimensions.contentSpacing.y
horizontalCenter: parent.horizontalCenter
left: parent.left
leftMargin: (parent.width - termsContainerTextMetrics.width) / 2
}
text: completeProfileBody.termsContainerText
font.family: completeProfileBody.fontFamily
font.pixelSize: 14
font.bold: completeProfileBody.fontBold
wrapMode: Text.WordWrap
color: hifi.colors.baseGrayHighlight
lineHeight: 1
lineHeightMode: Text.ProportionalHeight
onLinkActivated: loginDialog.openUrl(link)
}
} }
text: "<a href='https://fake.link'>Already have a High Fidelity profile? Link to an existing profile here.</a>"
wrapMode: Text.WordWrap
lineHeight: 2
lineHeightMode: Text.ProportionalHeight
horizontalAlignment: Text.AlignHCenter
onLinkActivated: {
bodyLoader.source = "LinkAccountBody.qml"
bodyLoader.item.width = root.pane.width
bodyLoader.item.height = root.pane.height
}
}
InfoItem {
id: termsContainer
anchors {
top: additionalTextContainer.bottom
margins: 0
topMargin: 2 * hifi.dimensions.contentSpacing.y
horizontalCenter: parent.horizontalCenter
}
width: parent.width
text: qsTr("By creating this user profile, you agree to <a href='https://highfidelity.com/terms'>High Fidelity's Terms of Service</a>")
wrapMode: Text.WordWrap
color: hifi.colors.baseGrayHighlight
lineHeight: 1
lineHeightMode: Text.ProportionalHeight
fontSizeMode: Text.HorizontalFit
horizontalAlignment: Text.AlignVCenter
onLinkActivated: loginDialog.openUrl(link)
} }
Component.onCompleted: { Component.onCompleted: {
root.title = qsTr("Complete Your Profile")
root.iconText = "<"
d.resize(); d.resize();
} }
@ -126,22 +261,31 @@ Item {
} }
onHandleCreateFailed: { onHandleCreateFailed: {
console.log("Create Failed: " + error) console.log("Create Failed: " + error)
var poppedUp = Settings.getValue("loginDialogPoppedUp", false);
bodyLoader.source = "UsernameCollisionBody.qml" if (poppedUp) {
if (!root.isTablet) { console.log("[ENCOURAGELOGINDIALOG]: failed creating an account")
bodyLoader.item.width = root.pane.width var data = {
bodyLoader.item.height = root.pane.height "action": "user failed creating an account"
};
UserActivityLogger.logAction("encourageLoginDialog", data);
} }
bodyLoader.setSource("UsernameCollisionBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader });
} }
onHandleLoginCompleted: { onHandleLoginCompleted: {
console.log("Login Succeeded") console.log("Login Succeeded")
loginSuccess(true)
bodyLoader.setSource("WelcomeBody.qml", { "welcomeBack" : false })
bodyLoader.item.width = root.pane.width
bodyLoader.item.height = root.pane.height
} }
onHandleLoginFailed: { onHandleLoginFailed: {
console.log("Login Failed") console.log("Login Failed")
var poppedUp = Settings.getValue("loginDialogPoppedUp", false);
if (poppedUp) {
console.log("[ENCOURAGELOGINDIALOG]: failed logging in")
var data = {
"action": "user failed logging in"
};
UserActivityLogger.logAction("encourageLoginDialog", data);
}
loginSuccess(false)
} }
} }
} }

View file

@ -32,10 +32,6 @@ Item {
property bool keyboardRaised: false property bool keyboardRaised: false
property bool punctuationMode: false property bool punctuationMode: false
property bool isLogIn: false
property bool atSignIn: false
property bool withSteam: false
onKeyboardRaisedChanged: d.resize(); onKeyboardRaisedChanged: d.resize();
QtObject { QtObject {
@ -105,7 +101,7 @@ Item {
// For the process of logging in. // For the process of logging in.
linkAccountBody.resetContainers(); linkAccountBody.resetContainers();
loggingInContainer.visible = true; loggingInContainer.visible = true;
if (linkAccountBody.withSteam) { if (loginDialog.isSteamRunning()) {
loggingInGlyph.visible = true; loggingInGlyph.visible = true;
loggingInText.text = "Logging in to Steam"; loggingInText.text = "Logging in to Steam";
loggingInText.x = loggingInHeader.width/2 - loggingInTextMetrics.width/2 + loggingInGlyphTextMetrics.width/2; loggingInText.x = loggingInHeader.width/2 - loggingInTextMetrics.width/2 + loggingInGlyphTextMetrics.width/2;
@ -125,7 +121,7 @@ Item {
failureTimer.start(); failureTimer.start();
return; return;
} }
if (linkAccountBody.withSteam) { if (loginDialog.isSteamRunning()) {
// reset the flag. // reset the flag.
linkAccountBody.withSteam = false; linkAccountBody.withSteam = false;
loggingInGlyph.visible = false; loggingInGlyph.visible = false;
@ -141,38 +137,10 @@ Item {
function toggleSignIn(signIn, isLogIn) { function toggleSignIn(signIn, isLogIn) {
// going to/from sign in/up dialog. // going to/from sign in/up dialog.
linkAccountBody.atSignIn = signIn; loginDialog.atSignIn = signIn;
linkAccountBody.isLogIn = isLogIn; loginDialog.isLogIn = isLogIn;
if (signIn) {
usernameField.visible = !isLogIn;
cantAccessContainer.visible = isLogIn;
if (isLogIn) {
loginButtonAtSignIn.text = "Log In";
loginButtonAtSignIn.color = hifi.buttons.black;
emailField.placeholderText = "Username or Email";
var savedUsername = Settings.getValue("wallet/savedUsername", "");
emailField.text = savedUsername === "Unknown user" ? "" : savedUsername;
emailField.anchors.top = loginContainer.top;
emailField.anchors.topMargin = !root.isTablet ? 0.2 * root.pane.height : 0.24 * root.pane.height;
cantAccessContainer.anchors.topMargin = !root.isTablet ? 3.5 * hifi.dimensions.contentSpacing.y : hifi.dimensions.contentSpacing.y;
} else {
loginButtonAtSignIn.text = "Sign Up";
loginButtonAtSignIn.color = hifi.buttons.blue;
emailField.placeholderText = "Email";
emailField.text = "";
emailField.anchors.top = usernameField.bottom;
emailField.anchors.topMargin = 1.5 * hifi.dimensions.contentSpacing.y;
passwordField.text = "";
}
loginErrorMessage.visible = false;
}
splashContainer.visible = !signIn; bodyLoader.setSource("SignInBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader });
topContainer.height = signIn ? root.pane.height : 0.6 * topContainer.height;
bottomContainer.visible = !signIn;
dismissTextContainer.visible = !signIn;
topOpaqueRect.visible = signIn;
loginContainer.visible = signIn;
} }
@ -190,7 +158,6 @@ Item {
color: "black" color: "black"
visible: false visible: false
} }
Item { Item {
id: bannerContainer id: bannerContainer
width: parent.width width: parent.width
@ -206,316 +173,6 @@ Item {
horizontalAlignment: Image.AlignHCenter horizontalAlignment: Image.AlignHCenter
} }
} }
Item {
id: loggingInContainer
width: parent.width
height: parent.height
onHeightChanged: d.resize(); onWidthChanged: d.resize();
visible: false
Item {
id: loggingInHeader
width: parent.width
height: 0.5 * parent.height
anchors {
top: parent.top
}
TextMetrics {
id: loggingInGlyphTextMetrics;
font: loggingInGlyph.font;
text: loggingInGlyph.text;
}
HifiStylesUit.HiFiGlyphs {
id: loggingInGlyph;
text: hifi.glyphs.steamSquare;
// Color
color: "white";
// Size
size: 31;
// Anchors
anchors.right: loggingInText.left;
anchors.rightMargin: linkAccountBody.loggingInGlyphRightMargin
anchors.bottom: parent.bottom;
anchors.bottomMargin: hifi.dimensions.contentSpacing.y
// Alignment
horizontalAlignment: Text.AlignHCenter;
verticalAlignment: Text.AlignVCenter;
visible: loginDialog.isSteamRunning();
}
TextMetrics {
id: loggingInTextMetrics;
font: loggingInText.font;
text: loggingInText.text;
}
Text {
id: loggingInText;
width: loggingInTextMetrics.width
anchors.bottom: parent.bottom;
anchors.bottomMargin: hifi.dimensions.contentSpacing.y
anchors.left: parent.left;
anchors.leftMargin: (parent.width - loggingInTextMetrics.width) / 2
color: "white";
font.family: linkAccountBody.fontFamily
font.pixelSize: linkAccountBody.fontSize
font.bold: linkAccountBody.fontBold
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
text: "Logging in"
}
}
Item {
id: loggingInFooter
width: parent.width
height: 0.5 * parent.height
anchors {
top: loggingInHeader.bottom
}
AnimatedImage {
id: linkAccountSpinner
source: "../../icons/loader-snake-64-w.gif"
width: 128
height: width
anchors.left: parent.left;
anchors.leftMargin: (parent.width - width) / 2;
anchors.top: parent.top
anchors.topMargin: hifi.dimensions.contentSpacing.y
}
TextMetrics {
id: loggedInGlyphTextMetrics;
font: loggedInGlyph.font;
text: loggedInGlyph.text;
}
HifiStylesUit.HiFiGlyphs {
id: loggedInGlyph;
text: hifi.glyphs.steamSquare;
// Size
size: 78;
// Anchors
anchors.left: parent.left;
anchors.leftMargin: (parent.width - loggedInGlyph.size) / 2;
anchors.top: parent.top
anchors.topMargin: hifi.dimensions.contentSpacing.y
// Alignment
horizontalAlignment: Text.AlignHCenter;
verticalAlignment: Text.AlignVCenter;
visible: loginDialog.isSteamRunning();
}
}
}
Item {
id: loginContainer
width: parent.width
height: parent.height - (bannerContainer.height + 1.5 * hifi.dimensions.contentSpacing.y)
anchors {
top: bannerContainer.bottom
topMargin: 1.5 * hifi.dimensions.contentSpacing.y
}
visible: false
Text {
id: loginErrorMessage;
anchors.bottom: emailField.top;
anchors.bottomMargin: 2
anchors.left: emailField.left;
color: "red";
font.family: linkAccountBody.fontFamily
font.pixelSize: 12
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
text: ""
visible: false
}
HifiControlsUit.TextField {
id: usernameField
width: banner.width
font.family: linkAccountBody.fontFamily
placeholderText: "Username"
anchors {
top: parent.top
topMargin: 0.2 * parent.height
left: parent.left
leftMargin: (parent.width - usernameField.width) / 2
}
visible: false
}
HifiControlsUit.TextField {
id: emailField
width: banner.width
font.family: linkAccountBody.fontFamily
text: Settings.getValue("wallet/savedUsername", "");
anchors {
top: parent.top
left: parent.left
leftMargin: (parent.width - emailField.width) / 2
}
focus: true
placeholderText: "Username or Email"
activeFocusOnPress: true
onHeightChanged: d.resize(); onWidthChanged: d.resize();
}
HifiControlsUit.TextField {
id: passwordField
width: banner.width
font.family: linkAccountBody.fontFamily
placeholderText: "Password"
activeFocusOnPress: true
echoMode: passwordFieldMouseArea.showPassword ? TextInput.Normal : TextInput.Password
anchors {
top: emailField.bottom
topMargin: 1.5 * hifi.dimensions.contentSpacing.y
left: parent.left
leftMargin: (parent.width - emailField.width) / 2
}
onFocusChanged: {
root.isPassword = true;
}
Rectangle {
id: showPasswordHitbox
z: 10
x: passwordField.width - ((passwordField.height) * 31 / 23)
width: parent.width - (parent.width - (parent.height * 31/16))
height: parent.height
anchors {
right: parent.right
}
color: "transparent"
Image {
id: showPasswordImage
width: passwordField.height * 16 / 23
height: passwordField.height * 16 / 23
anchors {
right: parent.right
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;
}
}
}
}
Keys.onReturnPressed: {
linkAccountBody.login()
}
}
HifiControlsUit.CheckBox {
id: autoLogoutCheckbox
checked: !Settings.getValue("wallet/autoLogout", false);
text: qsTr("Keep Me Logged In")
boxSize: 18;
labelFontFamily: linkAccountBody.fontFamily
labelFontSize: 18;
color: hifi.colors.white;
anchors {
top: passwordField.bottom;
topMargin: hifi.dimensions.contentSpacing.y;
right: passwordField.right;
}
onCheckedChanged: {
Settings.setValue("wallet/autoLogout", !checked);
if (checked) {
Settings.setValue("wallet/savedUsername", Account.username);
} else {
Settings.setValue("wallet/savedUsername", "");
}
}
Component.onDestruction: {
Settings.setValue("wallet/autoLogout", !checked);
}
}
Item {
id: cancelContainer
width: cancelText.width
height: d.minHeightButton
anchors {
top: autoLogoutCheckbox.bottom
topMargin: hifi.dimensions.contentSpacing.y
left: parent.left
leftMargin: (parent.width - passwordField.width) / 2
}
Text {
id: cancelText
anchors.centerIn: parent
text: qsTr("Cancel");
lineHeight: 1
color: "white"
font.family: linkAccountBody.fontFamily
font.pixelSize: linkAccountBody.fontSize
font.capitalization: Font.AllUppercase;
font.bold: linkAccountBody.fontBold
lineHeightMode: Text.ProportionalHeight
}
MouseArea {
id: cancelArea
anchors.fill: parent
acceptedButtons: Qt.LeftButton
onClicked: {
toggleSignIn(false, true);
linkAccountBody.isLogIn = false;
}
}
}
HifiControlsUit.Button {
id: loginButtonAtSignIn
width: d.minWidthButton
height: d.minHeightButton
text: qsTr("Log In")
fontFamily: linkAccountBody.fontFamily
fontSize: linkAccountBody.fontSize
fontBold: linkAccountBody.fontBold
anchors {
top: cancelContainer.top
right: passwordField.right
}
onClicked: {
linkAccountBody.login()
}
}
Item {
id: cantAccessContainer
width: parent.width
y: usernameField.height
anchors {
top: cancelContainer.bottom
topMargin: 3.5 * hifi.dimensions.contentSpacing.y
}
visible: false
HifiStylesUit.ShortcutText {
id: cantAccessText
z: 10
anchors.centerIn: parent
font.family: linkAccountBody.fontFamily
font.pixelSize: 14
text: "<a href='https://highfidelity.com/users/password/new'> Can't access your account?</a>"
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
linkColor: hifi.colors.blueAccent
onLinkActivated: loginDialog.openUrl(link)
}
}
}
Item { Item {
id: splashContainer id: splashContainer
width: parent.width width: parent.width
@ -653,6 +310,15 @@ Item {
anchors.fill: parent anchors.fill: parent
acceptedButtons: Qt.LeftButton acceptedButtons: Qt.LeftButton
onClicked: { onClicked: {
var poppedUp = Settings.getValue("loginDialogPoppedUp", false);
if (poppedUp) {
console.log("[ENCOURAGELOGINDIALOG]: user dismissed login screen")
var data = {
"action": "user dismissed login screen"
};
Settings.setValue("loginDialogPoppedUp", false);
}
root.tryDestroy(); root.tryDestroy();
} }
} }
@ -727,16 +393,8 @@ Item {
} }
Keys.onPressed: { Keys.onPressed: {
if (!visible && !atSignIn) { if (!visible) {
return; return;
} }
switch (event.key) {
case Qt.Key_Enter:
case Qt.Key_Return:
event.accepted = true
linkAccountBody.login()
break
}
} }
} }

View file

@ -23,6 +23,7 @@ Item {
clip: true clip: true
height: root.pane.height height: root.pane.height
width: root.pane.width width: root.pane.width
property int textFieldHeight: 31
property bool failAfterSignUp: false property bool failAfterSignUp: false
property string fontFamily: "Cairo" property string fontFamily: "Cairo"
property int fontSize: 24 property int fontSize: 24
@ -32,8 +33,6 @@ Item {
property bool keyboardRaised: false property bool keyboardRaised: false
property bool punctuationMode: false property bool punctuationMode: false
property bool logIn: isLogIn
property bool signIn: atSignIn
property bool withSteam: loginDialog.isSteamRunning() property bool withSteam: loginDialog.isSteamRunning()
onKeyboardRaisedChanged: d.resize(); onKeyboardRaisedChanged: d.resize();
@ -50,8 +49,8 @@ Item {
function resize() { function resize() {
maxWidth = root.isTablet ? 1280 : Window.innerWidth; maxWidth = root.isTablet ? 1280 : Window.innerWidth;
maxHeight = root.isTablet ? 720 : Window.innerHeight; maxHeight = root.isTablet ? 720 : Window.innerHeight;
var targetWidth = Math.max(titleWidth, topContainer.width); var targetWidth = Math.max(titleWidth, mainContainer.width);
var targetHeight = hifi.dimensions.contentSpacing.y + topContainer.height + var targetHeight = hifi.dimensions.contentSpacing.y + mainContainer.height +
4 * hifi.dimensions.contentSpacing.y; 4 * hifi.dimensions.contentSpacing.y;
var newWidth = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)); var newWidth = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth));
@ -89,7 +88,7 @@ Item {
function login() { function login() {
signInBody.toggleLoading(); signInBody.toggleLoading();
if (signInBody.isLogIn) { if (loginDialog.isLogIn) {
loginDialog.login(emailField.text, passwordField.text); loginDialog.login(emailField.text, passwordField.text);
} else { } else {
loginDialog.signup(usernameField.text, emailField.text, passwordField.text); loginDialog.signup(usernameField.text, emailField.text, passwordField.text);
@ -105,7 +104,7 @@ Item {
// For the process of logging in. // For the process of logging in.
signInBody.resetContainers(); signInBody.resetContainers();
loggingInContainer.visible = true; loggingInContainer.visible = true;
if (signInBody.withSteam) { if (loginDialog.isSteamRunning()) {
loggingInGlyph.visible = true; loggingInGlyph.visible = true;
loggingInText.text = "Logging in to Steam"; loggingInText.text = "Logging in to Steam";
loggingInText.x = loggingInHeader.width/2 - loggingInTextMetrics.width/2 + loggingInGlyphTextMetrics.width/2; loggingInText.x = loggingInHeader.width/2 - loggingInTextMetrics.width/2 + loggingInGlyphTextMetrics.width/2;
@ -120,12 +119,12 @@ Item {
linkAccountSpinner.visible = false; linkAccountSpinner.visible = false;
if (!success) { if (!success) {
loginErrorMessage.visible = true; loginErrorMessage.visible = true;
loginErrorMessage.text = errorString !== "" ? errorString : signInBody.isLogIn ? "bad user/pass combo." : "unknown error."; loginErrorMessage.text = errorString !== "" ? errorString : "unknown error.";
loginErrorMessage.anchors.bottom = signInBody.isLogIn ? emailField.top : usernameField.top; loginErrorMessage.anchors.bottom = loginDialog.isLogIn ? emailField.top : usernameField.top;
failureTimer.start(); failureTimer.start();
return; return;
} }
if (signInBody.withSteam) { if (loginDialog.isSteamRunning() && !loginDialog.isLogIn) {
// reset the flag. // reset the flag.
signInBody.withSteam = false; signInBody.withSteam = false;
loggingInGlyph.visible = false; loggingInGlyph.visible = false;
@ -141,8 +140,8 @@ Item {
function toggleSignIn(signIn, isLogIn) { function toggleSignIn(signIn, isLogIn) {
// going to/from sign in/up dialog. // going to/from sign in/up dialog.
// signInBody.atSignIn = signIn; loginDialog.atSignIn = signIn;
// signInBody.isLogIn = isLogIn; loginDialog.isLogIn = isLogIn;
if (signIn) { if (signIn) {
usernameField.visible = !isLogIn; usernameField.visible = !isLogIn;
cantAccessContainer.visible = isLogIn; cantAccessContainer.visible = isLogIn;
@ -155,6 +154,9 @@ Item {
emailField.anchors.top = loginContainer.top; emailField.anchors.top = loginContainer.top;
emailField.anchors.topMargin = !root.isTablet ? 0.2 * root.pane.height : 0.24 * root.pane.height; emailField.anchors.topMargin = !root.isTablet ? 0.2 * root.pane.height : 0.24 * root.pane.height;
cantAccessContainer.anchors.topMargin = !root.isTablet ? 3.5 * hifi.dimensions.contentSpacing.y : hifi.dimensions.contentSpacing.y; cantAccessContainer.anchors.topMargin = !root.isTablet ? 3.5 * hifi.dimensions.contentSpacing.y : hifi.dimensions.contentSpacing.y;
} else if (loginDialog.isSteamRunning()) {
signInBody.toggleLoading();
loginDialog.loginWithSteam();
} else { } else {
loginButtonAtSignIn.text = "Sign Up"; loginButtonAtSignIn.text = "Sign Up";
loginButtonAtSignIn.color = hifi.buttons.blue; loginButtonAtSignIn.color = hifi.buttons.blue;
@ -172,13 +174,13 @@ Item {
} }
Item { Item {
id: topContainer id: mainContainer
width: root.pane.width width: root.pane.width
height: root.pane.height height: root.pane.height
onHeightChanged: d.resize(); onWidthChanged: d.resize(); onHeightChanged: d.resize(); onWidthChanged: d.resize();
Rectangle { Rectangle {
id: topOpaqueRect id: opaqueRect
height: parent.height height: parent.height
width: parent.width width: parent.width
opacity: 0.9 opacity: 0.9
@ -284,6 +286,8 @@ Item {
HifiStylesUit.HiFiGlyphs { HifiStylesUit.HiFiGlyphs {
id: loggedInGlyph; id: loggedInGlyph;
text: hifi.glyphs.steamSquare; text: hifi.glyphs.steamSquare;
// color
color: "white"
// Size // Size
size: 78; size: 78;
// Anchors // Anchors
@ -326,6 +330,7 @@ Item {
HifiControlsUit.TextField { HifiControlsUit.TextField {
id: usernameField id: usernameField
width: banner.width width: banner.width
height: signInBody.textFieldHeight
font.family: signInBody.fontFamily font.family: signInBody.fontFamily
placeholderText: "Username" placeholderText: "Username"
anchors { anchors {
@ -340,6 +345,7 @@ Item {
HifiControlsUit.TextField { HifiControlsUit.TextField {
id: emailField id: emailField
width: banner.width width: banner.width
height: signInBody.textFieldHeight
font.family: signInBody.fontFamily font.family: signInBody.fontFamily
text: Settings.getValue("wallet/savedUsername", ""); text: Settings.getValue("wallet/savedUsername", "");
anchors { anchors {
@ -355,6 +361,7 @@ Item {
HifiControlsUit.TextField { HifiControlsUit.TextField {
id: passwordField id: passwordField
width: banner.width width: banner.width
height: signInBody.textFieldHeight
font.family: signInBody.fontFamily font.family: signInBody.fontFamily
placeholderText: "Password" placeholderText: "Password"
activeFocusOnPress: true activeFocusOnPress: true
@ -371,10 +378,10 @@ Item {
} }
Item { Item {
id: showPasswordHitbox id: showPasswordContainer
z: 10 z: 10
x: passwordField.width - ((passwordField.height) * 31 / 23) // width + image's rightMargin
width: parent.width - (parent.width - (parent.height * 31/16)) width: showPasswordImage.width + 8
height: parent.height height: parent.height
anchors { anchors {
right: parent.right right: parent.right
@ -461,7 +468,8 @@ Item {
anchors.fill: parent anchors.fill: parent
acceptedButtons: Qt.LeftButton acceptedButtons: Qt.LeftButton
onClicked: { onClicked: {
bodyLoader.setSource("LinkAccountBody0.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader }); loginDialog.atSignIn = false;
bodyLoader.setSource("LinkAccountBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader });
} }
} }
} }
@ -519,25 +527,27 @@ Item {
root.keyboardRaised = Qt.binding( function() { return keyboardRaised; }) root.keyboardRaised = Qt.binding( function() { return keyboardRaised; })
} }
d.resize(); d.resize();
print(signIn, logIn) print(loginDialog.atSignIn, loginDialog.isLogIn)
toggleSignIn(signIn, logIn) toggleSignIn(loginDialog.atSignIn, loginDialog.isLogIn)
} }
Connections { Connections {
target: loginDialog target: loginDialog
onHandleCreateFailed: { onHandleCreateFailed: {
console.log("Create Failed") console.log("Create Failed")
var error = "There was an unknown error while creating your account. Please try again later.";
loadingSuccess(false, error);
} }
onHandleCreateCompleted: { onHandleCreateCompleted: {
console.log("Create Completed") console.log("Create Completed")
} }
onHandleSignupFailed: { onHandleSignupFailed: {
console.log("Sign Up Failed") console.log("Sign Up Failed")
loadingSuccess(false, errorString) loadingSuccess(false, "");
} }
onHandleSignupCompleted: { onHandleSignupCompleted: {
console.log("Sign Up Completed") console.log("Sign Up Completed");
loadingSuccess(true) loadingSuccess(true, "");
} }
onHandleLoginCompleted: { onHandleLoginCompleted: {
console.log("Login Succeeded") console.log("Login Succeeded")
@ -553,7 +563,7 @@ Item {
if (loginDialog.isSteamRunning()) { if (loginDialog.isSteamRunning()) {
loginDialog.linkSteam(); loginDialog.linkSteam();
} }
loadingSuccess(true) loadingSuccess(true, "")
} }
onHandleLoginFailed: { onHandleLoginFailed: {
console.log("Login Failed") console.log("Login Failed")
@ -566,11 +576,16 @@ Item {
UserActivityLogger.logAction("encourageLoginDialog", data); UserActivityLogger.logAction("encourageLoginDialog", data);
Settings.setValue("loginDialogPoppedUp", false); Settings.setValue("loginDialogPoppedUp", false);
} }
loadingSuccess(false) if (loginDialog.isSteamRunning()) {
bodyLoader.setSource("CompleteProfileBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader });
}
var error = "Username or password incorrect."
loadingSuccess(false, error)
} }
onHandleLinkCompleted: { onHandleLinkCompleted: {
console.log("Link Succeeded") console.log("Link Succeeded")
loadingSuccess(true) loadingSuccess(true, "")
} }
onHandleLinkFailed: { onHandleLinkFailed: {
console.log("Link Failed") console.log("Link Failed")
@ -580,7 +595,7 @@ Item {
} }
Keys.onPressed: { Keys.onPressed: {
if (!visible && !atSignIn) { if (!visible && !loginDialog.atSignIn) {
return; return;
} }