mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
adding final create failure message handling, ui improvements
This commit is contained in:
parent
c54bce3953
commit
f4d4220e58
5 changed files with 98 additions and 72 deletions
|
@ -22,6 +22,7 @@ Item {
|
|||
width: root.width
|
||||
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 termsContainerOculusText: qsTr("By signing up, you agree to High Fidelity's Terms of Service")
|
||||
readonly property int textFieldHeight: 31
|
||||
readonly property string fontFamily: "Raleway"
|
||||
readonly property int fontSize: 15
|
||||
|
@ -86,8 +87,8 @@ Item {
|
|||
}
|
||||
Text {
|
||||
id: loginErrorMessage;
|
||||
width: root.bannerWidth
|
||||
color: "red";
|
||||
width: root.bannerWidth;
|
||||
font.family: completeProfileBody.fontFamily
|
||||
font.pixelSize: 18
|
||||
font.bold: completeProfileBody.fontBold
|
||||
|
@ -97,7 +98,7 @@ Item {
|
|||
visible: true
|
||||
}
|
||||
Component.onCompleted: {
|
||||
if (loginErrorMessageTextMetrics.width > root.bannerWidth && root.isTablet) {
|
||||
if (loginErrorMessageTextMetrics.width > root.bannerWidth) {
|
||||
loginErrorMessage.wrapMode = Text.WordWrap;
|
||||
loginErrorMessage.verticalAlignment = Text.AlignLeft;
|
||||
loginErrorMessage.horizontalAlignment = Text.AlignLeft;
|
||||
|
@ -326,7 +327,7 @@ Item {
|
|||
width: (parent.width - hifi.dimensions.contentSpacing.x) / 2
|
||||
height: d.minHeightButton
|
||||
|
||||
text: qsTr("Create your profile")
|
||||
text: completeProfileBody.withOculus ? qsTr("Sign Up") : qsTr("Create your profile")
|
||||
color: hifi.buttons.blue
|
||||
|
||||
fontFamily: completeProfileBody.fontFamily
|
||||
|
@ -344,15 +345,68 @@ Item {
|
|||
}
|
||||
|
||||
Item {
|
||||
id: additionalTextContainer
|
||||
id: termsContainer
|
||||
width: parent.width
|
||||
height: additionalTextMetrics.height
|
||||
height: termsTextMetrics.height
|
||||
anchors {
|
||||
top: buttons.bottom
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
topMargin: hifi.dimensions.contentSpacing.y
|
||||
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 {
|
||||
id: additionalTextMetrics
|
||||
|
@ -363,7 +417,7 @@ Item {
|
|||
HifiStylesUit.ShortcutText {
|
||||
id: additionalText
|
||||
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.pixelSize: completeProfileBody.fontSize
|
||||
font.bold: completeProfileBody.fontBold
|
||||
|
@ -380,8 +434,7 @@ Item {
|
|||
"linkOculus": completeProfileBody.withOculus });
|
||||
}
|
||||
Component.onCompleted: {
|
||||
if (additionalTextMetrics.width > root.bannerWidth && root.isTablet) {
|
||||
additionalText.width = root.bannerWidth;
|
||||
if (additionalTextMetrics.width > root.bannerWidth) {
|
||||
additionalText.wrapMode = Text.WordWrap;
|
||||
additionalText.verticalAlignment = 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.text = error;
|
||||
|
||||
if (loginErrorMessageTextMetrics.width > root.bannerWidth && root.isTablet) {
|
||||
if (loginErrorMessageTextMetrics.width > root.bannerWidth) {
|
||||
loginErrorMessage.wrapMode = Text.WordWrap;
|
||||
loginErrorMessage.verticalAlignment = Text.AlignLeft;
|
||||
loginErrorMessage.horizontalAlignment = Text.AlignLeft;
|
||||
|
@ -487,5 +491,6 @@ Item {
|
|||
}
|
||||
d.resize();
|
||||
root.text = "";
|
||||
usernameField.forceActiveFocus();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -278,7 +278,7 @@ Item {
|
|||
bodyLoader.setSource("CompleteProfileBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": loggingInBody.withSteam,
|
||||
"withOculus": loggingInBody.withOculus, "errorString": errorString });
|
||||
} 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,
|
||||
"withOculus": loggingInBody.withOculus, "errorString": errorString });
|
||||
} else {
|
||||
|
|
|
@ -392,7 +392,7 @@ Item {
|
|||
font.pixelSize: signUpBody.fontSize
|
||||
font.bold: signUpBody.fontBold
|
||||
wrapMode: Text.WordWrap
|
||||
color: hifi.colors.lightGray
|
||||
color: hifi.colors.white
|
||||
linkColor: hifi.colors.blueAccent
|
||||
lineHeight: 1
|
||||
lineHeightMode: Text.ProportionalHeight
|
||||
|
@ -400,7 +400,7 @@ Item {
|
|||
onLinkActivated: loginDialog.openUrl(link);
|
||||
|
||||
Component.onCompleted: {
|
||||
if (termsTextMetrics.width > root.bannerWidth && root.isTablet) {
|
||||
if (termsTextMetrics.width > root.bannerWidth) {
|
||||
termsText.width = root.bannerWidth;
|
||||
termsText.wrapMode = Text.WordWrap;
|
||||
additionalText.verticalAlignment = Text.AlignLeft;
|
||||
|
@ -467,6 +467,7 @@ Item {
|
|||
loginErrorMessage.text = errorStringEdited;
|
||||
loginErrorMessageTextMetrics.text = errorString;
|
||||
if (loginErrorMessageTextMetrics.width > usernameField.width) {
|
||||
loginErrorMessage.width = root.bannerWidth;
|
||||
loginErrorMessage.wrapMode = Text.WordWrap;
|
||||
loginErrorMessage.verticalAlignment = Text.AlignLeft;
|
||||
loginErrorMessage.horizontalAlignment = Text.AlignLeft;
|
||||
|
|
|
@ -227,7 +227,7 @@ Item {
|
|||
font.pixelSize: usernameCollisionBody.fontSize
|
||||
font.bold: usernameCollisionBody.fontBold
|
||||
wrapMode: Text.WordWrap
|
||||
color: hifi.colors.lightGray
|
||||
color: hifi.colors.white
|
||||
linkColor: hifi.colors.blueAccent
|
||||
lineHeight: 1
|
||||
lineHeightMode: Text.ProportionalHeight
|
||||
|
@ -235,7 +235,7 @@ Item {
|
|||
onLinkActivated: loginDialog.openUrl(link);
|
||||
|
||||
Component.onCompleted: {
|
||||
if (termsTextMetrics.width > root.bannerWidth && root.isTablet) {
|
||||
if (termsTextMetrics.width > root.bannerWidth) {
|
||||
termsText.width = root.bannerWidth;
|
||||
termsText.wrapMode = Text.WordWrap;
|
||||
additionalText.verticalAlignment = Text.AlignLeft;
|
||||
|
|
|
@ -294,7 +294,6 @@ void LoginDialog::createCompleted(QNetworkReply* reply) {
|
|||
void LoginDialog::createFailed(QNetworkReply* reply) {
|
||||
if (isOculusRunning()) {
|
||||
auto replyData = reply->readAll();
|
||||
qDebug() << replyData;
|
||||
QJsonParseError parseError;
|
||||
auto doc = QJsonDocument::fromJson(replyData, &parseError);
|
||||
if (parseError.error != QJsonParseError::NoError) {
|
||||
|
@ -307,21 +306,42 @@ void LoginDialog::createFailed(QNetworkReply* reply) {
|
|||
auto error = data.value("error").toObject();
|
||||
auto identity = error.value("identity");
|
||||
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()) {
|
||||
QJsonArray arr = user.toArray();
|
||||
if (!arr.isEmpty()) {
|
||||
auto firstError = arr.at(0).toString();
|
||||
qDebug() << firstError;
|
||||
emit handleCreateFailed("Username " + firstError);
|
||||
usernameError = "Username " + arr.at(0).toString() + ".";
|
||||
}
|
||||
}
|
||||
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();
|
||||
if (!arr.isEmpty()) {
|
||||
auto firstError = arr.at(0).toString();
|
||||
qDebug() << firstError;
|
||||
emit handleCreateFailed(firstError);
|
||||
auto identityError = "Identity " + arr.at(0).toString() + ".";
|
||||
emit handleCreateFailed(identityError);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue