adding final create failure message handling, ui improvements

This commit is contained in:
Wayne Chen 2019-01-16 15:23:56 -08:00
parent aa6b819149
commit 8c2dee20a0
5 changed files with 98 additions and 72 deletions

View file

@ -22,6 +22,7 @@ Item {
width: root.width width: root.width
height: root.height height: root.height
readonly property string termsContainerText: qsTr("By creating this user profile, you agree to High Fidelity's Terms of Service") readonly property string termsContainerText: qsTr("By creating this user profile, you agree to High Fidelity's Terms of Service")
readonly property string termsContainerOculusText: qsTr("By signing up, you agree to High Fidelity's Terms of Service")
readonly property int textFieldHeight: 31 readonly property int textFieldHeight: 31
readonly property string fontFamily: "Raleway" readonly property string fontFamily: "Raleway"
readonly property int fontSize: 15 readonly property int fontSize: 15
@ -86,8 +87,8 @@ Item {
} }
Text { Text {
id: loginErrorMessage; id: loginErrorMessage;
width: root.bannerWidth
color: "red"; color: "red";
width: root.bannerWidth;
font.family: completeProfileBody.fontFamily font.family: completeProfileBody.fontFamily
font.pixelSize: 18 font.pixelSize: 18
font.bold: completeProfileBody.fontBold font.bold: completeProfileBody.fontBold
@ -97,7 +98,7 @@ Item {
visible: true visible: true
} }
Component.onCompleted: { Component.onCompleted: {
if (loginErrorMessageTextMetrics.width > root.bannerWidth && root.isTablet) { if (loginErrorMessageTextMetrics.width > root.bannerWidth) {
loginErrorMessage.wrapMode = Text.WordWrap; loginErrorMessage.wrapMode = Text.WordWrap;
loginErrorMessage.verticalAlignment = Text.AlignLeft; loginErrorMessage.verticalAlignment = Text.AlignLeft;
loginErrorMessage.horizontalAlignment = Text.AlignLeft; loginErrorMessage.horizontalAlignment = Text.AlignLeft;
@ -326,7 +327,7 @@ Item {
width: (parent.width - hifi.dimensions.contentSpacing.x) / 2 width: (parent.width - hifi.dimensions.contentSpacing.x) / 2
height: d.minHeightButton height: d.minHeightButton
text: qsTr("Create your profile") text: completeProfileBody.withOculus ? qsTr("Sign Up") : qsTr("Create your profile")
color: hifi.buttons.blue color: hifi.buttons.blue
fontFamily: completeProfileBody.fontFamily fontFamily: completeProfileBody.fontFamily
@ -344,15 +345,68 @@ Item {
} }
Item { Item {
id: additionalTextContainer id: termsContainer
width: parent.width width: parent.width
height: additionalTextMetrics.height height: termsTextMetrics.height
anchors { anchors {
top: buttons.bottom top: buttons.bottom
horizontalCenter: parent.horizontalCenter horizontalCenter: parent.horizontalCenter
topMargin: hifi.dimensions.contentSpacing.y topMargin: hifi.dimensions.contentSpacing.y
left: parent.left left: parent.left
} }
TextMetrics {
id: termsTextMetrics
font: termsText.font
text: completeProfileBody.withOculus ? completeProfileBody.termsContainerOculusText : completeProfileBody.termsContainerText
Component.onCompleted: {
// with the link.
if (completeProfileBody.withOculus) {
termsText.text = qsTr("By signing up, you agree to <a href='https://highfidelity.com/terms'>High Fidelity's Terms of Service</a>")
} else {
termsText.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: termsText
text: completeProfileBody.withOculus ? completeProfileBody.termsContainerOculusText : completeProfileBody.termsContainerText
font.family: completeProfileBody.fontFamily
font.pixelSize: completeProfileBody.fontSize
font.bold: completeProfileBody.fontBold
wrapMode: Text.WordWrap
color: hifi.colors.white
linkColor: hifi.colors.blueAccent
lineHeight: 1
lineHeightMode: Text.ProportionalHeight
onLinkActivated: loginDialog.openUrl(link);
Component.onCompleted: {
if (termsTextMetrics.width > root.bannerWidth) {
termsText.width = root.bannerWidth;
termsText.wrapMode = Text.WordWrap;
additionalText.verticalAlignment = Text.AlignLeft;
additionalText.horizontalAlignment = Text.AlignLeft;
termsContainer.height = (termsTextMetrics.width / root.bannerWidth) * termsTextMetrics.height;
termsContainer.anchors.left = buttons.left;
} else {
termsText.anchors.centerIn = termsContainer;
}
}
}
}
Item {
id: additionalTextContainer
width: parent.width
height: additionalTextMetrics.height
anchors {
top: termsContainer.bottom
horizontalCenter: parent.horizontalCenter
topMargin: 2 * hifi.dimensions.contentSpacing.y
left: parent.left
}
TextMetrics { TextMetrics {
id: additionalTextMetrics id: additionalTextMetrics
@ -363,7 +417,7 @@ Item {
HifiStylesUit.ShortcutText { HifiStylesUit.ShortcutText {
id: additionalText id: additionalText
text: "<a href='https://fake.link'>Already have a High Fidelity profile? Link to an existing profile here.</a>" text: "<a href='https://fake.link'>Already have a High Fidelity profile? Link to an existing profile here.</a>"
width: root.bannerWidth;
font.family: completeProfileBody.fontFamily font.family: completeProfileBody.fontFamily
font.pixelSize: completeProfileBody.fontSize font.pixelSize: completeProfileBody.fontSize
font.bold: completeProfileBody.fontBold font.bold: completeProfileBody.fontBold
@ -380,8 +434,7 @@ Item {
"linkOculus": completeProfileBody.withOculus }); "linkOculus": completeProfileBody.withOculus });
} }
Component.onCompleted: { Component.onCompleted: {
if (additionalTextMetrics.width > root.bannerWidth && root.isTablet) { if (additionalTextMetrics.width > root.bannerWidth) {
additionalText.width = root.bannerWidth;
additionalText.wrapMode = Text.WordWrap; additionalText.wrapMode = Text.WordWrap;
additionalText.verticalAlignment = Text.AlignLeft; additionalText.verticalAlignment = Text.AlignLeft;
additionalText.horizontalAlignment = Text.AlignLeft; additionalText.horizontalAlignment = Text.AlignLeft;
@ -393,55 +446,6 @@ Item {
} }
} }
} }
Item {
id: termsContainer
width: parent.width
height: termsTextMetrics.height
anchors {
top: additionalTextContainer.bottom
horizontalCenter: parent.horizontalCenter
topMargin: 2 * hifi.dimensions.contentSpacing.y
left: parent.left
}
TextMetrics {
id: termsTextMetrics
font: termsText.font
text: completeProfileBody.termsContainerText
Component.onCompleted: {
// with the link.
termsText.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: termsText
text: completeProfileBody.termsContainerText
font.family: completeProfileBody.fontFamily
font.pixelSize: completeProfileBody.fontSize
font.bold: completeProfileBody.fontBold
wrapMode: Text.WordWrap
color: hifi.colors.lightGray
linkColor: hifi.colors.blueAccent
lineHeight: 1
lineHeightMode: Text.ProportionalHeight
onLinkActivated: loginDialog.openUrl(link);
Component.onCompleted: {
if (termsTextMetrics.width > root.bannerWidth && root.isTablet) {
termsText.width = root.bannerWidth;
termsText.wrapMode = Text.WordWrap;
additionalText.verticalAlignment = Text.AlignLeft;
additionalText.horizontalAlignment = Text.AlignLeft;
termsContainer.height = (termsTextMetrics.width / root.bannerWidth) * termsTextMetrics.height;
termsContainer.anchors.left = buttons.left;
} else {
termsText.anchors.centerIn = termsContainer;
}
}
}
}
} }
} }
@ -463,7 +467,7 @@ Item {
loginErrorMessage.visible = true; loginErrorMessage.visible = true;
loginErrorMessage.text = error; loginErrorMessage.text = error;
if (loginErrorMessageTextMetrics.width > root.bannerWidth && root.isTablet) { if (loginErrorMessageTextMetrics.width > root.bannerWidth) {
loginErrorMessage.wrapMode = Text.WordWrap; loginErrorMessage.wrapMode = Text.WordWrap;
loginErrorMessage.verticalAlignment = Text.AlignLeft; loginErrorMessage.verticalAlignment = Text.AlignLeft;
loginErrorMessage.horizontalAlignment = Text.AlignLeft; loginErrorMessage.horizontalAlignment = Text.AlignLeft;
@ -487,5 +491,6 @@ Item {
} }
d.resize(); d.resize();
root.text = ""; root.text = "";
usernameField.forceActiveFocus();
} }
} }

View file

@ -278,7 +278,7 @@ Item {
bodyLoader.setSource("CompleteProfileBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": loggingInBody.withSteam, bodyLoader.setSource("CompleteProfileBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": loggingInBody.withSteam,
"withOculus": loggingInBody.withOculus, "errorString": errorString }); "withOculus": loggingInBody.withOculus, "errorString": errorString });
} else if (loggingInBody.withOculus) { } else if (loggingInBody.withOculus) {
errorString = "Your Oculus authentication has failed. Please make sure you are logged into Oculus and try again." errorString = "Your Oculus account is not connected to an existing High Fidelity account. Please create a new one."
bodyLoader.setSource("CompleteProfileBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": loggingInBody.withSteam, bodyLoader.setSource("CompleteProfileBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": loggingInBody.withSteam,
"withOculus": loggingInBody.withOculus, "errorString": errorString }); "withOculus": loggingInBody.withOculus, "errorString": errorString });
} else { } else {

View file

@ -392,7 +392,7 @@ Item {
font.pixelSize: signUpBody.fontSize font.pixelSize: signUpBody.fontSize
font.bold: signUpBody.fontBold font.bold: signUpBody.fontBold
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
color: hifi.colors.lightGray color: hifi.colors.white
linkColor: hifi.colors.blueAccent linkColor: hifi.colors.blueAccent
lineHeight: 1 lineHeight: 1
lineHeightMode: Text.ProportionalHeight lineHeightMode: Text.ProportionalHeight
@ -400,7 +400,7 @@ Item {
onLinkActivated: loginDialog.openUrl(link); onLinkActivated: loginDialog.openUrl(link);
Component.onCompleted: { Component.onCompleted: {
if (termsTextMetrics.width > root.bannerWidth && root.isTablet) { if (termsTextMetrics.width > root.bannerWidth) {
termsText.width = root.bannerWidth; termsText.width = root.bannerWidth;
termsText.wrapMode = Text.WordWrap; termsText.wrapMode = Text.WordWrap;
additionalText.verticalAlignment = Text.AlignLeft; additionalText.verticalAlignment = Text.AlignLeft;
@ -467,6 +467,7 @@ Item {
loginErrorMessage.text = errorStringEdited; loginErrorMessage.text = errorStringEdited;
loginErrorMessageTextMetrics.text = errorString; loginErrorMessageTextMetrics.text = errorString;
if (loginErrorMessageTextMetrics.width > usernameField.width) { if (loginErrorMessageTextMetrics.width > usernameField.width) {
loginErrorMessage.width = root.bannerWidth;
loginErrorMessage.wrapMode = Text.WordWrap; loginErrorMessage.wrapMode = Text.WordWrap;
loginErrorMessage.verticalAlignment = Text.AlignLeft; loginErrorMessage.verticalAlignment = Text.AlignLeft;
loginErrorMessage.horizontalAlignment = Text.AlignLeft; loginErrorMessage.horizontalAlignment = Text.AlignLeft;

View file

@ -227,7 +227,7 @@ Item {
font.pixelSize: usernameCollisionBody.fontSize font.pixelSize: usernameCollisionBody.fontSize
font.bold: usernameCollisionBody.fontBold font.bold: usernameCollisionBody.fontBold
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
color: hifi.colors.lightGray color: hifi.colors.white
linkColor: hifi.colors.blueAccent linkColor: hifi.colors.blueAccent
lineHeight: 1 lineHeight: 1
lineHeightMode: Text.ProportionalHeight lineHeightMode: Text.ProportionalHeight
@ -235,7 +235,7 @@ Item {
onLinkActivated: loginDialog.openUrl(link); onLinkActivated: loginDialog.openUrl(link);
Component.onCompleted: { Component.onCompleted: {
if (termsTextMetrics.width > root.bannerWidth && root.isTablet) { if (termsTextMetrics.width > root.bannerWidth) {
termsText.width = root.bannerWidth; termsText.width = root.bannerWidth;
termsText.wrapMode = Text.WordWrap; termsText.wrapMode = Text.WordWrap;
additionalText.verticalAlignment = Text.AlignLeft; additionalText.verticalAlignment = Text.AlignLeft;

View file

@ -294,7 +294,6 @@ void LoginDialog::createCompleted(QNetworkReply* reply) {
void LoginDialog::createFailed(QNetworkReply* reply) { void LoginDialog::createFailed(QNetworkReply* reply) {
if (isOculusRunning()) { if (isOculusRunning()) {
auto replyData = reply->readAll(); auto replyData = reply->readAll();
qDebug() << replyData;
QJsonParseError parseError; QJsonParseError parseError;
auto doc = QJsonDocument::fromJson(replyData, &parseError); auto doc = QJsonDocument::fromJson(replyData, &parseError);
if (parseError.error != QJsonParseError::NoError) { if (parseError.error != QJsonParseError::NoError) {
@ -307,21 +306,42 @@ void LoginDialog::createFailed(QNetworkReply* reply) {
auto error = data.value("error").toObject(); auto error = data.value("error").toObject();
auto identity = error.value("identity"); auto identity = error.value("identity");
auto user = error.value("username"); auto user = error.value("username");
qDebug() << user.isArray() << " " << user.isObject() << " " << user.isString() << " " << user.isUndefined() << " " << user.isNull(); auto email = error.value("email");
QString usernameError;
QString emailError;
QString identityError;
QString errorReply;
if (!user.isNull() && !user.isUndefined()) { if (!user.isNull() && !user.isUndefined()) {
QJsonArray arr = user.toArray(); QJsonArray arr = user.toArray();
if (!arr.isEmpty()) { if (!arr.isEmpty()) {
auto firstError = arr.at(0).toString(); usernameError = "Username " + arr.at(0).toString() + ".";
qDebug() << firstError;
emit handleCreateFailed("Username " + firstError);
} }
} }
if (!identity.isNull()) { if (!email.isNull() && !email.isUndefined()) {
QJsonArray arr = email.toArray();
if (!arr.isEmpty()) {
emailError = "Email " + arr.at(0).toString() + ".";
}
}
if (!usernameError.isEmpty()) {
errorReply = usernameError;
if (!emailError.isEmpty()) {
errorReply.append(" " + emailError);
}
emit handleCreateFailed(errorReply);
return;
}
if (!emailError.isEmpty()) {
emit handleCreateFailed(emailError);
return;
}
if (!identity.isNull() && !identity.isUndefined()) {
QJsonArray arr = identity.toArray(); QJsonArray arr = identity.toArray();
if (!arr.isEmpty()) { if (!arr.isEmpty()) {
auto firstError = arr.at(0).toString(); auto identityError = "Identity " + arr.at(0).toString() + ".";
qDebug() << firstError; emit handleCreateFailed(identityError);
emit handleCreateFailed(firstError); return;
} }
} }
} }