From b0fb7778cf3696332e56515918b6c640262358c2 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 28 Nov 2018 19:17:30 -0800 Subject: [PATCH] fixing some text, turning off lasers until they intersect login overlay --- .../qml/LoginDialog/CantAccessBody.qml | 157 ++++++++++++++++++ .../qml/LoginDialog/LinkAccountBody.qml | 107 ++++++------ .../resources/qml/LoginDialog/SignUpBody.qml | 37 ++--- .../resources/qml/LoginDialog/WelcomeBody.qml | 90 ---------- interface/src/Application.cpp | 4 +- interface/src/LoginStateManager.cpp | 8 +- interface/src/LoginStateManager.h | 2 +- 7 files changed, 236 insertions(+), 169 deletions(-) create mode 100644 interface/resources/qml/LoginDialog/CantAccessBody.qml delete mode 100644 interface/resources/qml/LoginDialog/WelcomeBody.qml diff --git a/interface/resources/qml/LoginDialog/CantAccessBody.qml b/interface/resources/qml/LoginDialog/CantAccessBody.qml new file mode 100644 index 0000000000..b1cef05948 --- /dev/null +++ b/interface/resources/qml/LoginDialog/CantAccessBody.qml @@ -0,0 +1,157 @@ +// +// CantAccessBody.qml +// +// Created by Wayne Chen on 11/28/18 +// Copyright 2018 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 controlsUit 1.0 as HifiControlsUit +import stylesUit 1.0 as HifiStylesUit + +Item { + id: cantAccessBody + clip: true + width: root.width + height: root.height + property int textFieldHeight: 31 + property string fontFamily: "Raleway" + property int fontSize: 15 + // property int textFieldFontSize: !root.isTablet ? !root.isOverlay : hifi.fontSizes.textFieldInput ? hifi.fontSizes.textFieldInput : 18 + property int textFontSize: 24 + property bool fontBold: true + + QtObject { + id: d + readonly property int minWidth: 480 + readonly property int minWidthButton: !root.isTablet ? 256 : 174 + property int maxWidth: root.isTablet ? 1280 : root.width + readonly property int minHeight: 120 + // readonly property int minHeightButton: !root.isTablet ? 56 : 42 + readonly property int minHeightButton: 36 + property int maxHeight: root.isTablet ? 720 : root.height + + function resize() { + maxWidth = root.isTablet ? 1280 : root.width; + maxHeight = root.isTablet ? 720 : root.height; + var targetWidth = Math.max(titleWidth, mainContainer.width); + var targetHeight = hifi.dimensions.contentSpacing.y + mainContainer.height + 4 * hifi.dimensions.contentSpacing.y; + + var newWidth = Math.max(d.minWidth, Math.min(d.maxWidth, targetWidth)); + if (!isNaN(newWidth)) { + parent.width = root.width = newWidth; + } + + parent.height = root.height = Math.max(d.minHeight, Math.min(d.maxHeight, targetHeight)) + hifi.dimensions.contentSpacing.y; + } + } + + Item { + id: mainContainer + anchors.fill: parent + onHeightChanged: d.resize(); onWidthChanged: d.resize(); + + Rectangle { + id: opaqueRect + height: parent.height + width: parent.width + opacity: 0.9 + color: "black" + } + Item { + id: bannerContainer + width: parent.width + height: banner.height + anchors { + bottom: textContainer.top + bottomMargin: 0.125 * parent.height + } + Image { + id: banner + anchors.centerIn: parent + source: "../../images/high-fidelity-banner.svg" + horizontalAlignment: Image.AlignHCenter + } + } + + Item { + id: textContainer + width: parent.width + height: 0.45 * parent.height + anchors { + top: parent.top + topMargin: bannerContainer.height + 0.25 * parent.height + left: parent.left + } + TextMetrics { + id: titleTextMetrics + font: titleText.font + text: titleText.text + } + Text { + id: titleText + anchors { + top: parent.top + topMargin: 0.2 * parent.height + left: parent.left + leftMargin: (parent.width - titleTextMetrics.width) / 2 + } + text: qsTr("Can't Access Account") + font.pixelSize: cantAccessBody.textFontSize + 10 + font.bold: cantAccessBody.fontBold + color: "white" + lineHeight: 2 + lineHeightMode: Text.ProportionalHeight + horizontalAlignment: Text.AlignHCenter + } + + TextMetrics { + id: bodyTextMetrics + font: bodyText.font + text: bodyText.text + } + Text { + id: bodyText + anchors { + top: titleText.bottom + topMargin: hifi.dimensions.contentSpacing.y + left: parent.left + leftMargin: (parent.width - bodyTextMetrics.width) / 2 + } + text: qsTr("Please navigate to your default browser to recover your account.\nIf you are in a VR headset, please take it off.") + font.pixelSize: cantAccessBody.textFontSize + color: "white" + wrapMode: Text.WordWrap + lineHeight: 2 + lineHeightMode: Text.ProportionalHeight + horizontalAlignment: Text.AlignHCenter + } + } + + HifiControlsUit.Button { + id: okButton + height: d.minHeightButton + anchors { + bottom: parent.bottom + right: parent.right + margins: 3 * hifi.dimensions.contentSpacing.y + } + text: qsTr("OK") + fontFamily: cantAccessBody.fontFamily + fontSize: cantAccessBody.fontSize + fontBold: cantAccessBody.fontBold + onClicked: { + bodyLoader.setSource("LinkAccountBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "errorString": ""}); + } + } + + } + Component.onCompleted: { + d.resize(); + } +} diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 79ec2c5bbc..1fc1b3d1e2 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -100,8 +100,8 @@ Item { width: parent.width height: banner.height anchors { - top: parent.top - topMargin: 0.03 * parent.height + bottom: loginContainer.top + bottomMargin: 0.125 * parent.height } Image { id: banner @@ -110,14 +110,15 @@ Item { horizontalAlignment: Image.AlignHCenter } } - Item { id: loginContainer - width: parent.width - height: parent.height - (bannerContainer.height + 1.5 * hifi.dimensions.contentSpacing.y) + width: emailField.width + height: 0.45 * parent.height anchors { - top: bannerContainer.bottom - topMargin: 1.5 * hifi.dimensions.contentSpacing.y + top: parent.top + topMargin: bannerContainer.height + 0.25 * parent.height + left: parent.left + leftMargin: (parent.width - emailField.width) / 2 } Item { id: errorContainer @@ -152,9 +153,7 @@ Item { font.pixelSize: linkAccountBody.textFieldFontSize anchors { top: parent.top - topMargin: 0.2 * root.height - left: parent.left - leftMargin: (parent.width - emailField.width) / 2 + topMargin: loginErrorMessage.height } placeholderText: "Username or Email" activeFocusOnPress: true @@ -194,8 +193,6 @@ Item { anchors { top: emailField.bottom topMargin: 1.5 * hifi.dimensions.contentSpacing.y - left: parent.left - leftMargin: (parent.width - emailField.width) / 2 } onFocusChanged: { @@ -317,7 +314,8 @@ Item { linkColor: hifi.colors.blueAccent onLinkActivated: { Tablet.playSound(TabletEnums.ButtonClick); - loginDialog.openUrl(link) + loginDialog.openUrl(link); + bodyLoader.setSource("CantAccessBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader }); } } HifiControlsUit.Button { @@ -361,52 +359,52 @@ Item { } } - Item { - id: signUpContainer - width: emailField.width - height: emailField.height + } + Item { + id: signUpContainer + width: loginContainer.width + height: signUpTextMetrics.height + anchors { + left: loginContainer.left + top: loginContainer.bottom + // topMargin: 0.25 * parent.height + } + TextMetrics { + id: signUpTextMetrics + font: signUpText.font + text: signUpText.text + } + Text { + id: signUpText + text: qsTr("Don't have an account?") anchors { - left: emailField.left - bottom: parent.bottom - bottomMargin: 0.25 * parent.height + left: parent.left } - TextMetrics { - id: signUpTextMetrics - font: signUpText.font - text: signUpText.text - } - Text { - id: signUpText - text: qsTr("Don't have an account?") - anchors { - left: parent.left - } - lineHeight: 1 - color: "white" - font.family: linkAccountBody.fontFamily - font.pixelSize: 18 - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignHCenter + lineHeight: 1 + color: "white" + font.family: linkAccountBody.fontFamily + font.pixelSize: 18 + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + } + + HifiStylesUit.ShortcutText { + id: signUpShortcutText + z: 10 + font.family: linkAccountBody.fontFamily + font.pixelSize: 18 + anchors { + left: signUpText.right + leftMargin: hifi.dimensions.contentSpacing.x } - HifiStylesUit.ShortcutText { - id: signUpShortcutText - z: 10 - font.family: linkAccountBody.fontFamily - font.pixelSize: 18 - anchors { - left: signUpText.right - leftMargin: hifi.dimensions.contentSpacing.x - } + text: "Sign Up" - text: "Sign Up" - - linkColor: hifi.colors.blueAccent - onLinkActivated: { - Tablet.playSound(TabletEnums.ButtonClick); - bodyLoader.setSource("SignUpBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, - "errorString": "" }); - } + linkColor: hifi.colors.blueAccent + onLinkActivated: { + Tablet.playSound(TabletEnums.ButtonClick); + bodyLoader.setSource("SignUpBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, + "errorString": "" }); } } } @@ -430,6 +428,7 @@ Item { fontFamily: linkAccountBody.fontFamily fontSize: linkAccountBody.fontSize fontBold: linkAccountBody.fontBold + visible: loginDialog.getLoginDialogPoppedUp() onClicked: { if (loginDialog.getLoginDialogPoppedUp()) { console.log("[ENCOURAGELOGINDIALOG]: user dismissed login screen") diff --git a/interface/resources/qml/LoginDialog/SignUpBody.qml b/interface/resources/qml/LoginDialog/SignUpBody.qml index 54fd7f1c1b..9558ea620b 100644 --- a/interface/resources/qml/LoginDialog/SignUpBody.qml +++ b/interface/resources/qml/LoginDialog/SignUpBody.qml @@ -59,8 +59,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; } } @@ -103,13 +102,14 @@ Item { color: "black" } + Item { id: bannerContainer width: parent.width height: banner.height anchors { - top: parent.top - topMargin: 85 + bottom: loginContainer.top + bottomMargin: 0.125 * parent.height } Image { id: banner @@ -118,14 +118,15 @@ Item { horizontalAlignment: Image.AlignHCenter } } - Item { id: loginContainer - width: parent.width - height: parent.height - (bannerContainer.height + 1.5 * hifi.dimensions.contentSpacing.y) + width: usernameField.width + height: parent.height - bannerContainer.height anchors { - top: bannerContainer.bottom - topMargin: 1.5 * hifi.dimensions.contentSpacing.y + top: parent.top + topMargin: bannerContainer.height + 0.25 * parent.height + left: parent.left + leftMargin: (parent.width - usernameField.width) / 2 } visible: true @@ -134,9 +135,9 @@ Item { width: loginErrorMessageTextMetrics.width height: loginErrorMessageTextMetrics.height anchors { - bottom: emailField.top; - bottomMargin: 2; - left: emailField.left; + bottom: usernameField.top; + bottomMargin: hifi.dimensions.contentSpacing.y; + left: usernameField.left; } TextMetrics { id: loginErrorMessageTextMetrics @@ -163,9 +164,7 @@ Item { font.pixelSize: signUpBody.textFieldFontSize anchors { top: parent.top - topMargin: 0.2 * parent.height - left: parent.left - leftMargin: (parent.width - usernameField.width) / 2 + topMargin: loginErrorMessage.height } focus: true Keys.onPressed: { @@ -207,8 +206,6 @@ Item { height: signUpBody.textFieldHeight anchors { top: parent.top - left: parent.left - leftMargin: (parent.width - emailField.width) / 2 } placeholderText: "Username or Email" font.pixelSize: signUpBody.textFieldFontSize @@ -255,8 +252,6 @@ Item { anchors { top: emailField.bottom topMargin: 1.5 * hifi.dimensions.contentSpacing.y - left: parent.left - leftMargin: (parent.width - emailField.width) / 2 } onFocusChanged: { @@ -360,7 +355,7 @@ Item { } HifiControlsUit.Button { id: cancelButton - width: 1.2 * cancelButtonTextMetrics.width + width: emailField.width / 2 height: d.minHeightButton anchors { top: keepMeLoggedInCheckbox.bottom @@ -379,7 +374,7 @@ Item { } HifiControlsUit.Button { id: signUpButton - width: d.minWidthButton + width: emailField.width / 2 height: d.minHeightButton color: hifi.buttons.blue text: qsTr("Sign Up") diff --git a/interface/resources/qml/LoginDialog/WelcomeBody.qml b/interface/resources/qml/LoginDialog/WelcomeBody.qml deleted file mode 100644 index 020e6db002..0000000000 --- a/interface/resources/qml/LoginDialog/WelcomeBody.qml +++ /dev/null @@ -1,90 +0,0 @@ -// -// WelcomeBody.qml -// -// Created by Clement on 7/18/16 -// 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 controlsUit 1.0 -import stylesUit 1.0 - -Item { - id: welcomeBody - clip: true - width: root.pane.width - height: root.pane.height - - property bool welcomeBack: false - - function setTitle() { - root.title = (welcomeBack ? qsTr("Welcome back ") : qsTr("Welcome ")) + Account.username + qsTr("!") - root.iconText = "" - 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, mainTextContainer.contentWidth) - var targetHeight = mainTextContainer.height + 3 * hifi.dimensions.contentSpacing.y + buttons.height - - 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)) - } - } - - InfoItem { - id: mainTextContainer - anchors { - top: parent.top - horizontalCenter: parent.horizontalCenter - margins: 0 - topMargin: hifi.dimensions.contentSpacing.y - } - - text: qsTr("You are now signed into High Fidelity") - wrapMode: Text.WordWrap - color: hifi.colors.baseGrayHighlight - lineHeight: 2 - lineHeightMode: Text.ProportionalHeight - horizontalAlignment: Text.AlignHCenter - } - - Row { - id: buttons - anchors { - top: mainTextContainer.bottom - horizontalCenter: parent.horizontalCenter - margins: 0 - topMargin: 2 * hifi.dimensions.contentSpacing.y - } - spacing: hifi.dimensions.contentSpacing.x - onHeightChanged: d.resize(); onWidthChanged: d.resize(); - - Button { - anchors.verticalCenter: parent.verticalCenter - - text: qsTr("Close"); - - onClicked: root.tryDestroy() - } - } - - Component.onCompleted: welcomeBody.setTitle() - - Connections { - target: Account - onUsernameChanged: welcomeBody.setTitle() - } -} diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 64f5982dfe..930a10dccb 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -6267,7 +6267,7 @@ void Application::update(float deltaTime) { _overlays.update(deltaTime); } if (!_loginDialogOverlayID.isNull()) { - _loginStateManager.update(getMyAvatar()->getDominantHand()); + _loginStateManager.update(getMyAvatar()->getDominantHand(), _loginDialogOverlayID); updateLoginDialogOverlayPosition(); } @@ -8631,7 +8631,7 @@ void Application::createLoginDialogOverlay() { auto offset = headLookVec * 0.7f; auto overlayPosition = (cameraPosition + offset) + (upVec * -0.1f); - const glm::vec2 LOGIN_OVERLAY_DIMENSIONS{ 0.5f, 0.5f }; + const glm::vec2 LOGIN_OVERLAY_DIMENSIONS{ 0.89f, 0.5f }; QVariantMap overlayProperties = { { "name", "LoginDialogOverlay" }, { "url", OVERLAY_LOGIN_DIALOG_URL }, diff --git a/interface/src/LoginStateManager.cpp b/interface/src/LoginStateManager.cpp index a77b61e723..3a2e376715 100644 --- a/interface/src/LoginStateManager.cpp +++ b/interface/src/LoginStateManager.cpp @@ -210,7 +210,7 @@ void LoginStateManager::setUp() { pointers->enablePointer(_rightLoginPointerID); } -void LoginStateManager::update(const QString dominantHand) { +void LoginStateManager::update(const QString dominantHand, const QUuid loginOverlayID) { if (!isSetUp()) { return; } @@ -223,6 +223,12 @@ void LoginStateManager::update(const QString dominantHand) { QString mode = "full"; auto rightObjectID = raypicks->getPrevRayPickResult(_rightLoginPointerID)["objectID"].toUuid(); auto leftObjectID = raypicks->getPrevRayPickResult(_leftLoginPointerID)["objectID"].toUuid(); + if (leftObjectID.isNull() || leftObjectID != loginOverlayID) { + pointers->setRenderState(_leftLoginPointerID, ""); + } + if (rightObjectID.isNull() || rightObjectID != loginOverlayID) { + pointers->setRenderState(_leftLoginPointerID, ""); + } if (_dominantHand == "left" && !leftObjectID.isNull()) { // dominant is left. pointers->setRenderState(_rightLoginPointerID, ""); diff --git a/interface/src/LoginStateManager.h b/interface/src/LoginStateManager.h index 3228d2e8e6..db9b24bdeb 100644 --- a/interface/src/LoginStateManager.h +++ b/interface/src/LoginStateManager.h @@ -26,7 +26,7 @@ public: void setUp(); void tearDown(); - void update(const QString dominantHand); + void update(const QString dominantHand, const QUuid loginOverlayID); bool isSetUp() const { return (_leftLoginPointerID > PointerEvent::INVALID_POINTER_ID) && (_rightLoginPointerID > PointerEvent::INVALID_POINTER_ID); }