From 1ce7d8a31c9e5410339b60b42d5f8b6ea4e78418 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 13 Dec 2018 13:47:07 -0800 Subject: [PATCH] dev feedback --- .../qml/LoginDialog/LinkAccountBody.qml | 5 +- .../resources/qml/LoginDialog/SignUpBody.qml | 5 +- .../resources/qml/windows/ModalFrame.qml | 49 ++++++--------- interface/src/Application.cpp | 61 +++++++++---------- interface/src/Application.h | 1 - interface/src/LoginStateManager.cpp | 18 +++--- .../src/scripting/HMDScriptingInterface.h | 1 - interface/src/ui/LoginDialog.cpp | 22 ------- interface/src/ui/LoginDialog.h | 2 - interface/src/ui/overlays/Web3DOverlay.cpp | 10 +-- 10 files changed, 68 insertions(+), 106 deletions(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index e015a071b4..6edc2d5c61 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -30,6 +30,7 @@ Item { property int fontSize: 15 property int textFieldFontSize: 18 property bool fontBold: true + readonly property var passwordImageRatio: 16 / 23 property bool keyboardEnabled: false property bool keyboardRaised: false @@ -213,8 +214,8 @@ Item { Image { id: showPasswordImage - width: passwordField.height * 16 / 23 - height: passwordField.height * 16 / 23 + width: passwordField.height * passwordImageRatio + height: passwordField.height * passwordImageRatio anchors { right: parent.right rightMargin: 8 diff --git a/interface/resources/qml/LoginDialog/SignUpBody.qml b/interface/resources/qml/LoginDialog/SignUpBody.qml index d49d92feeb..3280d1f54f 100644 --- a/interface/resources/qml/LoginDialog/SignUpBody.qml +++ b/interface/resources/qml/LoginDialog/SignUpBody.qml @@ -28,6 +28,7 @@ Item { property int fontSize: 15 property int textFieldFontSize: 18 property bool fontBold: true + readonly property var passwordImageRatio: 16 / 23 property bool keyboardEnabled: false property bool keyboardRaised: false @@ -249,8 +250,8 @@ Item { Image { id: showPasswordImage - width: passwordField.height * 16 / 23 - height: passwordField.height * 16 / 23 + width: passwordField.height * passwordImageRatio + height: passwordField.height * passwordImageRatio anchors { right: parent.right rightMargin: 8 diff --git a/interface/resources/qml/windows/ModalFrame.qml b/interface/resources/qml/windows/ModalFrame.qml index f1733ec32c..f7e06ad4ac 100644 --- a/interface/resources/qml/windows/ModalFrame.qml +++ b/interface/resources/qml/windows/ModalFrame.qml @@ -85,35 +85,6 @@ Frame { y: -hifi.dimensions.modalDialogTitleHeight anchors.right: parent.right } - // spacer for closeButton - Rectangle { - id: closeButtonSpacer - width: parent.width - closeButton.width - 50 - height: 20 - color: "transparent" - anchors.left: title.right - y: -hifi.dimensions.modalDialogTitleHeight - visible: window.closeButtonVisible - } - - GlyphButton { - id: closeButton - visible: window.closeButtonVisible - width: 30 - y: -hifi.dimensions.modalDialogTitleHeight - 20 - anchors { - // top: parent.top - left: closeButtonSpacer.right - // topMargin: 10 - // rightMargin: 10 - } - glyph: hifi.glyphs.close - size: 23 - onClicked: { - window.clickedCloseButton = true; - window.destroy(); - } - } } Rectangle { @@ -123,5 +94,25 @@ Frame { color: hifi.colors.lightGray } } + + + GlyphButton { + id: closeButton + visible: window.closeButtonVisible + width: 30 + y: -hifi.dimensions.modalDialogTitleHeight + anchors { + top: parent.top + right: parent.right + topMargin: 10 + rightMargin: 10 + } + glyph: hifi.glyphs.close + size: 23 + onClicked: { + window.clickedCloseButton = true; + window.destroy(); + } + } } } diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index d544549ef2..c7e1558767 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1785,7 +1785,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo }); connect(offscreenUi.data(), &OffscreenUi::keyboardFocusActive, [this]() { -#if !defined(Q_OS_ANDROID) +#if !defined(Q_OS_ANDROID) && !defined(DISABLE_QML) // Do not show login dialog if requested not to on the command line QString hifiNoLoginCommandLineKey = QString("--").append(HIFI_NO_LOGIN_COMMAND_LINE_KEY); int index = arguments().indexOf(hifiNoLoginCommandLineKey); @@ -1794,7 +1794,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo return; } - // only for non-android. QML is ready to be shown at this time. showLoginScreen(); #else resumeAfterLoginDialogActionTaken(); @@ -5266,7 +5265,6 @@ void Application::resumeAfterLoginDialogActionTaken() { addressManager->goToEntry(); } else { QVariant testProperty = property(hifi::properties::TEST); - qDebug() << testProperty; if (testProperty.isValid()) { const auto testScript = property(hifi::properties::TEST).toUrl(); // Set last parameter to exit interface when the test script finishes, if so requested @@ -8624,14 +8622,14 @@ void Application::setShowBulletConstraintLimits(bool value) { } void Application::createLoginDialogOverlay() { - auto cameraPosition = _myCamera.getPosition(); - auto cameraOrientation = _myCamera.getOrientation(); - auto upVec = getMyAvatar()->getWorldOrientation() * Vectors::UNIT_Y; - auto headLookVec = (cameraOrientation * Vectors::FRONT); + const auto cameraPosition = _myCamera.getPosition(); + const auto cameraOrientation = _myCamera.getOrientation(); + const auto upVec = getMyAvatar()->getWorldOrientation() * Vectors::UNIT_Y; + const auto headLookVec = (cameraOrientation * Vectors::FRONT); // DEFAULT_DPI / tablet scale percentage - float overlayDpi = 31.0f / (75.0f / 100.0f); - auto offset = headLookVec * 0.7f; - auto overlayPosition = (cameraPosition + offset) + (upVec * -0.1f); + const float overlayDpi = 31.0f / (75.0f / 100.0f); + const auto offset = headLookVec * 0.7f; + const auto overlayPosition = (cameraPosition + offset) + (upVec * -0.1f); const glm::vec2 LOGIN_OVERLAY_DIMENSIONS{ 0.89f, 0.5f }; QVariantMap overlayProperties = { @@ -8652,9 +8650,11 @@ void Application::createLoginDialogOverlay() { auto loginOverlay = std::dynamic_pointer_cast(overlays.getOverlay(_loginDialogOverlayID)); auto keyboard = DependencyManager::get().data(); if (!keyboard->getAnchorID().isNull() && !_loginDialogOverlayID.isNull()) { + const auto keyboardLocalOrientation = glm::quat(0.0f, 0.0, 1.0f, 0.25f); + const auto keyboardLocalOffset = glm::vec3(-0.4f * getMyAvatar()->getSensorToWorldScale(), -0.3f, 0.2f); QVariantMap properties { - { "position", vec3toVariant(loginOverlay->getWorldPosition() + glm::vec3(-0.4f * getMyAvatar()->getSensorToWorldScale(), -0.3f, 0.2f)) }, - { "orientation", quatToVariant(loginOverlay->getWorldOrientation() * glm::quat(0.0f, 0.0, 1.0f, 0.25f)) }, + { "position", vec3toVariant(loginOverlay->getWorldPosition() + keyboardLocalOffset) }, + { "orientation", quatToVariant(loginOverlay->getWorldOrientation() * keyboardLocalOrientation) }, }; overlays.editOverlay(keyboard->getAnchorID(), properties); keyboard->setResetKeyboardPositionOnRaise(false); @@ -8670,32 +8670,28 @@ void Application::createLoginDialogOverlay() { void Application::updateLoginDialogOverlayPosition() { const float LOOK_AWAY_THRESHOLD_ANGLE = 40.0f; + const auto overlayOffset = glm::vec2(0.7f, -0.1f); auto& overlays = getOverlays(); auto loginOverlay = std::dynamic_pointer_cast(overlays.getOverlay(_loginDialogOverlayID)); - auto overlayPositionVec = loginOverlay->getWorldPosition(); - auto cameraPositionVec = _myCamera.getPosition(); - auto cameraOrientation = _myCamera.getOrientation(); - cameraOrientation = cancelOutRollAndPitch(cameraOrientation); - auto headLookVec = (cameraOrientation * Vectors::FRONT); - auto overlayToHeadVec = overlayPositionVec - cameraPositionVec; - auto pointAngle = (glm::acos(glm::dot(glm::normalize(overlayToHeadVec), glm::normalize(headLookVec))) * 180.0f / PI); - auto upVec = getMyAvatar()->getWorldOrientation() * Vectors::UNIT_Y; - auto offset = headLookVec * 0.7f; - auto newOverlayPositionVec = (cameraPositionVec + offset) + (upVec * -0.1f); - auto newOverlayOrientation = glm::inverse(glm::quat_cast(glm::lookAt(newOverlayPositionVec, cameraPositionVec, upVec))) * Quaternions::Y_180; + const auto overlayPositionVec = loginOverlay->getWorldPosition(); + const auto cameraPositionVec = _myCamera.getPosition(); + const auto cameraOrientation = cancelOutRollAndPitch(_myCamera.getOrientation()); + const auto headLookVec = (cameraOrientation * Vectors::FRONT); + const auto overlayToHeadVec = overlayPositionVec - cameraPositionVec; + const auto pointAngle = (glm::acos(glm::dot(glm::normalize(overlayToHeadVec), glm::normalize(headLookVec))) * 180.0f / PI); + const auto upVec = getMyAvatar()->getWorldOrientation() * Vectors::UNIT_Y; + const auto offset = headLookVec * overlayOffset.x; + const auto newOverlayPositionVec = (cameraPositionVec + offset) + (upVec * overlayOffset.y); + const auto newOverlayOrientation = glm::inverse(glm::quat_cast(glm::lookAt(newOverlayPositionVec, cameraPositionVec, upVec))) * Quaternions::Y_180; - bool overlayOutOfBounds = glm::distance(overlayPositionVec, cameraPositionVec) > 1.0f; + const bool overlayOutOfBounds = glm::distance(overlayPositionVec, cameraPositionVec) > 1.0f; if (pointAngle > LOOK_AWAY_THRESHOLD_ANGLE || overlayOutOfBounds) { - QVariantMap properties { - {"position", vec3toVariant(newOverlayPositionVec)}, - {"orientation", quatToVariant(newOverlayOrientation)} - }; - overlays.editOverlay(_loginDialogOverlayID, properties); - auto keyboardPositionOffsetVec = newOverlayOrientation * glm::vec3(-0.4f * getMyAvatar()->getSensorToWorldScale(), -0.3f, 0.2f); + const auto keyboardLocalOrientation = glm::quat(0.0f, 0.0, 1.0f, 0.25f); + const auto keyboardLocalOffset = glm::vec3(-0.4f * getMyAvatar()->getSensorToWorldScale(), -0.3f, 0.2f); QVariantMap keyboardProperties { - { "position", vec3toVariant(newOverlayPositionVec + keyboardPositionOffsetVec) }, - { "orientation", quatToVariant(newOverlayOrientation * glm::quat(0.0f, 0.0, 1.0f, 0.25f)) }, + { "position", vec3toVariant(loginOverlay->getWorldPosition() + keyboardLocalOffset) }, + { "orientation", quatToVariant(loginOverlay->getWorldOrientation() * keyboardLocalOrientation) }, }; auto keyboard = DependencyManager::get().data(); overlays.editOverlay(keyboard->getAnchorID(), keyboardProperties); @@ -8709,7 +8705,6 @@ void Application::onDismissedLoginDialog() { keyboard->setResetKeyboardPositionOnRaise(true); if (!_loginDialogOverlayID.isNull()) { // deleting overlay. - qDebug() << "Deleting overlay"; getOverlays().deleteOverlay(_loginDialogOverlayID); _loginDialogOverlayID = OverlayID(); _loginStateManager.tearDown(); diff --git a/interface/src/Application.h b/interface/src/Application.h index a3bbb2b83f..e75854a1a4 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -690,7 +690,6 @@ private: bool _interstitialModeEnabled{ false }; bool _loginDialogPoppedUp = false; - // if visible before login popped up. bool _developerMenuVisible{ false }; CameraMode _previousCameraMode; OverlayID _loginDialogOverlayID; diff --git a/interface/src/LoginStateManager.cpp b/interface/src/LoginStateManager.cpp index 2f42649349..8811303f7d 100644 --- a/interface/src/LoginStateManager.cpp +++ b/interface/src/LoginStateManager.cpp @@ -149,12 +149,12 @@ void LoginStateManager::setUp() { _renderStates = QList({halfRenderStateIdentifier, fullRenderStateIdentifier, holdRenderStateIdentifier}); _defaultRenderStates = QList({halfDefaultRenderStateIdentifier, fullDefaultRenderStateIdentifier, holdDefaultRenderStateIdentifier}); - auto pointers = DependencyManager::get().data(); - auto controller = DependencyManager::get().data(); + auto pointers = DependencyManager::get(); + auto controller = DependencyManager::get(); - glm::vec3 grabPointSphereOffsetLeft { -0.04f, 0.13f, 0.039f }; // x = upward, y = forward, z = lateral - glm::vec3 grabPointSphereOffsetRight { 0.04f, 0.13f, 0.039f }; // x = upward, y = forward, z = lateral - glm::vec3 malletOffset {glm::vec3(0.0f, 0.18f - 0.050f, 0.0f)}; + const glm::vec3 grabPointSphereOffsetLeft { -0.04f, 0.13f, 0.039f }; // x = upward, y = forward, z = lateral + const glm::vec3 grabPointSphereOffsetRight { 0.04f, 0.13f, 0.039f }; // x = upward, y = forward, z = lateral + const glm::vec3 malletOffset {glm::vec3(0.0f, 0.18f - 0.050f, 0.0f)}; QList leftPointerTriggerProperties; QVariantMap ltClick1 { @@ -222,10 +222,10 @@ void LoginStateManager::update(const QString dominantHand, const QUuid loginOver auto pointers = DependencyManager::get(); auto raypicks = DependencyManager::get(); if (pointers && raypicks) { - auto rightObjectID = raypicks->getPrevRayPickResult(_rightLoginPointerID)["objectID"].toUuid(); - auto leftObjectID = raypicks->getPrevRayPickResult(_leftLoginPointerID)["objectID"].toUuid(); - QString leftMode = (leftObjectID.isNull() || leftObjectID != loginOverlayID) ? "" : "full"; - QString rightMode = (rightObjectID.isNull() || rightObjectID != loginOverlayID) ? "" : "full"; + const auto rightObjectID = raypicks->getPrevRayPickResult(_rightLoginPointerID)["objectID"].toUuid(); + const auto leftObjectID = raypicks->getPrevRayPickResult(_leftLoginPointerID)["objectID"].toUuid(); + const QString leftMode = (leftObjectID.isNull() || leftObjectID != loginOverlayID) ? "" : "full"; + const QString rightMode = (rightObjectID.isNull() || rightObjectID != loginOverlayID) ? "" : "full"; pointers->setRenderState(_leftLoginPointerID, leftMode); pointers->setRenderState(_rightLoginPointerID, rightMode); if (_dominantHand == "left" && !leftObjectID.isNull()) { diff --git a/interface/src/scripting/HMDScriptingInterface.h b/interface/src/scripting/HMDScriptingInterface.h index c20390dbd0..81f85409cc 100644 --- a/interface/src/scripting/HMDScriptingInterface.h +++ b/interface/src/scripting/HMDScriptingInterface.h @@ -413,7 +413,6 @@ public: QVariant getPlayAreaRect(); QVector getSensorPositions(); - // Get the position of the HMD glm::vec3 getPosition() const; private: diff --git a/interface/src/ui/LoginDialog.cpp b/interface/src/ui/LoginDialog.cpp index dc5422e488..54f85dc932 100644 --- a/interface/src/ui/LoginDialog.cpp +++ b/interface/src/ui/LoginDialog.cpp @@ -109,9 +109,6 @@ bool LoginDialog::isOculusStoreRunning() const { } void LoginDialog::dismissLoginDialog() { - // it'll only pop up once. - qDebug() << "LoginDialog::dismissLoginDialog"; - QAction* loginAction = Menu::getInstance()->getActionForOption(MenuOption::Login); Q_CHECK_PTR(loginAction); loginAction->setEnabled(true); @@ -124,25 +121,6 @@ void LoginDialog::login(const QString& username, const QString& password) const DependencyManager::get()->requestAccessToken(username, password); } -void LoginDialog::loginThroughOculus() { - qDebug() << "Attempting to login through Oculus"; - if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) { - steamClient->requestTicket([this](Ticket ticket) { - if (ticket.isNull()) { - emit handleLoginFailed(); - return; - } - - DependencyManager::get()->requestAccessTokenWithSteam(ticket); - }); - } -} - -void LoginDialog::linkOculus() { - qDebug() << "Attempting to link Oculus account"; - -} - void LoginDialog::loginThroughSteam() { qDebug() << "Attempting to login through Steam"; if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) { diff --git a/interface/src/ui/LoginDialog.h b/interface/src/ui/LoginDialog.h index c9f12b691d..2714d654bf 100644 --- a/interface/src/ui/LoginDialog.h +++ b/interface/src/ui/LoginDialog.h @@ -70,8 +70,6 @@ protected slots: Q_INVOKABLE bool isOculusStoreRunning() const; Q_INVOKABLE void login(const QString& username, const QString& password) const; - Q_INVOKABLE void loginThroughOculus(); - Q_INVOKABLE void linkOculus(); Q_INVOKABLE void loginThroughSteam(); Q_INVOKABLE void linkSteam(); Q_INVOKABLE void createAccountFromSteam(QString username = QString()); diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index a36a5481c2..18b7150b4a 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -232,12 +232,12 @@ void Web3DOverlay::setupQmlSurface(bool isTablet, bool isLoginDialog) { _webSurface->getSurfaceContext()->setContextProperty("MyAvatar", DependencyManager::get()->getMyAvatar().get()); _webSurface->getSurfaceContext()->setContextProperty("Entities", DependencyManager::get().data()); _webSurface->getSurfaceContext()->setContextProperty("Snapshot", DependencyManager::get().data()); - _webSurface->getSurfaceContext()->setContextProperty("Settings", SettingsScriptingInterface::getInstance()); - _webSurface->getSurfaceContext()->setContextProperty("MenuInterface", MenuScriptingInterface::getInstance()); - _webSurface->getSurfaceContext()->setContextProperty("KeyboardScriptingInterface", DependencyManager::get().data()); if (isTablet || isLoginDialog) { _webSurface->getSurfaceContext()->setContextProperty("Account", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED + _webSurface->getSurfaceContext()->setContextProperty("Settings", SettingsScriptingInterface::getInstance()); + _webSurface->getSurfaceContext()->setContextProperty("MenuInterface", MenuScriptingInterface::getInstance()); + _webSurface->getSurfaceContext()->setContextProperty("KeyboardScriptingInterface", DependencyManager::get().data()); } if (isTablet) { auto tabletScriptingInterface = DependencyManager::get(); @@ -545,7 +545,7 @@ void Web3DOverlay::setProperties(const QVariantMap& properties) { * @property {boolean} visible=true - If true, the overlay is rendered, otherwise it is not rendered. * * @property {string} name="" - A friendly name for the overlay. - * @property {Vec3} position - The position of the overlay center. Synonyms: p1, point, and + * @property {Vec3} position - The position of the overlay center. Synonyms: p1, point, and * start. * @property {Vec3} localPosition - The local position of the overlay relative to its parent if the overlay has a * parentID set, otherwise the same value as position. @@ -570,7 +570,7 @@ void Web3DOverlay::setProperties(const QVariantMap& properties) { * @property {string} url - The URL of the Web page to display. * @property {string} scriptURL="" - The URL of a JavaScript file to inject into the Web page. * @property {number} dpi=30 - The dots per inch to display the Web page at, on the overlay. - * @property {Vec2} dimensions=1,1 - The size of the overlay to display the Web page on, in meters. Synonyms: + * @property {Vec2} dimensions=1,1 - The size of the overlay to display the Web page on, in meters. Synonyms: * scale, size. * @property {number} maxFPS=10 - The maximum update rate for the Web overlay content, in frames/second. * @property {boolean} showKeyboardFocusHighlight=true - If true, the Web overlay is highlighted when it has