From 801a3846071733d93fc27162f4dcf37cf7ec3d97 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 7 Dec 2016 16:14:20 -0800 Subject: [PATCH 01/12] a simple signup dialog copied from login dialog --- interface/resources/qml/SignupDialog.qml | 257 +++++++++++++++++++++++ interface/src/Application.cpp | 2 + interface/src/ui/DialogsManager.cpp | 3 +- interface/src/ui/SignupDialog.cpp | 52 +++++ interface/src/ui/SignupDialog.h | 40 ++++ 5 files changed, 353 insertions(+), 1 deletion(-) create mode 100644 interface/resources/qml/SignupDialog.qml create mode 100644 interface/src/ui/SignupDialog.cpp create mode 100644 interface/src/ui/SignupDialog.h diff --git a/interface/resources/qml/SignupDialog.qml b/interface/resources/qml/SignupDialog.qml new file mode 100644 index 0000000000..a7ff9d975d --- /dev/null +++ b/interface/resources/qml/SignupDialog.qml @@ -0,0 +1,257 @@ +// +// SignupDialog.qml +// +// Created by David Rowe on 7 Dec 2016 +// Copyright 2015 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +import Hifi 1.0 +import QtQuick 2.4 + +import "controls-uit" +import "styles-uit" +import "windows" + +import "SignupDialog" + +ModalWindow { + id: root + HifiConstants { id: hifi } + objectName: "SignupDialog" + implicitWidth: 520 + implicitHeight: 320 + destroyOnCloseButton: true + destroyOnHidden: true + visible: true + + property string iconText: "" + property int iconSize: 50 + + property string title: "" + property int titleWidth: 0 + + keyboardOverride: true // Disable ModalWindow's keyboard. + + SignupDialog { + id: signupDialog + + Item { + id: signupBody + clip: true + width: root.pane.width + height: root.pane.height + + function signup() { + mainTextContainer.visible = false + signupDialog.signup(usernameField.text, passwordField.text) + } + + property bool keyboardEnabled: false + property bool keyboardRaised: false + property bool punctuationMode: false + + onKeyboardRaisedChanged: d.resize(); + + QtObject { + id: d + readonly property int minWidth: 480 + readonly property int maxWidth: 1280 + readonly property int minHeight: 120 + readonly property int maxHeight: 720 + + function resize() { + var targetWidth = Math.max(titleWidth, form.contentWidth); + var targetHeight = hifi.dimensions.contentSpacing.y + mainTextContainer.height + + 4 * hifi.dimensions.contentSpacing.y + form.height + + hifi.dimensions.contentSpacing.y + buttons.height; + + if (additionalInformation.visible) { + targetWidth = Math.max(targetWidth, additionalInformation.width); + targetHeight += hifi.dimensions.contentSpacing.y + additionalInformation.height + } + + root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)); + root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) + + (keyboardEnabled && keyboardRaised ? (200 + 2 * hifi.dimensions.contentSpacing.y) : hifi.dimensions.contentSpacing.y); + } + } + + ShortcutText { + id: mainTextContainer + anchors { + top: parent.top + left: parent.left + margins: 0 + topMargin: hifi.dimensions.contentSpacing.y + } + + visible: false + + text: qsTr("Username or password incorrect.") + wrapMode: Text.WordWrap + color: hifi.colors.redAccent + lineHeight: 1 + lineHeightMode: Text.ProportionalHeight + horizontalAlignment: Text.AlignHCenter + } + + Column { + id: form + anchors { + top: mainTextContainer.bottom + left: parent.left + margins: 0 + topMargin: 2 * hifi.dimensions.contentSpacing.y + } + spacing: 2 * hifi.dimensions.contentSpacing.y + + Row { + spacing: hifi.dimensions.contentSpacing.x + + TextField { + id: usernameField + anchors { + verticalCenter: parent.verticalCenter + } + width: 350 + + label: "User Name or Email" + } + } + Row { + spacing: hifi.dimensions.contentSpacing.x + + TextField { + id: passwordField + anchors { + verticalCenter: parent.verticalCenter + } + width: 350 + + label: "Password" + echoMode: TextInput.Password + } + } + + } + + // Override ScrollingWindow's keyboard that would be at very bottom of dialog. + Keyboard { + raised: keyboardEnabled && keyboardRaised + numeric: punctuationMode + anchors { + left: parent.left + right: parent.right + bottom: buttons.top + bottomMargin: keyboardRaised ? 2 * hifi.dimensions.contentSpacing.y : 0 + } + } + + Row { + id: buttons + anchors { + right: parent.right + bottom: parent.bottom + bottomMargin: hifi.dimensions.contentSpacing.y + } + spacing: hifi.dimensions.contentSpacing.x + onHeightChanged: d.resize(); onWidthChanged: d.resize(); + + Button { + id: linkAccountButton + anchors.verticalCenter: parent.verticalCenter + width: 200 + + text: qsTr("Signup") + color: hifi.buttons.blue + + onClicked: signupBody.signup() + } + + Button { + anchors.verticalCenter: parent.verticalCenter + + text: qsTr("Cancel") + + onClicked: root.destroy() + } + } + + Component.onCompleted: { + root.title = qsTr("Sign into High Fidelity") + root.iconText = "<" + keyboardEnabled = HMD.active; + d.resize(); + + usernameField.forceActiveFocus(); + } + + Connections { + target: signupDialog + onHandleSignupCompleted: { + console.log("Signup Succeeded") + + bodyLoader.setSource("WelcomeBody.qml", { "welcomeBack" : true }) + bodyLoader.item.width = root.pane.width + bodyLoader.item.height = root.pane.height + } + onHandleSignupFailed: { + console.log("Signup Failed") + mainTextContainer.visible = true + } + } + + Keys.onPressed: { + if (!visible) { + return + } + + switch (event.key) { + case Qt.Key_Enter: + case Qt.Key_Return: + event.accepted = true + signupBody.signup() + break + } + } + } + } + + Keys.onPressed: { + if (!visible) { + return + } + + if (event.modifiers === Qt.ControlModifier) + switch (event.key) { + case Qt.Key_A: + event.accepted = true + detailedText.selectAll() + break + case Qt.Key_C: + event.accepted = true + detailedText.copy() + break + case Qt.Key_Period: + if (Qt.platform.os === "osx") { + event.accepted = true + content.reject() + } + break + } else switch (event.key) { + case Qt.Key_Escape: + case Qt.Key_Back: + event.accepted = true + destroy() + break + + case Qt.Key_Enter: + case Qt.Key_Return: + event.accepted = true + break + } + } +} diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index c6150dcc53..b85947272c 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -153,6 +153,7 @@ #include "ui/DialogsManager.h" #include "ui/LoginDialog.h" #include "ui/overlays/Cube3DOverlay.h" +#include "ui/SignupDialog.h" #include "ui/Snapshot.h" #include "ui/SnapshotAnimated.h" #include "ui/StandAloneJSConsole.h" @@ -1751,6 +1752,7 @@ void Application::initializeUi() { AddressBarDialog::registerType(); ErrorDialog::registerType(); LoginDialog::registerType(); + SignupDialog::registerType(); Tooltip::registerType(); UpdateDialog::registerType(); qmlRegisterType("Hifi", 1, 0, "Preference"); diff --git a/interface/src/ui/DialogsManager.cpp b/interface/src/ui/DialogsManager.cpp index 03c71d8573..a4cd674dfd 100644 --- a/interface/src/ui/DialogsManager.cpp +++ b/interface/src/ui/DialogsManager.cpp @@ -30,6 +30,7 @@ #include "OctreeStatsDialog.h" #include "PreferencesDialog.h" #include "ScriptEditorWindow.h" +#include "SignupDialog.h" #include "UpdateDialog.h" template @@ -74,7 +75,7 @@ void DialogsManager::toggleDiskCacheEditor() { } void DialogsManager::toggleLoginDialog() { - LoginDialog::toggleAction(); + SignupDialog::show(); } void DialogsManager::showLoginDialog() { diff --git a/interface/src/ui/SignupDialog.cpp b/interface/src/ui/SignupDialog.cpp new file mode 100644 index 0000000000..a9d575a4df --- /dev/null +++ b/interface/src/ui/SignupDialog.cpp @@ -0,0 +1,52 @@ +// +// SignupDialog.cpp +// interface/src/ui +// +// Created by Stephen Birarda on December 7 2016 +// Copyright 2016 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "SignupDialog.h" + +#include + +#include + +HIFI_QML_DEF(SignupDialog) + +SignupDialog::SignupDialog(QQuickItem *parent) : OffscreenQmlDialog(parent) { + +} + +void SignupDialog::signup(const QString& username, const QString& password) { + + JSONCallbackParameters callbackParams; + callbackParams.jsonCallbackReceiver = this; + callbackParams.jsonCallbackMethod = "signupCompleted"; + callbackParams.errorCallbackReceiver = this; + callbackParams.errorCallbackMethod = "signupFailed"; + + QJsonObject payload; + payload.insert("username", username); + payload.insert("password", password); + + static const QString API_SIGNUP_PATH = "api/v1/users"; + + qDebug() << "Sending a request to create an account for" << username; + + auto accountManager = DependencyManager::get(); + accountManager->sendRequest(API_SIGNUP_PATH, AccountManagerAuth::None, + QNetworkAccessManager::PostOperation, callbackParams, + QJsonDocument(payload).toJson()); +} + +void SignupDialog::signupCompleted(QNetworkReply& reply) { + emit handleSignupCompleted(); +} + +void SignupDialog::signupFailed(QNetworkReply& reply) { + +} diff --git a/interface/src/ui/SignupDialog.h b/interface/src/ui/SignupDialog.h new file mode 100644 index 0000000000..6d51f54c9f --- /dev/null +++ b/interface/src/ui/SignupDialog.h @@ -0,0 +1,40 @@ +// +// SignupDialog.h +// interface/src/ui +// +// Created by Stephen Birarda on December 7 2016 +// Copyright 2016 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#pragma once + +#ifndef hifi_SignupDialog_h +#define hifi_SignupDialog_h + +#include + +class QNetworkReply; + +class SignupDialog : public OffscreenQmlDialog { + Q_OBJECT + HIFI_QML_DECL + +public: + SignupDialog(QQuickItem* parent = nullptr); + +public slots: + void signupCompleted(QNetworkReply& reply); + void signupFailed(QNetworkReply& reply); + +signals: + void handleSignupCompleted(); + void handleSignupFailed(QString error); + +protected slots: + Q_INVOKABLE void signup(const QString& username, const QString& password); +}; + +#endif // hifi_SignupDialog_h From 556ccb90f7459b2c7644596f9649a27d96507a1a Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 8 Dec 2016 14:35:41 -0800 Subject: [PATCH 02/12] make a SignUpBody loaded by LoginDialog --- .../qml/LoginDialog/LinkAccountBody.qml | 29 ++ .../resources/qml/LoginDialog/SignUpBody.qml | 247 +++++++++++++++++ interface/resources/qml/SignupDialog.qml | 257 ------------------ interface/src/Application.cpp | 2 - interface/src/ui/DialogsManager.cpp | 3 +- interface/src/ui/LoginDialog.cpp | 30 ++ interface/src/ui/LoginDialog.h | 8 + interface/src/ui/SignupDialog.cpp | 52 ---- interface/src/ui/SignupDialog.h | 40 --- 9 files changed, 315 insertions(+), 353 deletions(-) create mode 100644 interface/resources/qml/LoginDialog/SignUpBody.qml delete mode 100644 interface/resources/qml/SignupDialog.qml delete mode 100644 interface/src/ui/SignupDialog.cpp delete mode 100644 interface/src/ui/SignupDialog.h diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index fbcb3d5e37..89211a998d 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -173,6 +173,35 @@ Item { } } + Row { + id: leftButton + anchors { + left: parent.left + bottom: parent.bottom + bottomMargin: hifi.dimensions.contentSpacing.y + } + + spacing: hifi.dimensions.contentSpacing.x + onHeightChanged: d.resize(); onWidthChanged: d.resize(); + + Button { + id: signupButton + + anchors.verticalCenter: parent.verticalCenter + + width: 150 + + text: qsTr("Sign Up") + visible: !loginDialog.isSteamRunning() + + onClicked: { + bodyLoader.setSource("SignUpBody.qml") + bodyLoader.item.width = root.pane.width + bodyLoader.item.height = root.pane.height + } + } + } + Row { id: buttons anchors { diff --git a/interface/resources/qml/LoginDialog/SignUpBody.qml b/interface/resources/qml/LoginDialog/SignUpBody.qml new file mode 100644 index 0000000000..e3f8374d94 --- /dev/null +++ b/interface/resources/qml/LoginDialog/SignUpBody.qml @@ -0,0 +1,247 @@ +// +// SignUpBody.qml +// +// Created by Stephen Birarda on 7 Dec 2016 +// Copyright 2016 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +import Hifi 1.0 +import QtQuick 2.4 +import QtQuick.Controls 1.4 +import QtQuick.Controls.Styles 1.4 as OriginalStyles + +import "../controls-uit" +import "../styles-uit" + +Item { + id: signupBody + clip: true + width: root.pane.width + height: root.pane.height + + function signup() { + mainTextContainer.visible = false + loginDialog.signup(usernameField.text, passwordField.text) + } + + property bool keyboardEnabled: false + property bool keyboardRaised: false + property bool punctuationMode: false + + onKeyboardRaisedChanged: d.resize(); + + QtObject { + id: d + readonly property int minWidth: 480 + readonly property int maxWidth: 1280 + readonly property int minHeight: 120 + readonly property int maxHeight: 720 + + function resize() { + var targetWidth = Math.max(titleWidth, form.contentWidth); + var targetHeight = hifi.dimensions.contentSpacing.y + mainTextContainer.height + + 4 * hifi.dimensions.contentSpacing.y + form.height + + hifi.dimensions.contentSpacing.y + buttons.height; + + root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)); + root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) + + (keyboardEnabled && keyboardRaised ? (200 + 2 * hifi.dimensions.contentSpacing.y) : hifi.dimensions.contentSpacing.y); + } + } + + ShortcutText { + id: mainTextContainer + anchors { + top: parent.top + left: parent.left + margins: 0 + topMargin: hifi.dimensions.contentSpacing.y + } + + visible: false + + text: qsTr("Username or password incorrect.") + wrapMode: Text.WordWrap + color: hifi.colors.redAccent + lineHeight: 1 + lineHeightMode: Text.ProportionalHeight + horizontalAlignment: Text.AlignHCenter + } + + Column { + id: form + anchors { + top: mainTextContainer.bottom + left: parent.left + margins: 0 + topMargin: 2 * hifi.dimensions.contentSpacing.y + } + spacing: 2 * hifi.dimensions.contentSpacing.y + + Row { + spacing: hifi.dimensions.contentSpacing.x + + TextField { + id: usernameField + anchors { + verticalCenter: parent.verticalCenter + } + width: 350 + + label: "Username" + } + + ShortcutText { + anchors { + verticalCenter: parent.verticalCenter + } + + wrapMode: Text.WordWrap + lineHeight: 1 + lineHeightMode: Text.ProportionalHeight + + text: qsTr("Must be unique. No spaces or other special characters") + + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + + color: hifi.colors.blueAccent + } + } + Row { + spacing: hifi.dimensions.contentSpacing.x + + TextField { + id: passwordField + anchors { + verticalCenter: parent.verticalCenter + } + width: 350 + + label: "Password" + echoMode: TextInput.Password + } + + ShortcutText { + anchors { + verticalCenter: parent.verticalCenter + } + + text: qsTr("At least 6 characters") + + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + + color: hifi.colors.blueAccent + } + } + + } + + // Override ScrollingWindow's keyboard that would be at very bottom of dialog. + Keyboard { + raised: keyboardEnabled && keyboardRaised + numeric: punctuationMode + anchors { + left: parent.left + right: parent.right + bottom: buttons.top + bottomMargin: keyboardRaised ? 2 * hifi.dimensions.contentSpacing.y : 0 + } + } + + Row { + id: leftButton + anchors { + left: parent.left + bottom: parent.bottom + bottomMargin: hifi.dimensions.contentSpacing.y + } + + spacing: hifi.dimensions.contentSpacing.x + onHeightChanged: d.resize(); onWidthChanged: d.resize(); + + Button { + anchors.verticalCenter: parent.verticalCenter + + text: qsTr("Existing User") + + onClicked: { + bodyLoader.setSource("LinkAccountBody.qml") + bodyLoader.item.width = root.pane.width + bodyLoader.item.height = root.pane.height + } + } + } + + Row { + id: buttons + anchors { + right: parent.right + bottom: parent.bottom + bottomMargin: hifi.dimensions.contentSpacing.y + } + spacing: hifi.dimensions.contentSpacing.x + onHeightChanged: d.resize(); onWidthChanged: d.resize(); + + Button { + id: linkAccountButton + anchors.verticalCenter: parent.verticalCenter + width: 200 + + text: qsTr("Sign Up") + color: hifi.buttons.blue + + onClicked: signupBody.signup() + } + + Button { + anchors.verticalCenter: parent.verticalCenter + + text: qsTr("Cancel") + + onClicked: root.destroy() + } + } + + Component.onCompleted: { + root.title = qsTr("Create an Account") + root.iconText = "<" + keyboardEnabled = HMD.active; + d.resize(); + + usernameField.forceActiveFocus(); + } + + Connections { + target: loginDialog + onHandleSignupCompleted: { + console.log("Signup Succeeded") + + bodyLoader.setSource("WelcomeBody.qml", { "welcomeBack" : true }) + bodyLoader.item.width = root.pane.width + bodyLoader.item.height = root.pane.height + } + onHandleSignupFailed: { + console.log("Signup Failed") + mainTextContainer.visible = true + } + } + + Keys.onPressed: { + if (!visible) { + return + } + + switch (event.key) { + case Qt.Key_Enter: + case Qt.Key_Return: + event.accepted = true + signupBody.signup() + break + } + } +} diff --git a/interface/resources/qml/SignupDialog.qml b/interface/resources/qml/SignupDialog.qml deleted file mode 100644 index a7ff9d975d..0000000000 --- a/interface/resources/qml/SignupDialog.qml +++ /dev/null @@ -1,257 +0,0 @@ -// -// SignupDialog.qml -// -// Created by David Rowe on 7 Dec 2016 -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import Hifi 1.0 -import QtQuick 2.4 - -import "controls-uit" -import "styles-uit" -import "windows" - -import "SignupDialog" - -ModalWindow { - id: root - HifiConstants { id: hifi } - objectName: "SignupDialog" - implicitWidth: 520 - implicitHeight: 320 - destroyOnCloseButton: true - destroyOnHidden: true - visible: true - - property string iconText: "" - property int iconSize: 50 - - property string title: "" - property int titleWidth: 0 - - keyboardOverride: true // Disable ModalWindow's keyboard. - - SignupDialog { - id: signupDialog - - Item { - id: signupBody - clip: true - width: root.pane.width - height: root.pane.height - - function signup() { - mainTextContainer.visible = false - signupDialog.signup(usernameField.text, passwordField.text) - } - - property bool keyboardEnabled: false - property bool keyboardRaised: false - property bool punctuationMode: false - - onKeyboardRaisedChanged: d.resize(); - - QtObject { - id: d - readonly property int minWidth: 480 - readonly property int maxWidth: 1280 - readonly property int minHeight: 120 - readonly property int maxHeight: 720 - - function resize() { - var targetWidth = Math.max(titleWidth, form.contentWidth); - var targetHeight = hifi.dimensions.contentSpacing.y + mainTextContainer.height + - 4 * hifi.dimensions.contentSpacing.y + form.height + - hifi.dimensions.contentSpacing.y + buttons.height; - - if (additionalInformation.visible) { - targetWidth = Math.max(targetWidth, additionalInformation.width); - targetHeight += hifi.dimensions.contentSpacing.y + additionalInformation.height - } - - root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)); - root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) - + (keyboardEnabled && keyboardRaised ? (200 + 2 * hifi.dimensions.contentSpacing.y) : hifi.dimensions.contentSpacing.y); - } - } - - ShortcutText { - id: mainTextContainer - anchors { - top: parent.top - left: parent.left - margins: 0 - topMargin: hifi.dimensions.contentSpacing.y - } - - visible: false - - text: qsTr("Username or password incorrect.") - wrapMode: Text.WordWrap - color: hifi.colors.redAccent - lineHeight: 1 - lineHeightMode: Text.ProportionalHeight - horizontalAlignment: Text.AlignHCenter - } - - Column { - id: form - anchors { - top: mainTextContainer.bottom - left: parent.left - margins: 0 - topMargin: 2 * hifi.dimensions.contentSpacing.y - } - spacing: 2 * hifi.dimensions.contentSpacing.y - - Row { - spacing: hifi.dimensions.contentSpacing.x - - TextField { - id: usernameField - anchors { - verticalCenter: parent.verticalCenter - } - width: 350 - - label: "User Name or Email" - } - } - Row { - spacing: hifi.dimensions.contentSpacing.x - - TextField { - id: passwordField - anchors { - verticalCenter: parent.verticalCenter - } - width: 350 - - label: "Password" - echoMode: TextInput.Password - } - } - - } - - // Override ScrollingWindow's keyboard that would be at very bottom of dialog. - Keyboard { - raised: keyboardEnabled && keyboardRaised - numeric: punctuationMode - anchors { - left: parent.left - right: parent.right - bottom: buttons.top - bottomMargin: keyboardRaised ? 2 * hifi.dimensions.contentSpacing.y : 0 - } - } - - Row { - id: buttons - anchors { - right: parent.right - bottom: parent.bottom - bottomMargin: hifi.dimensions.contentSpacing.y - } - spacing: hifi.dimensions.contentSpacing.x - onHeightChanged: d.resize(); onWidthChanged: d.resize(); - - Button { - id: linkAccountButton - anchors.verticalCenter: parent.verticalCenter - width: 200 - - text: qsTr("Signup") - color: hifi.buttons.blue - - onClicked: signupBody.signup() - } - - Button { - anchors.verticalCenter: parent.verticalCenter - - text: qsTr("Cancel") - - onClicked: root.destroy() - } - } - - Component.onCompleted: { - root.title = qsTr("Sign into High Fidelity") - root.iconText = "<" - keyboardEnabled = HMD.active; - d.resize(); - - usernameField.forceActiveFocus(); - } - - Connections { - target: signupDialog - onHandleSignupCompleted: { - console.log("Signup Succeeded") - - bodyLoader.setSource("WelcomeBody.qml", { "welcomeBack" : true }) - bodyLoader.item.width = root.pane.width - bodyLoader.item.height = root.pane.height - } - onHandleSignupFailed: { - console.log("Signup Failed") - mainTextContainer.visible = true - } - } - - Keys.onPressed: { - if (!visible) { - return - } - - switch (event.key) { - case Qt.Key_Enter: - case Qt.Key_Return: - event.accepted = true - signupBody.signup() - break - } - } - } - } - - Keys.onPressed: { - if (!visible) { - return - } - - if (event.modifiers === Qt.ControlModifier) - switch (event.key) { - case Qt.Key_A: - event.accepted = true - detailedText.selectAll() - break - case Qt.Key_C: - event.accepted = true - detailedText.copy() - break - case Qt.Key_Period: - if (Qt.platform.os === "osx") { - event.accepted = true - content.reject() - } - break - } else switch (event.key) { - case Qt.Key_Escape: - case Qt.Key_Back: - event.accepted = true - destroy() - break - - case Qt.Key_Enter: - case Qt.Key_Return: - event.accepted = true - break - } - } -} diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index b85947272c..c6150dcc53 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -153,7 +153,6 @@ #include "ui/DialogsManager.h" #include "ui/LoginDialog.h" #include "ui/overlays/Cube3DOverlay.h" -#include "ui/SignupDialog.h" #include "ui/Snapshot.h" #include "ui/SnapshotAnimated.h" #include "ui/StandAloneJSConsole.h" @@ -1752,7 +1751,6 @@ void Application::initializeUi() { AddressBarDialog::registerType(); ErrorDialog::registerType(); LoginDialog::registerType(); - SignupDialog::registerType(); Tooltip::registerType(); UpdateDialog::registerType(); qmlRegisterType("Hifi", 1, 0, "Preference"); diff --git a/interface/src/ui/DialogsManager.cpp b/interface/src/ui/DialogsManager.cpp index a4cd674dfd..03c71d8573 100644 --- a/interface/src/ui/DialogsManager.cpp +++ b/interface/src/ui/DialogsManager.cpp @@ -30,7 +30,6 @@ #include "OctreeStatsDialog.h" #include "PreferencesDialog.h" #include "ScriptEditorWindow.h" -#include "SignupDialog.h" #include "UpdateDialog.h" template @@ -75,7 +74,7 @@ void DialogsManager::toggleDiskCacheEditor() { } void DialogsManager::toggleLoginDialog() { - SignupDialog::show(); + LoginDialog::toggleAction(); } void DialogsManager::showLoginDialog() { diff --git a/interface/src/ui/LoginDialog.cpp b/interface/src/ui/LoginDialog.cpp index fef0a12813..6b655abb5d 100644 --- a/interface/src/ui/LoginDialog.cpp +++ b/interface/src/ui/LoginDialog.cpp @@ -153,3 +153,33 @@ void LoginDialog::createFailed(QNetworkReply& reply) { emit handleCreateFailed(reply.errorString()); } +void LoginDialog::signup(const QString& username, const QString& password) { + + JSONCallbackParameters callbackParams; + callbackParams.jsonCallbackReceiver = this; + callbackParams.jsonCallbackMethod = "signupCompleted"; + callbackParams.errorCallbackReceiver = this; + callbackParams.errorCallbackMethod = "signupFailed"; + + QJsonObject payload; + payload.insert("username", username); + payload.insert("password", password); + + static const QString API_SIGNUP_PATH = "api/v1/users"; + + qDebug() << "Sending a request to create an account for" << username; + + auto accountManager = DependencyManager::get(); + accountManager->sendRequest(API_SIGNUP_PATH, AccountManagerAuth::None, + QNetworkAccessManager::PostOperation, callbackParams, + QJsonDocument(payload).toJson()); +} + +void LoginDialog::signupCompleted(QNetworkReply& reply) { + emit handleSignupCompleted(); +} + +void LoginDialog::signupFailed(QNetworkReply& reply) { + qDebug() << "SIGNUP FAILED" << reply.readAll(); +} + diff --git a/interface/src/ui/LoginDialog.h b/interface/src/ui/LoginDialog.h index 8b6dc40302..69d41c92f1 100644 --- a/interface/src/ui/LoginDialog.h +++ b/interface/src/ui/LoginDialog.h @@ -36,6 +36,9 @@ signals: void handleCreateCompleted(); void handleCreateFailed(QString error); + + void handleSignupCompleted(); + void handleSignupFailed(QString error); public slots: void linkCompleted(QNetworkReply& reply); @@ -43,6 +46,9 @@ public slots: void createCompleted(QNetworkReply& reply); void createFailed(QNetworkReply& reply); + + void signupCompleted(QNetworkReply& reply); + void signupFailed(QNetworkReply& reply); protected slots: Q_INVOKABLE bool isSteamRunning() const; @@ -51,6 +57,8 @@ protected slots: Q_INVOKABLE void loginThroughSteam(); Q_INVOKABLE void linkSteam(); Q_INVOKABLE void createAccountFromStream(QString username = QString()); + + Q_INVOKABLE void signup(const QString& username, const QString& password); Q_INVOKABLE void openUrl(const QString& url) const; diff --git a/interface/src/ui/SignupDialog.cpp b/interface/src/ui/SignupDialog.cpp deleted file mode 100644 index a9d575a4df..0000000000 --- a/interface/src/ui/SignupDialog.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// -// SignupDialog.cpp -// interface/src/ui -// -// Created by Stephen Birarda on December 7 2016 -// Copyright 2016 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include "SignupDialog.h" - -#include - -#include - -HIFI_QML_DEF(SignupDialog) - -SignupDialog::SignupDialog(QQuickItem *parent) : OffscreenQmlDialog(parent) { - -} - -void SignupDialog::signup(const QString& username, const QString& password) { - - JSONCallbackParameters callbackParams; - callbackParams.jsonCallbackReceiver = this; - callbackParams.jsonCallbackMethod = "signupCompleted"; - callbackParams.errorCallbackReceiver = this; - callbackParams.errorCallbackMethod = "signupFailed"; - - QJsonObject payload; - payload.insert("username", username); - payload.insert("password", password); - - static const QString API_SIGNUP_PATH = "api/v1/users"; - - qDebug() << "Sending a request to create an account for" << username; - - auto accountManager = DependencyManager::get(); - accountManager->sendRequest(API_SIGNUP_PATH, AccountManagerAuth::None, - QNetworkAccessManager::PostOperation, callbackParams, - QJsonDocument(payload).toJson()); -} - -void SignupDialog::signupCompleted(QNetworkReply& reply) { - emit handleSignupCompleted(); -} - -void SignupDialog::signupFailed(QNetworkReply& reply) { - -} diff --git a/interface/src/ui/SignupDialog.h b/interface/src/ui/SignupDialog.h deleted file mode 100644 index 6d51f54c9f..0000000000 --- a/interface/src/ui/SignupDialog.h +++ /dev/null @@ -1,40 +0,0 @@ -// -// SignupDialog.h -// interface/src/ui -// -// Created by Stephen Birarda on December 7 2016 -// Copyright 2016 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#pragma once - -#ifndef hifi_SignupDialog_h -#define hifi_SignupDialog_h - -#include - -class QNetworkReply; - -class SignupDialog : public OffscreenQmlDialog { - Q_OBJECT - HIFI_QML_DECL - -public: - SignupDialog(QQuickItem* parent = nullptr); - -public slots: - void signupCompleted(QNetworkReply& reply); - void signupFailed(QNetworkReply& reply); - -signals: - void handleSignupCompleted(); - void handleSignupFailed(QString error); - -protected slots: - Q_INVOKABLE void signup(const QString& username, const QString& password); -}; - -#endif // hifi_SignupDialog_h From b66ddbdbdb87fae558fc2073219cb29e496f0bb1 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 8 Dec 2016 16:16:37 -0800 Subject: [PATCH 03/12] add email field, error handling for sign up inputs --- .../resources/qml/LoginDialog/SignUpBody.qml | 32 ++++++--- interface/src/Menu.h | 2 +- interface/src/ui/LoginDialog.cpp | 69 ++++++++++++++++--- interface/src/ui/LoginDialog.h | 4 +- .../networking/src/NetworkingConstants.h | 2 +- 5 files changed, 86 insertions(+), 23 deletions(-) diff --git a/interface/resources/qml/LoginDialog/SignUpBody.qml b/interface/resources/qml/LoginDialog/SignUpBody.qml index e3f8374d94..69c19e3328 100644 --- a/interface/resources/qml/LoginDialog/SignUpBody.qml +++ b/interface/resources/qml/LoginDialog/SignUpBody.qml @@ -24,7 +24,7 @@ Item { function signup() { mainTextContainer.visible = false - loginDialog.signup(usernameField.text, passwordField.text) + loginDialog.signup(emailField.text, usernameField.text, passwordField.text) } property bool keyboardEnabled: false @@ -81,6 +81,20 @@ Item { } spacing: 2 * hifi.dimensions.contentSpacing.y + Row { + spacing: hifi.dimensions.contentSpacing.x + + TextField { + id: emailField + anchors { + verticalCenter: parent.verticalCenter + } + width: 350 + + label: "Email" + } + } + Row { spacing: hifi.dimensions.contentSpacing.x @@ -99,11 +113,7 @@ Item { verticalCenter: parent.verticalCenter } - wrapMode: Text.WordWrap - lineHeight: 1 - lineHeightMode: Text.ProportionalHeight - - text: qsTr("Must be unique. No spaces or other special characters") + text: qsTr("No spaces / special chars.") verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter @@ -111,6 +121,7 @@ Item { color: hifi.colors.blueAccent } } + Row { spacing: hifi.dimensions.contentSpacing.x @@ -213,20 +224,21 @@ Item { keyboardEnabled = HMD.active; d.resize(); - usernameField.forceActiveFocus(); + emailField.forceActiveFocus(); } Connections { target: loginDialog onHandleSignupCompleted: { - console.log("Signup Succeeded") + console.log("Sign Up Succeeded") - bodyLoader.setSource("WelcomeBody.qml", { "welcomeBack" : true }) + bodyLoader.setSource("WelcomeBody.qml", { "welcomeBack": false }) bodyLoader.item.width = root.pane.width bodyLoader.item.height = root.pane.height } onHandleSignupFailed: { - console.log("Signup Failed") + console.log("Sign Up Failed") + mainTextContainer.text = errorString mainTextContainer.visible = true } } diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 5a08096257..e2a368db2d 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -119,7 +119,7 @@ namespace MenuOption { const QString LoadScript = "Open and Run Script File..."; const QString LoadScriptURL = "Open and Run Script from URL..."; const QString LodTools = "LOD Tools"; - const QString Login = "Login"; + const QString Login = "Login / Sign Up"; const QString Log = "Log"; const QString LogExtraTimings = "Log Extra Timing Details"; const QString LowVelocityFilter = "Low Velocity Filter"; diff --git a/interface/src/ui/LoginDialog.cpp b/interface/src/ui/LoginDialog.cpp index 6b655abb5d..f369312420 100644 --- a/interface/src/ui/LoginDialog.cpp +++ b/interface/src/ui/LoginDialog.cpp @@ -11,9 +11,10 @@ #include "LoginDialog.h" -#include -#include -#include +#include +#include +#include +#include #include #include @@ -47,7 +48,7 @@ void LoginDialog::toggleAction() { connection = connect(loginAction, &QAction::triggered, accountManager.data(), &AccountManager::logout); } else { // change the menu item to login - loginAction->setText("Login"); + loginAction->setText("Login / Sign Up"); connection = connect(loginAction, &QAction::triggered, [] { LoginDialog::show(); }); @@ -153,7 +154,7 @@ void LoginDialog::createFailed(QNetworkReply& reply) { emit handleCreateFailed(reply.errorString()); } -void LoginDialog::signup(const QString& username, const QString& password) { +void LoginDialog::signup(const QString& email, const QString& username, const QString& password) { JSONCallbackParameters callbackParams; callbackParams.jsonCallbackReceiver = this; @@ -162,8 +163,13 @@ void LoginDialog::signup(const QString& username, const QString& password) { callbackParams.errorCallbackMethod = "signupFailed"; QJsonObject payload; - payload.insert("username", username); - payload.insert("password", password); + + QJsonObject userObject; + userObject.insert("email", email); + userObject.insert("username", username); + userObject.insert("password", password); + + payload.insert("user", userObject); static const QString API_SIGNUP_PATH = "api/v1/users"; @@ -179,7 +185,52 @@ void LoginDialog::signupCompleted(QNetworkReply& reply) { emit handleSignupCompleted(); } -void LoginDialog::signupFailed(QNetworkReply& reply) { - qDebug() << "SIGNUP FAILED" << reply.readAll(); +QString errorStringFromAPIObject(const QJsonValue& apiObject) { + if (apiObject.isArray()) { + return apiObject.toArray()[0].toString(); + } else if (apiObject.isString()) { + return apiObject.toString(); + } else { + return "is invalid"; + } +} + +void LoginDialog::signupFailed(QNetworkReply& reply) { + + // parse the returned JSON to see what the problem was + auto jsonResponse = QJsonDocument::fromJson(reply.readAll()); + + static const QString RESPONSE_DATA_KEY = "data"; + + auto dataJsonValue = jsonResponse.object()[RESPONSE_DATA_KEY]; + + if (dataJsonValue.isObject()) { + auto dataObject = dataJsonValue.toObject(); + + static const QString EMAIL_DATA_KEY = "email"; + static const QString USERNAME_DATA_KEY = "username"; + static const QString PASSWORD_DATA_KEY = "password"; + + QStringList errorStringList; + + if (dataObject.contains(EMAIL_DATA_KEY)) { + errorStringList.append(QString("Email %1.").arg(errorStringFromAPIObject(dataObject[EMAIL_DATA_KEY]))); + } + + if (dataObject.contains(USERNAME_DATA_KEY)) { + errorStringList.append(QString("Username %1.").arg(errorStringFromAPIObject(dataObject[USERNAME_DATA_KEY]))); + } + + if (dataObject.contains(PASSWORD_DATA_KEY)) { + errorStringList.append(QString("Password %1.").arg(errorStringFromAPIObject(dataObject[PASSWORD_DATA_KEY]))); + } + + emit handleSignupFailed(errorStringList.join(' ')); + } else { + static const QString DEFAULT_SIGN_UP_FAILURE_MESSAGE = "There was an unknown error while creating your account. Please try again later."; + emit handleSignupFailed(DEFAULT_SIGN_UP_FAILURE_MESSAGE); + } + + } diff --git a/interface/src/ui/LoginDialog.h b/interface/src/ui/LoginDialog.h index 69d41c92f1..ce6075793b 100644 --- a/interface/src/ui/LoginDialog.h +++ b/interface/src/ui/LoginDialog.h @@ -38,7 +38,7 @@ signals: void handleCreateFailed(QString error); void handleSignupCompleted(); - void handleSignupFailed(QString error); + void handleSignupFailed(QString errorString); public slots: void linkCompleted(QNetworkReply& reply); @@ -58,7 +58,7 @@ protected slots: Q_INVOKABLE void linkSteam(); Q_INVOKABLE void createAccountFromStream(QString username = QString()); - Q_INVOKABLE void signup(const QString& username, const QString& password); + Q_INVOKABLE void signup(const QString& email, const QString& username, const QString& password); Q_INVOKABLE void openUrl(const QString& url) const; diff --git a/libraries/networking/src/NetworkingConstants.h b/libraries/networking/src/NetworkingConstants.h index a512ae8887..d1e0a46c71 100644 --- a/libraries/networking/src/NetworkingConstants.h +++ b/libraries/networking/src/NetworkingConstants.h @@ -15,7 +15,7 @@ #include namespace NetworkingConstants { - const QUrl METAVERSE_SERVER_URL = QUrl("https://metaverse.highfidelity.com"); + const QUrl METAVERSE_SERVER_URL = QUrl("http://localhost:3000"); } #endif // hifi_NetworkingConstants_h From 9445fc28982ce699c6aa9ef72b0816d35c43e6f2 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 8 Dec 2016 16:28:16 -0800 Subject: [PATCH 04/12] fix for display of multiple sign up errors --- interface/resources/qml/LoginDialog/SignUpBody.qml | 6 ++---- interface/src/ui/LoginDialog.cpp | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/interface/resources/qml/LoginDialog/SignUpBody.qml b/interface/resources/qml/LoginDialog/SignUpBody.qml index 69c19e3328..729d892e5f 100644 --- a/interface/resources/qml/LoginDialog/SignUpBody.qml +++ b/interface/resources/qml/LoginDialog/SignUpBody.qml @@ -63,12 +63,10 @@ Item { visible: false - text: qsTr("Username or password incorrect.") + text: qsTr("There was an unknown error while creating your account.") wrapMode: Text.WordWrap color: hifi.colors.redAccent - lineHeight: 1 - lineHeightMode: Text.ProportionalHeight - horizontalAlignment: Text.AlignHCenter + horizontalAlignment: Text.AlignLeft } Column { diff --git a/interface/src/ui/LoginDialog.cpp b/interface/src/ui/LoginDialog.cpp index f369312420..d27c3e907a 100644 --- a/interface/src/ui/LoginDialog.cpp +++ b/interface/src/ui/LoginDialog.cpp @@ -225,7 +225,7 @@ void LoginDialog::signupFailed(QNetworkReply& reply) { errorStringList.append(QString("Password %1.").arg(errorStringFromAPIObject(dataObject[PASSWORD_DATA_KEY]))); } - emit handleSignupFailed(errorStringList.join(' ')); + emit handleSignupFailed(errorStringList.join('\n')); } else { static const QString DEFAULT_SIGN_UP_FAILURE_MESSAGE = "There was an unknown error while creating your account. Please try again later."; emit handleSignupFailed(DEFAULT_SIGN_UP_FAILURE_MESSAGE); From 396c2bc28fa0c07930e81d12b85b12364f9c9e8c Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 8 Dec 2016 17:00:47 -0800 Subject: [PATCH 05/12] add error for login after signup, fix link style --- .../qml/LoginDialog/LinkAccountBody.qml | 11 ++++++++++- .../resources/qml/LoginDialog/SignUpBody.qml | 18 ++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 89211a998d..2f45441b9d 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -22,6 +22,8 @@ Item { width: root.pane.width height: root.pane.height + property bool failAfterSignUp: false + function login() { mainTextContainer.visible = false loginDialog.login(usernameField.text, passwordField.text) @@ -96,7 +98,7 @@ Item { } width: 350 - label: "User Name or Email" + label: "Username or Email" } ShortcutText { @@ -108,6 +110,7 @@ Item { verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter + linkColor: hifi.colors.blueAccent onLinkActivated: loginDialog.openUrl(link) } @@ -135,6 +138,7 @@ Item { verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter + linkColor: hifi.colors.blueAccent onLinkActivated: loginDialog.openUrl(link) } @@ -238,6 +242,11 @@ Item { keyboardEnabled = HMD.active; d.resize(); + if (failAfterSignUp) { + mainTextContainer.text = "Account created successfully." + mainTextContainer.visible = true + } + usernameField.forceActiveFocus(); } diff --git a/interface/resources/qml/LoginDialog/SignUpBody.qml b/interface/resources/qml/LoginDialog/SignUpBody.qml index 729d892e5f..913241cc3f 100644 --- a/interface/resources/qml/LoginDialog/SignUpBody.qml +++ b/interface/resources/qml/LoginDialog/SignUpBody.qml @@ -228,17 +228,27 @@ Item { Connections { target: loginDialog onHandleSignupCompleted: { - console.log("Sign Up Succeeded") + console.log("Sign Up Succeeded"); - bodyLoader.setSource("WelcomeBody.qml", { "welcomeBack": false }) - bodyLoader.item.width = root.pane.width - bodyLoader.item.height = root.pane.height + // now that we have an account, login with that username and password + loginDialog.login(usernameField.text, "test") } onHandleSignupFailed: { console.log("Sign Up Failed") mainTextContainer.text = errorString mainTextContainer.visible = true } + onHandleLoginCompleted: { + bodyLoader.setSource("WelcomeBody.qml", { "welcomeBack": false }) + bodyLoader.item.width = root.pane.width + bodyLoader.item.height = root.pane.height + } + onHandleLoginFailed: { + // we failed to login, show the LoginDialog so the user will try again + bodyLoader.setSource("LinkAccountBody.qml", { "failAfterSignUp": true }) + bodyLoader.item.width = root.pane.width + bodyLoader.item.height = root.pane.height + } } Keys.onPressed: { From 370de667d5f28a9286268237dff585bb21d105de Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 8 Dec 2016 17:23:39 -0800 Subject: [PATCH 06/12] add a spinner to the login dialog --- .../qml/LoginDialog/LinkAccountBody.qml | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 2f45441b9d..245ae2856d 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -26,6 +26,7 @@ Item { function login() { mainTextContainer.visible = false + toggleLoading(true) loginDialog.login(usernameField.text, passwordField.text) } @@ -59,6 +60,34 @@ Item { } } + function toggleLoading(isLoading) { + linkAccountSpinner.visible = isLoading + form.visible = !isLoading + + if (loginDialog.isSteamRunning()) { + additionalInformation.visible = !isLoading + } + + leftButton.visible = !isLoading + buttons.visible = !isLoading + } + + BusyIndicator { + id: linkAccountSpinner + + anchors { + top: parent.top + horizontalCenter: parent.horizontalCenter + topMargin: hifi.dimensions.contentSpacing.y + } + + visible: false + running: true + + width: 48 + height: 48 + } + ShortcutText { id: mainTextContainer anchors { @@ -266,6 +295,7 @@ Item { onHandleLoginFailed: { console.log("Login Failed") mainTextContainer.visible = true + toggleLoading(false) } onHandleLinkCompleted: { console.log("Link Succeeded") @@ -276,7 +306,7 @@ Item { } onHandleLinkFailed: { console.log("Link Failed") - + toggleLoading(false) } } From 673e03aae4a17e164fa0774bab6560bc99f7adf0 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 8 Dec 2016 17:29:29 -0800 Subject: [PATCH 07/12] add a spinner to sign up --- .../resources/qml/LoginDialog/SignUpBody.qml | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/interface/resources/qml/LoginDialog/SignUpBody.qml b/interface/resources/qml/LoginDialog/SignUpBody.qml index 913241cc3f..8c797d0c53 100644 --- a/interface/resources/qml/LoginDialog/SignUpBody.qml +++ b/interface/resources/qml/LoginDialog/SignUpBody.qml @@ -24,6 +24,7 @@ Item { function signup() { mainTextContainer.visible = false + toggleLoading(true) loginDialog.signup(emailField.text, usernameField.text, passwordField.text) } @@ -52,6 +53,30 @@ Item { } } + function toggleLoading(isLoading) { + linkAccountSpinner.visible = isLoading + form.visible = !isLoading + + leftButton.visible = !isLoading + buttons.visible = !isLoading + } + + BusyIndicator { + id: linkAccountSpinner + + anchors { + top: parent.top + horizontalCenter: parent.horizontalCenter + topMargin: hifi.dimensions.contentSpacing.y + } + + visible: false + running: true + + width: 48 + height: 48 + } + ShortcutText { id: mainTextContainer anchors { @@ -231,10 +256,12 @@ Item { console.log("Sign Up Succeeded"); // now that we have an account, login with that username and password - loginDialog.login(usernameField.text, "test") + loginDialog.login(usernameField.text, passwordField.text) } onHandleSignupFailed: { console.log("Sign Up Failed") + toggleLoading(false) + mainTextContainer.text = errorString mainTextContainer.visible = true } From 80699e826a2cc557a775eb1b760a452e3c3295f9 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 8 Dec 2016 17:30:00 -0800 Subject: [PATCH 08/12] put back production METAVERSE_SERVER_URL --- libraries/networking/src/NetworkingConstants.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/networking/src/NetworkingConstants.h b/libraries/networking/src/NetworkingConstants.h index d1e0a46c71..a512ae8887 100644 --- a/libraries/networking/src/NetworkingConstants.h +++ b/libraries/networking/src/NetworkingConstants.h @@ -15,7 +15,7 @@ #include namespace NetworkingConstants { - const QUrl METAVERSE_SERVER_URL = QUrl("http://localhost:3000"); + const QUrl METAVERSE_SERVER_URL = QUrl("https://metaverse.highfidelity.com"); } #endif // hifi_NetworkingConstants_h From f0f10d837cee60e96d6d89158c6babe7195e1f01 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 9 Dec 2016 16:04:42 -0800 Subject: [PATCH 09/12] fix indents, fix resize for keyboard changes --- .../qml/LoginDialog/LinkAccountBody.qml | 4 - .../resources/qml/LoginDialog/SignUpBody.qml | 410 +++++++++--------- 2 files changed, 205 insertions(+), 209 deletions(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 245ae2856d..ca392244c4 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -218,12 +218,8 @@ Item { onHeightChanged: d.resize(); onWidthChanged: d.resize(); Button { - id: signupButton - anchors.verticalCenter: parent.verticalCenter - width: 150 - text: qsTr("Sign Up") visible: !loginDialog.isSteamRunning() diff --git a/interface/resources/qml/LoginDialog/SignUpBody.qml b/interface/resources/qml/LoginDialog/SignUpBody.qml index 8c797d0c53..e19b8f469f 100644 --- a/interface/resources/qml/LoginDialog/SignUpBody.qml +++ b/interface/resources/qml/LoginDialog/SignUpBody.qml @@ -17,177 +17,177 @@ import "../controls-uit" import "../styles-uit" Item { - id: signupBody - clip: true - width: root.pane.width - height: root.pane.height + id: signupBody + clip: true + width: root.pane.width + height: root.pane.height - function signup() { - mainTextContainer.visible = false - toggleLoading(true) - loginDialog.signup(emailField.text, usernameField.text, passwordField.text) - } + function signup() { + mainTextContainer.visible = false + toggleLoading(true) + loginDialog.signup(emailField.text, usernameField.text, passwordField.text) + } - property bool keyboardEnabled: false - property bool keyboardRaised: false - property bool punctuationMode: false + property bool keyboardEnabled: false + property bool keyboardRaised: false + property bool punctuationMode: false - onKeyboardRaisedChanged: d.resize(); + onKeyboardRaisedChanged: d.resize(); - QtObject { - id: d - readonly property int minWidth: 480 - readonly property int maxWidth: 1280 - readonly property int minHeight: 120 - readonly property int maxHeight: 720 + QtObject { + id: d + readonly property int minWidth: 480 + readonly property int maxWidth: 1280 + readonly property int minHeight: 120 + readonly property int maxHeight: 720 - function resize() { - var targetWidth = Math.max(titleWidth, form.contentWidth); - var targetHeight = hifi.dimensions.contentSpacing.y + mainTextContainer.height + - 4 * hifi.dimensions.contentSpacing.y + form.height + - hifi.dimensions.contentSpacing.y + buttons.height; + function resize() { + var targetWidth = Math.max(titleWidth, form.contentWidth); + var targetHeight = hifi.dimensions.contentSpacing.y + mainTextContainer.height + + 4 * hifi.dimensions.contentSpacing.y + form.height + + hifi.dimensions.contentSpacing.y + buttons.height; - root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)); - root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) - + (keyboardEnabled && keyboardRaised ? (200 + 2 * hifi.dimensions.contentSpacing.y) : hifi.dimensions.contentSpacing.y); - } - } + width = root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)); + height = root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) + + (keyboardEnabled && keyboardRaised ? (200 + 2 * hifi.dimensions.contentSpacing.y) : 0); + } + } - function toggleLoading(isLoading) { - linkAccountSpinner.visible = isLoading - form.visible = !isLoading + function toggleLoading(isLoading) { + linkAccountSpinner.visible = isLoading + form.visible = !isLoading - leftButton.visible = !isLoading - buttons.visible = !isLoading - } + leftButton.visible = !isLoading + buttons.visible = !isLoading + } - BusyIndicator { - id: linkAccountSpinner + BusyIndicator { + id: linkAccountSpinner - anchors { - top: parent.top - horizontalCenter: parent.horizontalCenter - topMargin: hifi.dimensions.contentSpacing.y - } + anchors { + top: parent.top + horizontalCenter: parent.horizontalCenter + topMargin: hifi.dimensions.contentSpacing.y + } - visible: false - running: true + visible: false + running: true - width: 48 - height: 48 - } + width: 48 + height: 48 + } - ShortcutText { - id: mainTextContainer - anchors { - top: parent.top - left: parent.left - margins: 0 - topMargin: hifi.dimensions.contentSpacing.y - } + ShortcutText { + id: mainTextContainer + anchors { + top: parent.top + left: parent.left + margins: 0 + topMargin: hifi.dimensions.contentSpacing.y + } - visible: false + visible: false - text: qsTr("There was an unknown error while creating your account.") - wrapMode: Text.WordWrap - color: hifi.colors.redAccent - horizontalAlignment: Text.AlignLeft - } + text: qsTr("There was an unknown error while creating your account.") + wrapMode: Text.WordWrap + color: hifi.colors.redAccent + horizontalAlignment: Text.AlignLeft + } - Column { - id: form - anchors { - top: mainTextContainer.bottom - left: parent.left - margins: 0 - topMargin: 2 * hifi.dimensions.contentSpacing.y - } - spacing: 2 * hifi.dimensions.contentSpacing.y + Column { + id: form + anchors { + top: mainTextContainer.bottom + left: parent.left + margins: 0 + topMargin: 2 * hifi.dimensions.contentSpacing.y + } + spacing: 2 * hifi.dimensions.contentSpacing.y - Row { - spacing: hifi.dimensions.contentSpacing.x + Row { + spacing: hifi.dimensions.contentSpacing.x - TextField { - id: emailField - anchors { - verticalCenter: parent.verticalCenter - } - width: 350 + TextField { + id: emailField + anchors { + verticalCenter: parent.verticalCenter + } + width: 350 - label: "Email" - } - } + label: "Email" + } + } - Row { - spacing: hifi.dimensions.contentSpacing.x + Row { + spacing: hifi.dimensions.contentSpacing.x - TextField { - id: usernameField - anchors { - verticalCenter: parent.verticalCenter - } - width: 350 + TextField { + id: usernameField + anchors { + verticalCenter: parent.verticalCenter + } + width: 350 - label: "Username" - } + label: "Username" + } - ShortcutText { - anchors { - verticalCenter: parent.verticalCenter - } + ShortcutText { + anchors { + verticalCenter: parent.verticalCenter + } - text: qsTr("No spaces / special chars.") + text: qsTr("No spaces / special chars.") - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter - color: hifi.colors.blueAccent - } - } + color: hifi.colors.blueAccent + } + } - Row { - spacing: hifi.dimensions.contentSpacing.x + Row { + spacing: hifi.dimensions.contentSpacing.x - TextField { - id: passwordField - anchors { - verticalCenter: parent.verticalCenter - } - width: 350 + TextField { + id: passwordField + anchors { + verticalCenter: parent.verticalCenter + } + width: 350 - label: "Password" - echoMode: TextInput.Password - } + label: "Password" + echoMode: TextInput.Password + } - ShortcutText { - anchors { - verticalCenter: parent.verticalCenter - } + ShortcutText { + anchors { + verticalCenter: parent.verticalCenter + } - text: qsTr("At least 6 characters") + text: qsTr("At least 6 characters") - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter - color: hifi.colors.blueAccent - } - } + color: hifi.colors.blueAccent + } + } - } + } - // Override ScrollingWindow's keyboard that would be at very bottom of dialog. - Keyboard { - raised: keyboardEnabled && keyboardRaised - numeric: punctuationMode - anchors { - left: parent.left - right: parent.right - bottom: buttons.top - bottomMargin: keyboardRaised ? 2 * hifi.dimensions.contentSpacing.y : 0 - } - } + // Override ScrollingWindow's keyboard that would be at very bottom of dialog. + Keyboard { + raised: keyboardEnabled && keyboardRaised + numeric: punctuationMode + anchors { + left: parent.left + right: parent.right + bottom: buttons.top + bottomMargin: keyboardRaised ? 2 * hifi.dimensions.contentSpacing.y : 0 + } + } - Row { + Row { id: leftButton anchors { left: parent.left @@ -204,91 +204,91 @@ Item { text: qsTr("Existing User") onClicked: { - bodyLoader.setSource("LinkAccountBody.qml") - bodyLoader.item.width = root.pane.width - bodyLoader.item.height = root.pane.height + bodyLoader.setSource("LinkAccountBody.qml") + bodyLoader.item.width = root.pane.width + bodyLoader.item.height = root.pane.height } } } - Row { - id: buttons - anchors { - right: parent.right - bottom: parent.bottom - bottomMargin: hifi.dimensions.contentSpacing.y - } - spacing: hifi.dimensions.contentSpacing.x - onHeightChanged: d.resize(); onWidthChanged: d.resize(); + Row { + id: buttons + anchors { + right: parent.right + bottom: parent.bottom + bottomMargin: hifi.dimensions.contentSpacing.y + } + spacing: hifi.dimensions.contentSpacing.x + onHeightChanged: d.resize(); onWidthChanged: d.resize(); - Button { - id: linkAccountButton - anchors.verticalCenter: parent.verticalCenter - width: 200 + Button { + id: linkAccountButton + anchors.verticalCenter: parent.verticalCenter + width: 200 - text: qsTr("Sign Up") - color: hifi.buttons.blue + text: qsTr("Sign Up") + color: hifi.buttons.blue - onClicked: signupBody.signup() - } + onClicked: signupBody.signup() + } - Button { - anchors.verticalCenter: parent.verticalCenter + Button { + anchors.verticalCenter: parent.verticalCenter - text: qsTr("Cancel") + text: qsTr("Cancel") - onClicked: root.destroy() - } - } + onClicked: root.destroy() + } + } - Component.onCompleted: { - root.title = qsTr("Create an Account") - root.iconText = "<" - keyboardEnabled = HMD.active; - d.resize(); + Component.onCompleted: { + root.title = qsTr("Create an Account") + root.iconText = "<" + keyboardEnabled = HMD.active; + d.resize(); - emailField.forceActiveFocus(); - } + emailField.forceActiveFocus(); + } - Connections { - target: loginDialog - onHandleSignupCompleted: { - console.log("Sign Up Succeeded"); + Connections { + target: loginDialog + onHandleSignupCompleted: { + console.log("Sign Up Succeeded"); - // now that we have an account, login with that username and password - loginDialog.login(usernameField.text, passwordField.text) - } - onHandleSignupFailed: { - console.log("Sign Up Failed") - toggleLoading(false) + // now that we have an account, login with that username and password + loginDialog.login(usernameField.text, passwordField.text) + } + onHandleSignupFailed: { + console.log("Sign Up Failed") + toggleLoading(false) - mainTextContainer.text = errorString - mainTextContainer.visible = true - } - onHandleLoginCompleted: { - bodyLoader.setSource("WelcomeBody.qml", { "welcomeBack": false }) - bodyLoader.item.width = root.pane.width - bodyLoader.item.height = root.pane.height - } - onHandleLoginFailed: { - // we failed to login, show the LoginDialog so the user will try again - bodyLoader.setSource("LinkAccountBody.qml", { "failAfterSignUp": true }) - bodyLoader.item.width = root.pane.width - bodyLoader.item.height = root.pane.height - } - } + mainTextContainer.text = errorString + mainTextContainer.visible = true + } + onHandleLoginCompleted: { + bodyLoader.setSource("WelcomeBody.qml", { "welcomeBack": false }) + bodyLoader.item.width = root.pane.width + bodyLoader.item.height = root.pane.height + } + onHandleLoginFailed: { + // we failed to login, show the LoginDialog so the user will try again + bodyLoader.setSource("LinkAccountBody.qml", { "failAfterSignUp": true }) + bodyLoader.item.width = root.pane.width + bodyLoader.item.height = root.pane.height + } + } - Keys.onPressed: { - if (!visible) { - return - } + Keys.onPressed: { + if (!visible) { + return + } - switch (event.key) { - case Qt.Key_Enter: - case Qt.Key_Return: - event.accepted = true - signupBody.signup() - break - } - } + switch (event.key) { + case Qt.Key_Enter: + case Qt.Key_Return: + event.accepted = true + signupBody.signup() + break + } + } } From 691ce4312eeef75e479fc95abcc954044d85e2b8 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 9 Dec 2016 16:49:53 -0800 Subject: [PATCH 10/12] fix resizing for keyboard changes in body loaded qml --- interface/resources/qml/LoginDialog/CompleteProfileBody.qml | 4 ++-- interface/resources/qml/LoginDialog/LinkAccountBody.qml | 4 ++-- interface/resources/qml/LoginDialog/SignInBody.qml | 4 ++-- .../resources/qml/LoginDialog/UsernameCollisionBody.qml | 6 ++---- interface/resources/qml/LoginDialog/WelcomeBody.qml | 4 ++-- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/interface/resources/qml/LoginDialog/CompleteProfileBody.qml b/interface/resources/qml/LoginDialog/CompleteProfileBody.qml index f1b36ff6a7..05cacd9f73 100644 --- a/interface/resources/qml/LoginDialog/CompleteProfileBody.qml +++ b/interface/resources/qml/LoginDialog/CompleteProfileBody.qml @@ -33,8 +33,8 @@ Item { termsContainer.contentWidth)) var targetHeight = 5 * hifi.dimensions.contentSpacing.y + buttons.height + additionalTextContainer.height + termsContainer.height - root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)) - root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) + width = root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)) + height = root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) } } diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index ca392244c4..3a1d2c98b6 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -54,8 +54,8 @@ Item { targetHeight += hifi.dimensions.contentSpacing.y + additionalInformation.height } - root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)); - root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) + width = root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)); + height = root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) + (keyboardEnabled && keyboardRaised ? (200 + 2 * hifi.dimensions.contentSpacing.y) : hifi.dimensions.contentSpacing.y); } } diff --git a/interface/resources/qml/LoginDialog/SignInBody.qml b/interface/resources/qml/LoginDialog/SignInBody.qml index 7bbba683c3..924463e18c 100644 --- a/interface/resources/qml/LoginDialog/SignInBody.qml +++ b/interface/resources/qml/LoginDialog/SignInBody.qml @@ -43,8 +43,8 @@ Item { var targetWidth = Math.max(titleWidth, mainTextContainer.contentWidth) var targetHeight = mainTextContainer.height + 3 * hifi.dimensions.contentSpacing.y + buttons.height - root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)) - root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) + width = root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)) + height = root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) } } diff --git a/interface/resources/qml/LoginDialog/UsernameCollisionBody.qml b/interface/resources/qml/LoginDialog/UsernameCollisionBody.qml index eafe9e4b47..29a82afcf3 100644 --- a/interface/resources/qml/LoginDialog/UsernameCollisionBody.qml +++ b/interface/resources/qml/LoginDialog/UsernameCollisionBody.qml @@ -47,11 +47,9 @@ Item { hifi.dimensions.contentSpacing.y + textField.height + hifi.dimensions.contentSpacing.y + buttons.height - root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)) - root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) + width = root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)) + height = root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) + (keyboardEnabled && keyboardRaised ? (200 + 2 * hifi.dimensions.contentSpacing.y) : hifi.dimensions.contentSpacing.y) - - height = root.height } } diff --git a/interface/resources/qml/LoginDialog/WelcomeBody.qml b/interface/resources/qml/LoginDialog/WelcomeBody.qml index 5fed9addf8..1b85e1776e 100644 --- a/interface/resources/qml/LoginDialog/WelcomeBody.qml +++ b/interface/resources/qml/LoginDialog/WelcomeBody.qml @@ -39,8 +39,8 @@ Item { var targetWidth = Math.max(titleWidth, mainTextContainer.contentWidth) var targetHeight = mainTextContainer.height + 3 * hifi.dimensions.contentSpacing.y + buttons.height - root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)) - root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) + width = root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)) + height = root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) } } From a0663bdf3161618d2ffc6e01dfe519ea682035c5 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 12 Dec 2016 11:31:26 -0800 Subject: [PATCH 11/12] fix resizing of LoginDialog and friends --- interface/resources/qml/LoginDialog.qml | 1 - .../resources/qml/LoginDialog/CompleteProfileBody.qml | 8 ++++---- interface/resources/qml/LoginDialog/LinkAccountBody.qml | 7 +++---- interface/resources/qml/LoginDialog/SignInBody.qml | 8 ++++---- interface/resources/qml/LoginDialog/SignUpBody.qml | 6 +++--- .../resources/qml/LoginDialog/UsernameCollisionBody.qml | 4 ++-- interface/resources/qml/LoginDialog/WelcomeBody.qml | 8 ++++---- 7 files changed, 20 insertions(+), 22 deletions(-) diff --git a/interface/resources/qml/LoginDialog.qml b/interface/resources/qml/LoginDialog.qml index 08895ecaa1..2e7ff39ed6 100644 --- a/interface/resources/qml/LoginDialog.qml +++ b/interface/resources/qml/LoginDialog.qml @@ -40,7 +40,6 @@ ModalWindow { Loader { id: bodyLoader - anchors.fill: parent source: loginDialog.isSteamRunning() ? "LoginDialog/SignInBody.qml" : "LoginDialog/LinkAccountBody.qml" } } diff --git a/interface/resources/qml/LoginDialog/CompleteProfileBody.qml b/interface/resources/qml/LoginDialog/CompleteProfileBody.qml index 05cacd9f73..e06ce239ab 100644 --- a/interface/resources/qml/LoginDialog/CompleteProfileBody.qml +++ b/interface/resources/qml/LoginDialog/CompleteProfileBody.qml @@ -18,8 +18,8 @@ import "../styles-uit" Item { id: completeProfileBody clip: true - width: pane.width - height: pane.height + width: root.pane.width + height: root.pane.height QtObject { id: d @@ -33,8 +33,8 @@ Item { termsContainer.contentWidth)) var targetHeight = 5 * hifi.dimensions.contentSpacing.y + buttons.height + additionalTextContainer.height + termsContainer.height - width = root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)) - height = root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) + parent.width = root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)) + parent.height = root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) } } diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 3a1d2c98b6..e27635dbbd 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -19,9 +19,8 @@ import "../styles-uit" Item { id: linkAccountBody clip: true - width: root.pane.width height: root.pane.height - + width: root.pane.width property bool failAfterSignUp: false function login() { @@ -54,8 +53,8 @@ Item { targetHeight += hifi.dimensions.contentSpacing.y + additionalInformation.height } - width = root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)); - height = root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) + parent.width = root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)); + parent.height = root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) + (keyboardEnabled && keyboardRaised ? (200 + 2 * hifi.dimensions.contentSpacing.y) : hifi.dimensions.contentSpacing.y); } } diff --git a/interface/resources/qml/LoginDialog/SignInBody.qml b/interface/resources/qml/LoginDialog/SignInBody.qml index 924463e18c..167ed1640a 100644 --- a/interface/resources/qml/LoginDialog/SignInBody.qml +++ b/interface/resources/qml/LoginDialog/SignInBody.qml @@ -18,8 +18,8 @@ import "../styles-uit" Item { id: signInBody clip: true - width: pane.width - height: pane.height + width: root.pane.width + height: root.pane.height property bool required: false @@ -43,8 +43,8 @@ Item { var targetWidth = Math.max(titleWidth, mainTextContainer.contentWidth) var targetHeight = mainTextContainer.height + 3 * hifi.dimensions.contentSpacing.y + buttons.height - width = root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)) - height = root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) + parent.width = root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)) + parent.height = root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) } } diff --git a/interface/resources/qml/LoginDialog/SignUpBody.qml b/interface/resources/qml/LoginDialog/SignUpBody.qml index e19b8f469f..197f5a3c93 100644 --- a/interface/resources/qml/LoginDialog/SignUpBody.qml +++ b/interface/resources/qml/LoginDialog/SignUpBody.qml @@ -19,8 +19,8 @@ import "../styles-uit" Item { id: signupBody clip: true - width: root.pane.width height: root.pane.height + width: root.pane.width function signup() { mainTextContainer.visible = false @@ -47,8 +47,8 @@ Item { 4 * hifi.dimensions.contentSpacing.y + form.height + hifi.dimensions.contentSpacing.y + buttons.height; - width = root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)); - height = root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) + parent.width = root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)); + parent.height = root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) + (keyboardEnabled && keyboardRaised ? (200 + 2 * hifi.dimensions.contentSpacing.y) : 0); } } diff --git a/interface/resources/qml/LoginDialog/UsernameCollisionBody.qml b/interface/resources/qml/LoginDialog/UsernameCollisionBody.qml index 29a82afcf3..18c831b3a9 100644 --- a/interface/resources/qml/LoginDialog/UsernameCollisionBody.qml +++ b/interface/resources/qml/LoginDialog/UsernameCollisionBody.qml @@ -47,8 +47,8 @@ Item { hifi.dimensions.contentSpacing.y + textField.height + hifi.dimensions.contentSpacing.y + buttons.height - width = root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)) - height = root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) + parent.width = root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)) + parent.height = root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) + (keyboardEnabled && keyboardRaised ? (200 + 2 * hifi.dimensions.contentSpacing.y) : hifi.dimensions.contentSpacing.y) } } diff --git a/interface/resources/qml/LoginDialog/WelcomeBody.qml b/interface/resources/qml/LoginDialog/WelcomeBody.qml index 1b85e1776e..eb91956532 100644 --- a/interface/resources/qml/LoginDialog/WelcomeBody.qml +++ b/interface/resources/qml/LoginDialog/WelcomeBody.qml @@ -17,8 +17,8 @@ import "../styles-uit" Item { id: welcomeBody clip: true - width: pane.width - height: pane.height + width: root.pane.width + height: root.pane.height property bool welcomeBack: false @@ -39,8 +39,8 @@ Item { var targetWidth = Math.max(titleWidth, mainTextContainer.contentWidth) var targetHeight = mainTextContainer.height + 3 * hifi.dimensions.contentSpacing.y + buttons.height - width = root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)) - height = root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) + parent.width = root.width = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)) + parent.height = root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) } } From 5111256a9ed2793abb78e7669702102959a4bf94 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 12 Dec 2016 13:04:14 -0800 Subject: [PATCH 12/12] resize the sign up dialog when showing errors --- interface/resources/qml/LoginDialog/SignUpBody.qml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interface/resources/qml/LoginDialog/SignUpBody.qml b/interface/resources/qml/LoginDialog/SignUpBody.qml index 197f5a3c93..c0ff2d77cb 100644 --- a/interface/resources/qml/LoginDialog/SignUpBody.qml +++ b/interface/resources/qml/LoginDialog/SignUpBody.qml @@ -264,6 +264,8 @@ Item { mainTextContainer.text = errorString mainTextContainer.visible = true + + d.resize(); } onHandleLoginCompleted: { bodyLoader.setSource("WelcomeBody.qml", { "welcomeBack": false })