From cdee10d0b85e4e736d3006b4eddf9654357eead7 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 20 Nov 2018 16:54:16 -0800 Subject: [PATCH] getting dominant hand laser + sign up working --- .../qml/LoginDialog/LinkAccountBody.qml | 12 +++------ .../qml/LoginDialog/LoggingInBody.qml | 7 ++--- .../resources/qml/LoginDialog/SignInBody.qml | 22 ++++++++++++++- interface/src/Application.cpp | 9 +++++-- interface/src/LoginStateManager.cpp | 27 ++++++++++++++----- interface/src/LoginStateManager.h | 3 ++- interface/src/ui/LoginDialog.cpp | 8 ++++-- 7 files changed, 65 insertions(+), 23 deletions(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 3643033ba8..8f7835195a 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -28,12 +28,6 @@ Item { property bool withSteam: false - property bool keyboardEnabled: false - property bool keyboardRaised: false - property bool punctuationMode: false - - onKeyboardRaisedChanged: d.resize(); - QtObject { id: d readonly property int minWidth: 480 @@ -55,8 +49,7 @@ Item { parent.width = root.width = newWidth; } - 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); + parent.height = root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) + hifi.dimensions.contentSpacing.y; } } @@ -264,6 +257,9 @@ Item { } Component.onCompleted: { + root.keyboardEnabled = false; + root.keyboardRaised = false; + KeyboardScriptingInterface.raised = false; d.resize(); } Component.onDestruction: { diff --git a/interface/resources/qml/LoginDialog/LoggingInBody.qml b/interface/resources/qml/LoginDialog/LoggingInBody.qml index 6913269c7c..4f7db1c4bf 100644 --- a/interface/resources/qml/LoginDialog/LoggingInBody.qml +++ b/interface/resources/qml/LoginDialog/LoggingInBody.qml @@ -230,7 +230,7 @@ Item { // Alignment horizontalAlignment: Text.AlignHCenter; verticalAlignment: Text.AlignVCenter; - visible: loggingInBody.withSteam; + visible: false; } } } @@ -262,19 +262,20 @@ Item { onHandleLoginFailed: { console.log("Login Failed") + loggingInSpinner.visible = false; var errorString = ""; if (loggingInBody.withSteam && loggingInBody.fromBody === "LinkAccountBody") { loggingInGlyph.visible = false; loggingInText.text = "Your Steam authentication has failed. Please make sure you are logged into Steam and try again." + loggingInText.width = loggingInBody.width; loggingInText.wrapMode = Text.WordWrap; loggingInText.anchors.centerIn = loggingInHeader; - loggingInText.anchors.bottom = loggingInHeader.bottom; steamFailureTimer.start(); } else if (loggingInBody.withSteam) { errorString = "Your Steam authentication has failed. Please make sure you are logged into Steam and try again."; bodyLoader.setSource("UsernameCollisionBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "errorString": errorString }); } else { - errorString = loginDialog.isLogIn ? "Username or password is incorrect." : "Failed to sign up. Please try again."; + errorString = "Username or password is incorrect."; if (loginDialog.isLogIn && loginDialog.isSteamRunning()) { bodyLoader.setSource("CompleteProfileBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader }); } else { diff --git a/interface/resources/qml/LoginDialog/SignInBody.qml b/interface/resources/qml/LoginDialog/SignInBody.qml index fb7d1cf551..55b40fde30 100644 --- a/interface/resources/qml/LoginDialog/SignInBody.qml +++ b/interface/resources/qml/LoginDialog/SignInBody.qml @@ -65,7 +65,8 @@ Item { if (loginDialog.isLogIn) { loginDialog.login(emailField.text, passwordField.text); } else { - loginDialog.signup(usernameField.text, emailField.text, passwordField.text); + loginDialog.signup(emailField.text, usernameField.text, passwordField.text); + return; } bodyLoader.setSource("LoggingInBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": false, "fromBody": "" }); } @@ -484,4 +485,23 @@ Item { break; } } + Connections { + target: loginDialog + onHandleSignupCompleted: { + console.log("Sign Up Completed"); + + loginDialog.login(usernameField.text, passwordField.text); + bodyLoader.setSource("LoggingInBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": false, "fromBody": "" }); + } + onHandleSignupFailed: { + console.log("Sign Up Failed") + + loginErrorMessage.visible = (errorString !== ""); + if (errorString !== "") { + loginErrorMessage.text = errorString; + errorContainer.anchors.bottom = loginDialog.isLogIn ? emailField.top : usernameField.top; + errorContainer.anchors.left = emailField.left; + } + } + } } diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ce4308b228..978bb96a1f 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1316,6 +1316,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo connect(this, &Application::activeDisplayPluginChanged, this, &Application::updateSystemTabletMode); connect(this, &Application::activeDisplayPluginChanged, this, [&](){ auto dialogsManager = DependencyManager::get(); + auto keyboard = DependencyManager::get(); if (getLoginDialogPoppedUp()) { if (_firstRun.get()) { // display mode changed. Don't allow auto-switch to work after this session. @@ -1327,6 +1328,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo createLoginDialogOverlay(); } else { // Desktop mode. + QVariantMap properties{ + { "parentID", QUuid() } + }; + getOverlays().editOverlay(keyboard->getAnchorID(), properties); getOverlays().deleteOverlay(_loginDialogOverlayID); _loginDialogOverlayID = OverlayID(); _loginStateManager.tearDown(); @@ -6251,7 +6256,7 @@ void Application::update(float deltaTime) { _overlays.update(deltaTime); } if (!_loginDialogOverlayID.isNull()) { - _loginStateManager.update(); + _loginStateManager.update(getMyAvatar()->getDominantHand()); } if (!_loginDialogOverlayID.isNull()) { @@ -8662,7 +8667,7 @@ void Application::createLoginDialogOverlay() { QVariantMap properties { { "parentID", _loginDialogOverlayID }, { "localPosition", vec3toVariant(glm::vec3(-0.3f, -0.3f, 0.2f)) }, - { "localOrientation", quatToVariant(glm::quat(0.0f, 0.0, 1.0f, 0.0f)) } + { "localOrientation", quatToVariant(glm::quat(0.0f, 0.0, 1.0f, 0.25f)) }, }; getOverlays().editOverlay(keyboard->getAnchorID(), properties); keyboard->setResetKeyboardPositionOnRaise(false); diff --git a/interface/src/LoginStateManager.cpp b/interface/src/LoginStateManager.cpp index a393cbf178..a77b61e723 100644 --- a/interface/src/LoginStateManager.cpp +++ b/interface/src/LoginStateManager.cpp @@ -19,6 +19,7 @@ #include "controllers/StateController.h" #include "controllers/UserInputMapper.h" #include "raypick/PointerScriptingInterface.h" +#include "raypick/RayPickScriptingInterface.h" #include "raypick/PickScriptingInterface.h" #include "scripting/ControllerScriptingInterface.h" @@ -209,15 +210,29 @@ void LoginStateManager::setUp() { pointers->enablePointer(_rightLoginPointerID); } -void LoginStateManager::update() { +void LoginStateManager::update(const QString dominantHand) { + if (!isSetUp()) { + return; + } + if (_dominantHand != dominantHand) { + _dominantHand = dominantHand; + } auto pointers = DependencyManager::get(); - if (pointers) { + auto raypicks = DependencyManager::get(); + if (pointers && raypicks) { QString mode = "full"; - - if (_leftLoginPointerID > PointerEvent::INVALID_POINTER_ID) { + auto rightObjectID = raypicks->getPrevRayPickResult(_rightLoginPointerID)["objectID"].toUuid(); + auto leftObjectID = raypicks->getPrevRayPickResult(_leftLoginPointerID)["objectID"].toUuid(); + if (_dominantHand == "left" && !leftObjectID.isNull()) { + // dominant is left. + pointers->setRenderState(_rightLoginPointerID, ""); + pointers->setRenderState(_leftLoginPointerID, mode); + } else if (_dominantHand == "right" && !rightObjectID.isNull()) { + // dominant is right. + pointers->setRenderState(_leftLoginPointerID, ""); + pointers->setRenderState(_rightLoginPointerID, mode); + } else { pointers->setRenderState(_leftLoginPointerID, mode); - } - if (_rightLoginPointerID > PointerEvent::INVALID_POINTER_ID) { pointers->setRenderState(_rightLoginPointerID, mode); } } diff --git a/interface/src/LoginStateManager.h b/interface/src/LoginStateManager.h index 8a4c12fb34..3228d2e8e6 100644 --- a/interface/src/LoginStateManager.h +++ b/interface/src/LoginStateManager.h @@ -26,11 +26,12 @@ public: void setUp(); void tearDown(); - void update(); + void update(const QString dominantHand); bool isSetUp() const { return (_leftLoginPointerID > PointerEvent::INVALID_POINTER_ID) && (_rightLoginPointerID > PointerEvent::INVALID_POINTER_ID); } private: + QString _dominantHand; QList _renderStates {}; QList _defaultRenderStates {}; unsigned int _leftLoginPointerID { PointerEvent::INVALID_POINTER_ID }; diff --git a/interface/src/ui/LoginDialog.cpp b/interface/src/ui/LoginDialog.cpp index 5b920b90f7..d8339571b7 100644 --- a/interface/src/ui/LoginDialog.cpp +++ b/interface/src/ui/LoginDialog.cpp @@ -196,13 +196,17 @@ void LoginDialog::openUrl(const QString& url) const { offscreenUi->load("Browser.qml", [=](QQmlContext* context, QObject* newObject) { newObject->setProperty("url", url); }); - LoginDialog::hide(); + if (!qApp->getLoginDialogPoppedUp()) { + LoginDialog::hide(); + } } else { if (!hmd->getShouldShowTablet() && !qApp->isHMDMode()) { offscreenUi->load("Browser.qml", [=](QQmlContext* context, QObject* newObject) { newObject->setProperty("url", url); }); - LoginDialog::hide(); + if (!qApp->getLoginDialogPoppedUp()) { + LoginDialog::hide(); + } } else { tablet->gotoWebScreen(url); }