getting dominant hand laser + sign up working

This commit is contained in:
Wayne Chen 2018-11-20 16:54:16 -08:00
parent 4d55081184
commit cdee10d0b8
7 changed files with 65 additions and 23 deletions

View file

@ -28,12 +28,6 @@ Item {
property bool withSteam: false property bool withSteam: false
property bool keyboardEnabled: false
property bool keyboardRaised: false
property bool punctuationMode: false
onKeyboardRaisedChanged: d.resize();
QtObject { QtObject {
id: d id: d
readonly property int minWidth: 480 readonly property int minWidth: 480
@ -55,8 +49,7 @@ Item {
parent.width = root.width = newWidth; parent.width = root.width = newWidth;
} }
parent.height = root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) parent.height = root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) + hifi.dimensions.contentSpacing.y;
+ (keyboardEnabled && keyboardRaised ? (200 + 2 * hifi.dimensions.contentSpacing.y) : hifi.dimensions.contentSpacing.y);
} }
} }
@ -264,6 +257,9 @@ Item {
} }
Component.onCompleted: { Component.onCompleted: {
root.keyboardEnabled = false;
root.keyboardRaised = false;
KeyboardScriptingInterface.raised = false;
d.resize(); d.resize();
} }
Component.onDestruction: { Component.onDestruction: {

View file

@ -230,7 +230,7 @@ Item {
// Alignment // Alignment
horizontalAlignment: Text.AlignHCenter; horizontalAlignment: Text.AlignHCenter;
verticalAlignment: Text.AlignVCenter; verticalAlignment: Text.AlignVCenter;
visible: loggingInBody.withSteam; visible: false;
} }
} }
} }
@ -262,19 +262,20 @@ Item {
onHandleLoginFailed: { onHandleLoginFailed: {
console.log("Login Failed") console.log("Login Failed")
loggingInSpinner.visible = false;
var errorString = ""; var errorString = "";
if (loggingInBody.withSteam && loggingInBody.fromBody === "LinkAccountBody") { if (loggingInBody.withSteam && loggingInBody.fromBody === "LinkAccountBody") {
loggingInGlyph.visible = false; loggingInGlyph.visible = false;
loggingInText.text = "Your Steam authentication has failed. Please make sure you are logged into Steam and try again." 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.wrapMode = Text.WordWrap;
loggingInText.anchors.centerIn = loggingInHeader; loggingInText.anchors.centerIn = loggingInHeader;
loggingInText.anchors.bottom = loggingInHeader.bottom;
steamFailureTimer.start(); steamFailureTimer.start();
} else if (loggingInBody.withSteam) { } else if (loggingInBody.withSteam) {
errorString = "Your Steam authentication has failed. Please make sure you are logged into Steam and try again."; 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 }); bodyLoader.setSource("UsernameCollisionBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "errorString": errorString });
} else { } 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()) { if (loginDialog.isLogIn && loginDialog.isSteamRunning()) {
bodyLoader.setSource("CompleteProfileBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader }); bodyLoader.setSource("CompleteProfileBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader });
} else { } else {

View file

@ -65,7 +65,8 @@ Item {
if (loginDialog.isLogIn) { if (loginDialog.isLogIn) {
loginDialog.login(emailField.text, passwordField.text); loginDialog.login(emailField.text, passwordField.text);
} else { } else {
loginDialog.signup(usernameField.text, emailField.text, passwordField.text); loginDialog.signup(emailField.text, usernameField.text, passwordField.text);
return;
} }
bodyLoader.setSource("LoggingInBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": false, "fromBody": "" }); bodyLoader.setSource("LoggingInBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": false, "fromBody": "" });
} }
@ -484,4 +485,23 @@ Item {
break; 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;
}
}
}
} }

View file

@ -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, &Application::updateSystemTabletMode);
connect(this, &Application::activeDisplayPluginChanged, this, [&](){ connect(this, &Application::activeDisplayPluginChanged, this, [&](){
auto dialogsManager = DependencyManager::get<DialogsManager>(); auto dialogsManager = DependencyManager::get<DialogsManager>();
auto keyboard = DependencyManager::get<Keyboard>();
if (getLoginDialogPoppedUp()) { if (getLoginDialogPoppedUp()) {
if (_firstRun.get()) { if (_firstRun.get()) {
// display mode changed. Don't allow auto-switch to work after this session. // 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(); createLoginDialogOverlay();
} else { } else {
// Desktop mode. // Desktop mode.
QVariantMap properties{
{ "parentID", QUuid() }
};
getOverlays().editOverlay(keyboard->getAnchorID(), properties);
getOverlays().deleteOverlay(_loginDialogOverlayID); getOverlays().deleteOverlay(_loginDialogOverlayID);
_loginDialogOverlayID = OverlayID(); _loginDialogOverlayID = OverlayID();
_loginStateManager.tearDown(); _loginStateManager.tearDown();
@ -6251,7 +6256,7 @@ void Application::update(float deltaTime) {
_overlays.update(deltaTime); _overlays.update(deltaTime);
} }
if (!_loginDialogOverlayID.isNull()) { if (!_loginDialogOverlayID.isNull()) {
_loginStateManager.update(); _loginStateManager.update(getMyAvatar()->getDominantHand());
} }
if (!_loginDialogOverlayID.isNull()) { if (!_loginDialogOverlayID.isNull()) {
@ -8662,7 +8667,7 @@ void Application::createLoginDialogOverlay() {
QVariantMap properties { QVariantMap properties {
{ "parentID", _loginDialogOverlayID }, { "parentID", _loginDialogOverlayID },
{ "localPosition", vec3toVariant(glm::vec3(-0.3f, -0.3f, 0.2f)) }, { "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); getOverlays().editOverlay(keyboard->getAnchorID(), properties);
keyboard->setResetKeyboardPositionOnRaise(false); keyboard->setResetKeyboardPositionOnRaise(false);

View file

@ -19,6 +19,7 @@
#include "controllers/StateController.h" #include "controllers/StateController.h"
#include "controllers/UserInputMapper.h" #include "controllers/UserInputMapper.h"
#include "raypick/PointerScriptingInterface.h" #include "raypick/PointerScriptingInterface.h"
#include "raypick/RayPickScriptingInterface.h"
#include "raypick/PickScriptingInterface.h" #include "raypick/PickScriptingInterface.h"
#include "scripting/ControllerScriptingInterface.h" #include "scripting/ControllerScriptingInterface.h"
@ -209,15 +210,29 @@ void LoginStateManager::setUp() {
pointers->enablePointer(_rightLoginPointerID); pointers->enablePointer(_rightLoginPointerID);
} }
void LoginStateManager::update() { void LoginStateManager::update(const QString dominantHand) {
if (!isSetUp()) {
return;
}
if (_dominantHand != dominantHand) {
_dominantHand = dominantHand;
}
auto pointers = DependencyManager::get<PointerScriptingInterface>(); auto pointers = DependencyManager::get<PointerScriptingInterface>();
if (pointers) { auto raypicks = DependencyManager::get<RayPickScriptingInterface>();
if (pointers && raypicks) {
QString mode = "full"; QString mode = "full";
auto rightObjectID = raypicks->getPrevRayPickResult(_rightLoginPointerID)["objectID"].toUuid();
if (_leftLoginPointerID > PointerEvent::INVALID_POINTER_ID) { 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); pointers->setRenderState(_leftLoginPointerID, mode);
}
if (_rightLoginPointerID > PointerEvent::INVALID_POINTER_ID) {
pointers->setRenderState(_rightLoginPointerID, mode); pointers->setRenderState(_rightLoginPointerID, mode);
} }
} }

View file

@ -26,11 +26,12 @@ public:
void setUp(); void setUp();
void tearDown(); void tearDown();
void update(); void update(const QString dominantHand);
bool isSetUp() const { return (_leftLoginPointerID > PointerEvent::INVALID_POINTER_ID) && (_rightLoginPointerID > PointerEvent::INVALID_POINTER_ID); } bool isSetUp() const { return (_leftLoginPointerID > PointerEvent::INVALID_POINTER_ID) && (_rightLoginPointerID > PointerEvent::INVALID_POINTER_ID); }
private: private:
QString _dominantHand;
QList<QVariant> _renderStates {}; QList<QVariant> _renderStates {};
QList<QVariant> _defaultRenderStates {}; QList<QVariant> _defaultRenderStates {};
unsigned int _leftLoginPointerID { PointerEvent::INVALID_POINTER_ID }; unsigned int _leftLoginPointerID { PointerEvent::INVALID_POINTER_ID };

View file

@ -196,13 +196,17 @@ void LoginDialog::openUrl(const QString& url) const {
offscreenUi->load("Browser.qml", [=](QQmlContext* context, QObject* newObject) { offscreenUi->load("Browser.qml", [=](QQmlContext* context, QObject* newObject) {
newObject->setProperty("url", url); newObject->setProperty("url", url);
}); });
LoginDialog::hide(); if (!qApp->getLoginDialogPoppedUp()) {
LoginDialog::hide();
}
} else { } else {
if (!hmd->getShouldShowTablet() && !qApp->isHMDMode()) { if (!hmd->getShouldShowTablet() && !qApp->isHMDMode()) {
offscreenUi->load("Browser.qml", [=](QQmlContext* context, QObject* newObject) { offscreenUi->load("Browser.qml", [=](QQmlContext* context, QObject* newObject) {
newObject->setProperty("url", url); newObject->setProperty("url", url);
}); });
LoginDialog::hide(); if (!qApp->getLoginDialogPoppedUp()) {
LoginDialog::hide();
}
} else { } else {
tablet->gotoWebScreen(url); tablet->gotoWebScreen(url);
} }