From 54fe9eec8784345aa0634a2e8b985720efd3a41c Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 30 Oct 2018 10:19:11 -0700 Subject: [PATCH] adding overlay --- interface/src/ui/LoginDialog.cpp | 42 +++++++++++++++++++++++++------- interface/src/ui/LoginDialog.h | 7 ++++++ 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/interface/src/ui/LoginDialog.cpp b/interface/src/ui/LoginDialog.cpp index 1ec098ddb2..1442cbe3ed 100644 --- a/interface/src/ui/LoginDialog.cpp +++ b/interface/src/ui/LoginDialog.cpp @@ -26,11 +26,17 @@ #include "Menu.h" #include "Application.h" +#include "avatar/AvatarManager.h" #include "scripting/HMDScriptingInterface.h" +#include "ui/overlays/Overlays.h" +#include "ui/overlays/Web3DOverlay.h" #include "Constants.h" HIFI_QML_DEF(LoginDialog) +static const QUrl TABLET_LOGIN_DIALOG_URL("dialogs/TabletLoginDialog.qml"); +static const QUrl OVERLAY_LOGIN_DIALOG_URL("../LoginDialog.qml"); + LoginDialog::LoginDialog(QQuickItem *parent) : OffscreenQmlDialog(parent) { auto accountManager = DependencyManager::get(); // the login hasn't been dismissed yet if the user isn't logged in and is encouraged to login. @@ -51,24 +57,24 @@ void LoginDialog::showWithSelection() { auto tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); auto hmd = DependencyManager::get(); - static const QUrl url("dialogs/TabletLoginDialog.qml"); if (!qApp->isHMDMode()) { if (qApp->getLoginDialogPoppedUp()) { LoginDialog::show(); return; } else { - if (!tablet->isPathLoaded(url)) { - tablet->loadQMLSource(url); + if (!tablet->isPathLoaded(TABLET_LOGIN_DIALOG_URL)) { + tablet->loadQMLSource(TABLET_LOGIN_DIALOG_URL); } } } else { - //if (qApp->getLoginDialogPoppedUp()) { - // // pop up those overlay things. - // return; - //} else { - // tablet->initialScreen(url); - //} + if (qApp->getLoginDialogPoppedUp()) { + // pop up those overlay things. + createLoginDialogOverlay(); + return; + } else { + tablet->initialScreen(TABLET_LOGIN_DIALOG_URL); + } } if (!hmd->getShouldShowTablet()) { @@ -252,6 +258,24 @@ bool LoginDialog::getLoginDialogPoppedUp() const { return qApp->getLoginDialogPoppedUp(); } +void LoginDialog::createLoginDialogOverlay() { + Overlays& overlays = qApp->getOverlays(); + auto avatarManager = DependencyManager::get(); + auto myAvatar = avatarManager->getMyAvatar(); + + QVariantMap overlayProperties { + { "name", "" }, + { "visible", true }, + { "grabbable", false }, + { "ignoreRayIntersection", false }, + { "url", OVERLAY_LOGIN_DIALOG_URL }, + { "dimensions", myAvatar->getSessionUUID().toString() }, + {} + }; + + overlays.addOverlay("web3d", overlayProperties); +} + QString errorStringFromAPIObject(const QJsonValue& apiObject) { if (apiObject.isArray()) { return apiObject.toArray()[0].toString(); diff --git a/interface/src/ui/LoginDialog.h b/interface/src/ui/LoginDialog.h index df7bf69172..dbc4dfc759 100644 --- a/interface/src/ui/LoginDialog.h +++ b/interface/src/ui/LoginDialog.h @@ -18,6 +18,7 @@ #include class QNetworkReply; +class Web3DOverlay; class LoginDialog : public OffscreenQmlDialog { Q_OBJECT @@ -76,9 +77,15 @@ protected slots: Q_INVOKABLE bool getLoginDialogPoppedUp() const; private: + // for HMD mode on pop up. + static void createLoginDialogOverlay(); + bool getIsLogIn() const { return _isLogIn; } void setIsLogIn(const bool isLogIn) { _isLogIn = isLogIn; } + bool _isLogIn { false }; + + Web3DOverlay _loginDialogOverlay; }; #endif // hifi_LoginDialog_h