adding overlay

This commit is contained in:
Wayne Chen 2018-10-30 10:19:11 -07:00
parent af04630642
commit 54fe9eec87
2 changed files with 40 additions and 9 deletions

View file

@ -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<AccountManager>();
// 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<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
auto hmd = DependencyManager::get<HMDScriptingInterface>();
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<AvatarManager>();
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();

View file

@ -18,6 +18,7 @@
#include <SettingHandle.h>
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