From 482922d98673a4f73558c14e168321d5222df336 Mon Sep 17 00:00:00 2001 From: Kasen IO Date: Tue, 4 Aug 2020 01:28:19 -0400 Subject: [PATCH 01/15] First pass at making login dialog more clear. --- .../qml/LoginDialog/LinkAccountBody.qml | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 6f437bb991..ec3f0d263e 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -45,6 +45,7 @@ Item { property bool lostFocus: false readonly property bool loginDialogPoppedUp: loginDialog.getLoginDialogPoppedUp() + // If not logging into domain, then we must be logging into the metaverse... readonly property bool isLoggingInToDomain: loginDialog.getDomainLoginRequested() readonly property string domainAuthProvider: loginDialog.getDomainLoginAuthProvider() @@ -105,8 +106,9 @@ Item { loginErrorMessage.wrapMode = Text.WordWrap; errorContainer.height = (loginErrorMessageTextMetrics.width / displayNameField.width) * loginErrorMessageTextMetrics.height; } + loginDialogText.text = (!isLoggingInToDomain) ? "Log In to Metaverse" : "Log In to Domain"; loginButton.text = (!linkAccountBody.linkSteam && !linkAccountBody.linkOculus) ? "Log In" : "Link Account"; - loginButton.text = (!isLoggingInToDomain) ? "Log In" : "Log In to Domain"; + loginButton.text = (!isLoggingInToDomain) ? "Log In to Metaverse" : "Log In to Domain"; loginButton.color = hifi.buttons.blue; displayNameField.placeholderText = "Display Name (optional)"; var savedDisplayName = Settings.getValue("Avatar/displayName", ""); @@ -140,6 +142,21 @@ Item { visible: false; anchors.fill: parent; } + + Text { + id: loginDialogText + text: qsTr("Log In") + anchors { + left: parent.left + } + lineHeight: 1 + color: "white" + font.family: linkAccountBody.fontFamily + font.pixelSize: linkAccountBody.textFieldFontSize + font.bold: linkAccountBody.fontBold + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + } Item { id: loginContainer @@ -626,6 +643,24 @@ Item { root.tryDestroy(); } } + + Text { + id: loginSkipTipText + text: qsTr("Not all domains require you to have a metaverse account. \n Some domains have their own login dialogs.") + visible: !linkAccountBody.isLoggingInToDomain + anchors { + top: dismissButton.bottom + topMargin: hifi.dimensions.contentSpacing.y + left: parent.left + } + lineHeight: 1 + color: "white" + font.family: linkAccountBody.fontFamily + font.pixelSize: linkAccountBody.textFieldFontSize + font.bold: linkAccountBody.fontBold + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + } } } From 09f2153057777e1f5ff2740018cfb70297f6bf2f Mon Sep 17 00:00:00 2001 From: Kasen IO Date: Tue, 4 Aug 2020 15:48:10 -0400 Subject: [PATCH 02/15] Update login QML to display domain URL. --- interface/resources/qml/LoginDialog/LinkAccountBody.qml | 5 +++-- interface/resources/qml/LoginDialog/LoggingInBody.qml | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 8d86963578..643026c6ff 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -95,7 +95,7 @@ Item { } bodyLoader.setSource("LoggingInBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": linkAccountBody.withSteam, "withOculus": linkAccountBody.withOculus, "linkSteam": linkAccountBody.linkSteam, "linkOculus": linkAccountBody.linkOculus, - "displayName":displayNameField.text, "isLoggingInToDomain": linkAccountBody.isLoggingInToDomain }); + "displayName":displayNameField.text, "isLoggingInToDomain": linkAccountBody.isLoggingInToDomain, "domainLoginDomain": linkAccountBody.domainLoginDomain }); } function init() { @@ -106,7 +106,8 @@ Item { loginErrorMessage.wrapMode = Text.WordWrap; errorContainer.height = (loginErrorMessageTextMetrics.width / displayNameField.width) * loginErrorMessageTextMetrics.height; } - loginDialogText.text = (!isLoggingInToDomain) ? "Log In to Metaverse" : "Log In to Domain"; + var domainLoginText = "Log In to Domain: " + domainLoginDomain; + loginDialogText.text = (!isLoggingInToDomain) ? "Log In to Metaverse" : domainLoginText; loginButton.text = (!linkAccountBody.linkSteam && !linkAccountBody.linkOculus) ? "Log In" : "Link Account"; loginButton.text = (!isLoggingInToDomain) ? "Log In to Metaverse" : "Log In to Domain"; loginButton.color = hifi.buttons.blue; diff --git a/interface/resources/qml/LoginDialog/LoggingInBody.qml b/interface/resources/qml/LoginDialog/LoggingInBody.qml index 796798a2de..757c8b7449 100644 --- a/interface/resources/qml/LoginDialog/LoggingInBody.qml +++ b/interface/resources/qml/LoginDialog/LoggingInBody.qml @@ -33,6 +33,7 @@ Item { property bool linkOculus: linkOculus property bool createOculus: createOculus property bool isLoggingInToDomain: isLoggingInToDomain + property string domainLoginDomain: domainLoginDomain property string displayName: "" readonly property bool loginDialogPoppedUp: loginDialog.getLoginDialogPoppedUp() @@ -109,7 +110,7 @@ Item { loggingInText.text = "Logging in to Oculus"; loggingInText.x = loggingInHeader.width/2 - loggingInTextMetrics.width/2 + loggingInGlyphTextMetrics.width/2; } else if (loggingInBody.isLoggingInToDomain) { - loggingInText.text = "Logging in to Domain"; + loggingInText.text = "Logging in to " + domainLoginDomain; loggingInText.anchors.centerIn = loggingInHeader; } else { loggingInText.text = "Logging in"; From ffce0a9d27365537ca7298f91aa75dd2c54b80ca Mon Sep 17 00:00:00 2001 From: Kasen IO Date: Tue, 4 Aug 2020 19:12:31 -0400 Subject: [PATCH 03/15] Update QML. --- .../qml/LoginDialog/LinkAccountBody.qml | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 643026c6ff..6b3fcb1788 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -143,21 +143,6 @@ Item { visible: false; anchors.fill: parent; } - - Text { - id: loginDialogText - text: qsTr("Log In") - anchors { - left: parent.left - } - lineHeight: 1 - color: "white" - font.family: linkAccountBody.fontFamily - font.pixelSize: linkAccountBody.textFieldFontSize - font.bold: linkAccountBody.fontBold - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignHCenter - } Item { id: loginContainer @@ -176,9 +161,9 @@ Item { width: parent.width height: loginErrorMessageTextMetrics.height anchors { - bottom: displayNameField.top; + bottom: loginDialogText.top; bottomMargin: hifi.dimensions.contentSpacing.y; - left: displayNameField.left; + left: loginDialogText.left; } TextMetrics { id: loginErrorMessageTextMetrics @@ -197,6 +182,23 @@ Item { visible: false } } + + Text { + id: loginDialogText + text: qsTr("Log In") + anchors { + top: parent.top + left: parent.left + topMargin: errorContainer.height + } + lineHeight: 1 + color: "white" + font.family: linkAccountBody.fontFamily + font.pixelSize: linkAccountBody.textFieldFontSize + font.bold: linkAccountBody.fontBold + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + } HifiControlsUit.TextField { id: displayNameField @@ -205,8 +207,8 @@ Item { font.pixelSize: linkAccountBody.textFieldFontSize styleRenderType: Text.QtRendering anchors { - top: parent.top - topMargin: errorContainer.height + top: loginDialogText.bottom + topMargin: 1.5 * hifi.dimensions.contentSpacing.y } placeholderText: "Display Name (optional)" activeFocusOnPress: true @@ -370,6 +372,7 @@ Item { labelFontFamily: linkAccountBody.fontFamily labelFontSize: 18; color: hifi.colors.white; + visible: !isLoggingInToDomain anchors { top: passwordField.bottom; topMargin: hifi.dimensions.contentSpacing.y; From 0e8f019b8af0bdcaca6eebd0cc6a1f0978c6c4bc Mon Sep 17 00:00:00 2001 From: Kasen IO Date: Tue, 4 Aug 2020 20:00:24 -0400 Subject: [PATCH 04/15] Further things kinda working. --- .../qml/LoginDialog/LinkAccountBody.qml | 1 + interface/src/Application.cpp | 37 +++++++++++++++---- interface/src/ui/LoginDialog.cpp | 4 +- .../networking/src/DomainAccountManager.h | 2 + 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 6b3fcb1788..4f46e392f0 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -651,6 +651,7 @@ Item { Text { id: loginSkipTipText text: qsTr("Not all domains require you to have a metaverse account. \n Some domains have their own login dialogs.") + wrapMode: Text.WordWrap visible: !linkAccountBody.isLoggingInToDomain anchors { top: dismissButton.bottom diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 2c6702fbfc..f2b708793f 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1355,7 +1355,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo auto domainAccountManager = DependencyManager::get(); connect(domainAccountManager.data(), &DomainAccountManager::authRequired, dialogsManager.data(), &DialogsManager::showDomainLoginDialog); - + + connect(domainAccountManager.data(), &DomainAccountManager::loginComplete, this, + &Application::updateWindowTitle); // ####### TODO: Connect any other signals from domainAccountManager. @@ -7079,20 +7081,24 @@ void Application::updateWindowTitle() const { auto nodeList = DependencyManager::get(); auto accountManager = DependencyManager::get(); + auto domainAccountManager = DependencyManager::get(); auto isInErrorState = nodeList->getDomainHandler().isInErrorState(); + bool isMetaverseLoggedIn = accountManager->isLoggedIn(); + bool isDomainLoggedIn = domainAccountManager->isLoggedIn(); + qCDebug(interfaceapp) << "Is Logged Into Domain:" << isDomainLoggedIn; QString buildVersion = " - Vircadia - " + (BuildInfo::BUILD_TYPE == BuildInfo::BuildType::Stable ? QString("Version") : QString("Build")) + " " + applicationVersion(); - // ####### TODO - QString loginStatus = accountManager->isLoggedIn() ? "" : " (NOT LOGGED IN)"; - QString connectionStatus = isInErrorState ? " (ERROR CONNECTING)" : nodeList->getDomainHandler().isConnected() ? "" : " (NOT CONNECTED)"; - QString username = accountManager->getAccountInfo().getUsername(); - setCrashAnnotation("sentry[user][username]", username.toStdString()); + QString metaverseUsername = accountManager->getAccountInfo().getUsername(); + // ###### TODO + // QString domainUsername = domainAccountManager->getUsername(); + + setCrashAnnotation("sentry[user][metaverseUsername]", metaverseUsername.toStdString()); QString currentPlaceName; if (isServerlessMode()) { @@ -7108,8 +7114,23 @@ void Application::updateWindowTitle() const { } } - QString title = QString() + (!username.isEmpty() ? username + " @ " : QString()) - + currentPlaceName + connectionStatus + loginStatus + buildVersion; + QString metaverseDetails; + if (isMetaverseLoggedIn) { + metaverseDetails = "Metaverse: Logged in as " + metaverseUsername; + } else { + metaverseDetails = "Metaverse: Not Logged In"; + } + + QString domainDetails; + if (isDomainLoggedIn) { + // domainDetails = "Domain: Logged in as " + domainUsername; + domainDetails = "Domain: Logged In"; + } else { + domainDetails = "Domain: Not Logged In"; + } + + QString title = QString() + currentPlaceName + connectionStatus + " (" + metaverseDetails + " - " + domainDetails + ")" + + buildVersion; #ifndef WIN32 // crashes with vs2013/win32 diff --git a/interface/src/ui/LoginDialog.cpp b/interface/src/ui/LoginDialog.cpp index c7597c5658..4f8a3ca2bc 100644 --- a/interface/src/ui/LoginDialog.cpp +++ b/interface/src/ui/LoginDialog.cpp @@ -99,11 +99,11 @@ void LoginDialog::toggleAction() { if (accountManager->isLoggedIn()) { // change the menu item to logout - loginAction->setText("Logout " + accountManager->getAccountInfo().getUsername()); + loginAction->setText("Metaverse: Logout " + accountManager->getAccountInfo().getUsername()); connection = connect(loginAction, &QAction::triggered, accountManager.data(), &AccountManager::logout); } else { // change the menu item to login - loginAction->setText("Log In / Sign Up"); + loginAction->setText("Metaverse: Log In / Sign Up"); connection = connect(loginAction, &QAction::triggered, [] { // if not in login state, show. if (!qApp->getLoginDialogPoppedUp()) { diff --git a/libraries/networking/src/DomainAccountManager.h b/libraries/networking/src/DomainAccountManager.h index 0388ba1f5a..1590e4d467 100644 --- a/libraries/networking/src/DomainAccountManager.h +++ b/libraries/networking/src/DomainAccountManager.h @@ -30,6 +30,8 @@ public: QString getAccessToken() { return _access_token; } QString getRefreshToken() { return _refresh_token; } + bool isLoggedIn() { return hasValidAccessToken(); } + Q_INVOKABLE bool checkAndSignalForAccessToken(); public slots: From 352a3f4ab1250814eb0970b886796d8f50a164ca Mon Sep 17 00:00:00 2001 From: Kasen IO Date: Tue, 4 Aug 2020 21:17:57 -0400 Subject: [PATCH 05/15] Fix domain vs metaverse logins slightly. --- interface/src/Application.cpp | 3 ++- interface/src/ui/DialogsManager.cpp | 3 +++ interface/src/ui/DialogsManager.h | 1 + interface/src/ui/LoginDialog.cpp | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index f2b708793f..4a7c788d30 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -7123,13 +7123,14 @@ void Application::updateWindowTitle() const { QString domainDetails; if (isDomainLoggedIn) { + // ###### TODO // domainDetails = "Domain: Logged in as " + domainUsername; domainDetails = "Domain: Logged In"; } else { domainDetails = "Domain: Not Logged In"; } - QString title = QString() + currentPlaceName + connectionStatus + " (" + metaverseDetails + " - " + domainDetails + ")" + QString title = QString() + currentPlaceName + connectionStatus + " (" + metaverseDetails + ") (" + domainDetails + ")" + buildVersion; #ifndef WIN32 diff --git a/interface/src/ui/DialogsManager.cpp b/interface/src/ui/DialogsManager.cpp index 6e807c7b9f..3aaed2d3ec 100644 --- a/interface/src/ui/DialogsManager.cpp +++ b/interface/src/ui/DialogsManager.cpp @@ -110,6 +110,9 @@ void DialogsManager::setDomainConnectionFailureVisibility(bool visible) { } } +void DialogsManager::requestMetaverseLogin() { + DialogsManager::setDomainLogin(false); +} void DialogsManager::setDomainLogin(bool isDomainLogin, const QString& domain) { _isDomainLogin = isDomainLogin; diff --git a/interface/src/ui/DialogsManager.h b/interface/src/ui/DialogsManager.h index fa5c589fb4..07d9de82b0 100644 --- a/interface/src/ui/DialogsManager.h +++ b/interface/src/ui/DialogsManager.h @@ -41,6 +41,7 @@ public: QPointer getTestingDialog() const { return _testingDialog; } void emitAddressBarShown(bool visible) { emit addressBarShown(visible); } void setAddressBarVisible(bool addressBarVisible); + void requestMetaverseLogin(); bool getIsDomainLogin() { return _isDomainLogin; } QString getDomainLoginDomain() { return _domainLoginDomain; } diff --git a/interface/src/ui/LoginDialog.cpp b/interface/src/ui/LoginDialog.cpp index 4f8a3ca2bc..46e31070b8 100644 --- a/interface/src/ui/LoginDialog.cpp +++ b/interface/src/ui/LoginDialog.cpp @@ -107,6 +107,8 @@ void LoginDialog::toggleAction() { connection = connect(loginAction, &QAction::triggered, [] { // if not in login state, show. if (!qApp->getLoginDialogPoppedUp()) { + auto dialogsManager = DependencyManager::get(); + dialogsManager->requestMetaverseLogin(); LoginDialog::showWithSelection(); } }); From 8f55e13aa2faad823b5f8a91b36c15a8cc207754 Mon Sep 17 00:00:00 2001 From: Kasen IO Date: Tue, 4 Aug 2020 23:14:40 -0400 Subject: [PATCH 06/15] Disable login screen for all first-time users. --- interface/src/Application.cpp | 2 +- interface/src/Application.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 4a7c788d30..761b2ae717 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1584,7 +1584,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo // 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); - if (index != -1) { + if (index != -1 || _disableLoginScreen) { resumeAfterLoginDialogActionTaken(); return; } diff --git a/interface/src/Application.h b/interface/src/Application.h index 3d4e6873a8..f42696cda0 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -733,6 +733,7 @@ private: GraphicsEngine _graphicsEngine; void updateRenderArgs(float deltaTime); + bool _disableLoginScreen { true }; Overlays _overlays; ApplicationOverlay _applicationOverlay; From d81ec3a4b8256b4160ada2c4dd84d62021e53672 Mon Sep 17 00:00:00 2001 From: Kasen IO Date: Tue, 4 Aug 2020 23:46:39 -0400 Subject: [PATCH 07/15] Domain login display working correctly. --- .../qml/LoginDialog/LinkAccountBody.qml | 65 +++++++++---------- 1 file changed, 29 insertions(+), 36 deletions(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 4f46e392f0..6ba8c1435c 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -106,15 +106,15 @@ Item { loginErrorMessage.wrapMode = Text.WordWrap; errorContainer.height = (loginErrorMessageTextMetrics.width / displayNameField.width) * loginErrorMessageTextMetrics.height; } - var domainLoginText = "Log In to Domain: " + domainLoginDomain; - loginDialogText.text = (!isLoggingInToDomain) ? "Log In to Metaverse" : domainLoginText; + var domainLoginText = "Log In to Domain\n" + domainLoginDomain; + loginDialogText.text = (!isLoggingInToDomain) ? "Log In to Metaverse (Not Required)" : domainLoginText; loginButton.text = (!linkAccountBody.linkSteam && !linkAccountBody.linkOculus) ? "Log In" : "Link Account"; loginButton.text = (!isLoggingInToDomain) ? "Log In to Metaverse" : "Log In to Domain"; loginButton.color = hifi.buttons.blue; displayNameField.placeholderText = "Display Name (optional)"; var savedDisplayName = Settings.getValue("Avatar/displayName", ""); displayNameField.text = savedDisplayName; - emailField.placeholderText = "Username or Email"; + emailField.placeholderText = (!isLoggingInToDomain) ? "Username or Email" : "Username"; if (!isLoggingInToDomain) { var savedUsername = Settings.getValue("keepMeLoggedIn/savedUsername", ""); emailField.text = keepMeLoggedInCheckbox.checked ? savedUsername === "Unknown user" ? "" : savedUsername : ""; @@ -161,9 +161,9 @@ Item { width: parent.width height: loginErrorMessageTextMetrics.height anchors { - bottom: loginDialogText.top; + bottom: loginDialogTextContainer.top; bottomMargin: hifi.dimensions.contentSpacing.y; - left: loginDialogText.left; + left: loginDialogTextContainer.left; } TextMetrics { id: loginErrorMessageTextMetrics @@ -183,21 +183,33 @@ Item { } } - Text { - id: loginDialogText - text: qsTr("Log In") + Item { + id: loginDialogTextContainer + height: 56 anchors { top: parent.top left: parent.left - topMargin: errorContainer.height + right: parent.right; + topMargin: 1.5 * hifi.dimensions.contentSpacing.y + // horizontalCenter: mainContainer.horizontalCenter + } + + Text { + id: loginDialogText + text: qsTr("Log In") + lineHeight: 1 + color: "white" + anchors { + top: parent.top + left: parent.left + right: parent.right + } + font.family: linkAccountBody.fontFamily + font.pixelSize: 24 + font.bold: linkAccountBody.fontBold + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter } - lineHeight: 1 - color: "white" - font.family: linkAccountBody.fontFamily - font.pixelSize: linkAccountBody.textFieldFontSize - font.bold: linkAccountBody.fontBold - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignHCenter } HifiControlsUit.TextField { @@ -207,7 +219,7 @@ Item { font.pixelSize: linkAccountBody.textFieldFontSize styleRenderType: Text.QtRendering anchors { - top: loginDialogText.bottom + top: loginDialogTextContainer.bottom topMargin: 1.5 * hifi.dimensions.contentSpacing.y } placeholderText: "Display Name (optional)" @@ -647,25 +659,6 @@ Item { root.tryDestroy(); } } - - Text { - id: loginSkipTipText - text: qsTr("Not all domains require you to have a metaverse account. \n Some domains have their own login dialogs.") - wrapMode: Text.WordWrap - visible: !linkAccountBody.isLoggingInToDomain - anchors { - top: dismissButton.bottom - topMargin: hifi.dimensions.contentSpacing.y - left: parent.left - } - lineHeight: 1 - color: "white" - font.family: linkAccountBody.fontFamily - font.pixelSize: linkAccountBody.textFieldFontSize - font.bold: linkAccountBody.fontBold - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignHCenter - } } } From 2881f1147fcf77960d5658eb31e2235882de1856 Mon Sep 17 00:00:00 2001 From: Kasen IO Date: Wed, 5 Aug 2020 00:09:09 -0400 Subject: [PATCH 08/15] Metaverse login display working correctly. --- interface/resources/qml/LoginDialog/LinkAccountBody.qml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 6ba8c1435c..bba46e78c5 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -107,7 +107,7 @@ Item { errorContainer.height = (loginErrorMessageTextMetrics.width / displayNameField.width) * loginErrorMessageTextMetrics.height; } var domainLoginText = "Log In to Domain\n" + domainLoginDomain; - loginDialogText.text = (!isLoggingInToDomain) ? "Log In to Metaverse (Not Required)" : domainLoginText; + loginDialogText.text = (!isLoggingInToDomain) ? "Log In to Metaverse" : domainLoginText; loginButton.text = (!linkAccountBody.linkSteam && !linkAccountBody.linkOculus) ? "Log In" : "Link Account"; loginButton.text = (!isLoggingInToDomain) ? "Log In to Metaverse" : "Log In to Domain"; loginButton.color = hifi.buttons.blue; @@ -147,7 +147,7 @@ Item { Item { id: loginContainer width: displayNameField.width - height: errorContainer.height + displayNameField.height + emailField.height + passwordField.height + 5.5 * hifi.dimensions.contentSpacing.y + + height: errorContainer.height + loginDialogTextContainer.height + displayNameField.height + emailField.height + passwordField.height + 5.5 * hifi.dimensions.contentSpacing.y + keepMeLoggedInCheckbox.height + loginButton.height + cantAccessTextMetrics.height + continueButton.height anchors { top: parent.top @@ -469,7 +469,7 @@ Item { font.pixelSize: linkAccountBody.textFieldFontSize font.bold: linkAccountBody.fontBold - text: " Can't access your account?" + text: " Can't access your account?" verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter @@ -595,7 +595,7 @@ Item { leftMargin: hifi.dimensions.contentSpacing.x } - text: "Sign Up" + text: "Sign Up" linkColor: hifi.colors.blueAccent onLinkActivated: { From c42adc9e00dbec41338718c0ebd5172e8017eabd Mon Sep 17 00:00:00 2001 From: Kasen IO Date: Wed, 5 Aug 2020 00:14:27 -0400 Subject: [PATCH 09/15] Add menu items and triggers. --- interface/src/Menu.cpp | 11 +++++++++++ interface/src/ui/DialogsManager.cpp | 22 +++++++++++++++++++--- interface/src/ui/DialogsManager.h | 7 +++++-- interface/src/ui/LoginDialog.cpp | 2 +- 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 0ed5f67ea0..dbe60c4b7e 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -9,6 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +// For happ(ier) development of QML, use these two things: +// This forces QML files to be pulled from the source as you edit it: HIFI_USE_SOURCE_TREE_RESOURCES=1 +// Use this to live reload: DependencyManager::get()->clearCache(); + #include "Menu.h" #include #include @@ -84,6 +88,13 @@ Menu::Menu() { dialogsManager.data(), &DialogsManager::toggleLoginDialog); } + auto domainLogin = addActionToQMenuAndActionHash(fileMenu, "Domain: Log In"); + connect(domainLogin, &QAction::triggered, [] { + auto dialogsManager = DependencyManager::get(); + dialogsManager->requestDomainLoginState(); + dialogsManager->showDomainLoginDialog(); + }); + // File > Quit addActionToQMenuAndActionHash(fileMenu, MenuOption::Quit, Qt::CTRL | Qt::Key_Q, qApp, SLOT(quit()), QAction::QuitRole); diff --git a/interface/src/ui/DialogsManager.cpp b/interface/src/ui/DialogsManager.cpp index 3aaed2d3ec..01bf69178f 100644 --- a/interface/src/ui/DialogsManager.cpp +++ b/interface/src/ui/DialogsManager.cpp @@ -110,13 +110,29 @@ void DialogsManager::setDomainConnectionFailureVisibility(bool visible) { } } -void DialogsManager::requestMetaverseLogin() { - DialogsManager::setDomainLogin(false); +void DialogsManager::requestMetaverseLoginState() { + DialogsManager::setMetaverseLoginState(); +} + +void DialogsManager::requestDomainLoginState() { + DialogsManager::setDomainLoginState(); +} + +void DialogsManager::setMetaverseLoginState() { + // We're only turning off the domain login trigger but the actual domain auth URL is still saved. + // So we can continue the domain login if desired. + _isDomainLogin = false; +} + +void DialogsManager::setDomainLoginState() { + _isDomainLogin = true; } void DialogsManager::setDomainLogin(bool isDomainLogin, const QString& domain) { _isDomainLogin = isDomainLogin; - _domainLoginDomain = domain; + if (!domain.isEmpty()) { + _domainLoginDomain = domain; + } } void DialogsManager::toggleLoginDialog() { diff --git a/interface/src/ui/DialogsManager.h b/interface/src/ui/DialogsManager.h index 07d9de82b0..0f391d9758 100644 --- a/interface/src/ui/DialogsManager.h +++ b/interface/src/ui/DialogsManager.h @@ -41,7 +41,8 @@ public: QPointer getTestingDialog() const { return _testingDialog; } void emitAddressBarShown(bool visible) { emit addressBarShown(visible); } void setAddressBarVisible(bool addressBarVisible); - void requestMetaverseLogin(); + void requestMetaverseLoginState(); + void requestDomainLoginState(); bool getIsDomainLogin() { return _isDomainLogin; } QString getDomainLoginDomain() { return _domainLoginDomain; } @@ -53,7 +54,7 @@ public slots: void toggleLoginDialog(); void showLoginDialog(); void hideLoginDialog(); - void showDomainLoginDialog(const QString& domain); + void showDomainLoginDialog(const QString& domain = ""); void octreeStatsDetails(); void lodTools(); void hmdTools(bool showTools); @@ -89,6 +90,8 @@ private: bool _addressBarVisible { false }; void setDomainLogin(bool isDomainLogin, const QString& domain = ""); + void setMetaverseLoginState(); + void setDomainLoginState(); bool _isDomainLogin { false }; QString _domainLoginDomain; }; diff --git a/interface/src/ui/LoginDialog.cpp b/interface/src/ui/LoginDialog.cpp index 46e31070b8..71ae1eec83 100644 --- a/interface/src/ui/LoginDialog.cpp +++ b/interface/src/ui/LoginDialog.cpp @@ -108,7 +108,7 @@ void LoginDialog::toggleAction() { // if not in login state, show. if (!qApp->getLoginDialogPoppedUp()) { auto dialogsManager = DependencyManager::get(); - dialogsManager->requestMetaverseLogin(); + dialogsManager->requestMetaverseLoginState(); LoginDialog::showWithSelection(); } }); From 448cdcb31fd480ae521b92fcbb6791c6b9c79f16 Mon Sep 17 00:00:00 2001 From: Kasen IO Date: Wed, 5 Aug 2020 00:23:55 -0400 Subject: [PATCH 10/15] Update domain's describe-settings for clarity. --- domain-server/resources/describe-settings.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/domain-server/resources/describe-settings.json b/domain-server/resources/describe-settings.json index 8e57a9b683..d658e5d8ce 100644 --- a/domain-server/resources/describe-settings.json +++ b/domain-server/resources/describe-settings.json @@ -414,6 +414,7 @@ "name": "group_permissions", "type": "table", "caption": "Permissions for Users in Groups", + "help": "For groups that are supplied through OAuth, you will need to denote them by putting an \"@\" symbol in front of each item. e.g. \"@silver\"", "categorize_by_key": "permissions_id", "can_add_new_categories": true, "can_add_new_rows": false, @@ -542,6 +543,7 @@ "name": "group_forbiddens", "type": "table", "caption": "Permissions Denied to Users in Groups", + "help": "For groups that are supplied through OAuth, you will need to denote them by putting an \"@\" symbol in front of each item. e.g. \"@silver\"", "categorize_by_key": "permissions_id", "can_add_new_categories": true, "can_add_new_rows": false, From 6b0fc8fd66ec03af39fd2945e78df9beab9c0509 Mon Sep 17 00:00:00 2001 From: Kasen IO Date: Wed, 5 Aug 2020 02:18:01 -0400 Subject: [PATCH 11/15] Titlebar now responds correctly to domain logged in state. --- interface/src/Application.cpp | 9 +++---- .../networking/src/DomainAccountManager.cpp | 27 ++++++++++--------- .../networking/src/DomainAccountManager.h | 4 ++- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 761b2ae717..eec7d8a5f7 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -7085,7 +7085,7 @@ void Application::updateWindowTitle() const { auto isInErrorState = nodeList->getDomainHandler().isInErrorState(); bool isMetaverseLoggedIn = accountManager->isLoggedIn(); bool isDomainLoggedIn = domainAccountManager->isLoggedIn(); - qCDebug(interfaceapp) << "Is Logged Into Domain:" << isDomainLoggedIn; + QString authedDomain = domainAccountManager->getAuthedDomain(); QString buildVersion = " - Vircadia - " + (BuildInfo::BUILD_TYPE == BuildInfo::BuildType::Stable ? QString("Version") : QString("Build")) @@ -7095,8 +7095,7 @@ void Application::updateWindowTitle() const { nodeList->getDomainHandler().isConnected() ? "" : " (NOT CONNECTED)"; QString metaverseUsername = accountManager->getAccountInfo().getUsername(); - // ###### TODO - // QString domainUsername = domainAccountManager->getUsername(); + QString domainUsername = domainAccountManager->getUsername(); setCrashAnnotation("sentry[user][metaverseUsername]", metaverseUsername.toStdString()); @@ -7122,10 +7121,10 @@ void Application::updateWindowTitle() const { } QString domainDetails; - if (isDomainLoggedIn) { + if (currentPlaceName == authedDomain && isDomainLoggedIn) { // ###### TODO // domainDetails = "Domain: Logged in as " + domainUsername; - domainDetails = "Domain: Logged In"; + domainDetails = "Domain: Logged in as " + domainUsername; } else { domainDetails = "Domain: Not Logged In"; } diff --git a/libraries/networking/src/DomainAccountManager.cpp b/libraries/networking/src/DomainAccountManager.cpp index 6bb868df61..19c16178e2 100644 --- a/libraries/networking/src/DomainAccountManager.cpp +++ b/libraries/networking/src/DomainAccountManager.cpp @@ -18,7 +18,9 @@ #include #include +#include +#include "NodeList.h" #include "NetworkingConstants.h" #include "NetworkLogging.h" #include "NetworkAccessManager.h" @@ -101,6 +103,8 @@ void DomainAccountManager::requestAccessTokenFinished() { // miniOrange plugin provides no scope. if (rootObject.contains("access_token")) { // Success. + auto nodeList = DependencyManager::get(); + _domain_name = nodeList->getDomainHandler().getHostname(); QUrl rootURL = requestReply->url(); rootURL.setPath(""); setTokensFromJSON(rootObject, rootURL); @@ -133,10 +137,12 @@ bool DomainAccountManager::accessTokenIsExpired() { bool DomainAccountManager::hasValidAccessToken() { - QString currentDomainAccessToken = domainAccessToken.get(); - - if (currentDomainAccessToken.isEmpty() || accessTokenIsExpired()) { + // ###### TODO: wire this up to actually retrieve a token (based on session or storage) and confirm that it is in fact valid and relevant to the current domain. + // QString currentDomainAccessToken = domainAccessToken.get(); + QString currentDomainAccessToken = _access_token; + // if (currentDomainAccessToken.isEmpty() || accessTokenIsExpired()) { + if (currentDomainAccessToken.isEmpty()) { if (VERBOSE_HTTP_REQUEST_DEBUGGING) { qCDebug(networking) << "An access token is required for requests to" << qPrintable(_authURL.toString()); @@ -153,23 +159,20 @@ bool DomainAccountManager::hasValidAccessToken() { return true; } - } void DomainAccountManager::setTokensFromJSON(const QJsonObject& jsonObject, const QUrl& url) { _access_token = jsonObject["access_token"].toString(); _refresh_token = jsonObject["refresh_token"].toString(); - // ####### TODO: Enable and use these. // ####### TODO: Protect these per AccountManager? // ######: TODO: clientID needed? - /* - qCDebug(networking) << "Storing a domain account with access-token for" << qPrintable(url.toString()); - domainAccessToken.set(jsonObject["access_token"].toString()); - domainAccessRefreshToken.set(jsonObject["refresh_token"].toString()); - domainAccessTokenExpiresIn.set(QDateTime::currentMSecsSinceEpoch() + (jsonObject["expires_in"].toDouble() * 1000)); - domainAccessTokenType.set(jsonObject["token_type"].toString()); - */ + + // qCDebug(networking) << "Storing a domain account with access-token for" << qPrintable(url.toString()); + // domainAccessToken.set(jsonObject["access_token"].toString()); + // domainAccessRefreshToken.set(jsonObject["refresh_token"].toString()); + // domainAccessTokenExpiresIn.set(QDateTime::currentMSecsSinceEpoch() + (jsonObject["expires_in"].toDouble() * 1000)); + // domainAccessTokenType.set(jsonObject["token_type"].toString()); } bool DomainAccountManager::checkAndSignalForAccessToken() { diff --git a/libraries/networking/src/DomainAccountManager.h b/libraries/networking/src/DomainAccountManager.h index 1590e4d467..c8bc5e912c 100644 --- a/libraries/networking/src/DomainAccountManager.h +++ b/libraries/networking/src/DomainAccountManager.h @@ -29,8 +29,9 @@ public: QString getUsername() { return _username; } QString getAccessToken() { return _access_token; } QString getRefreshToken() { return _refresh_token; } + QString getAuthedDomain() { return _domain_name; } - bool isLoggedIn() { return hasValidAccessToken(); } + bool isLoggedIn() { return !_authURL.isEmpty() && hasValidAccessToken(); } Q_INVOKABLE bool checkAndSignalForAccessToken(); @@ -59,6 +60,7 @@ private: QString _username; // ####### TODO: Store elsewhere? QString _access_token; // ####... "" QString _refresh_token; // ####... "" + QString _domain_name; // }; #endif // hifi_DomainAccountManager_h From 658e14be25ad41523677ffedef2cf3fb03678732 Mon Sep 17 00:00:00 2001 From: Kasen IO Date: Wed, 5 Aug 2020 02:30:30 -0400 Subject: [PATCH 12/15] Remove unused aliases. --- interface/src/Menu.cpp | 2 +- interface/src/ui/DialogsManager.cpp | 10 +--------- interface/src/ui/DialogsManager.h | 6 ++---- interface/src/ui/LoginDialog.cpp | 2 +- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index dbe60c4b7e..f40082c1e7 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -91,7 +91,7 @@ Menu::Menu() { auto domainLogin = addActionToQMenuAndActionHash(fileMenu, "Domain: Log In"); connect(domainLogin, &QAction::triggered, [] { auto dialogsManager = DependencyManager::get(); - dialogsManager->requestDomainLoginState(); + dialogsManager->setDomainLoginState(); dialogsManager->showDomainLoginDialog(); }); diff --git a/interface/src/ui/DialogsManager.cpp b/interface/src/ui/DialogsManager.cpp index 01bf69178f..ae4f43d6fa 100644 --- a/interface/src/ui/DialogsManager.cpp +++ b/interface/src/ui/DialogsManager.cpp @@ -110,16 +110,8 @@ void DialogsManager::setDomainConnectionFailureVisibility(bool visible) { } } -void DialogsManager::requestMetaverseLoginState() { - DialogsManager::setMetaverseLoginState(); -} - -void DialogsManager::requestDomainLoginState() { - DialogsManager::setDomainLoginState(); -} - void DialogsManager::setMetaverseLoginState() { - // We're only turning off the domain login trigger but the actual domain auth URL is still saved. + // We're only turning off the domain login trigger but the actual domain auth URL is still saved. // So we can continue the domain login if desired. _isDomainLogin = false; } diff --git a/interface/src/ui/DialogsManager.h b/interface/src/ui/DialogsManager.h index 0f391d9758..864174296e 100644 --- a/interface/src/ui/DialogsManager.h +++ b/interface/src/ui/DialogsManager.h @@ -41,8 +41,8 @@ public: QPointer getTestingDialog() const { return _testingDialog; } void emitAddressBarShown(bool visible) { emit addressBarShown(visible); } void setAddressBarVisible(bool addressBarVisible); - void requestMetaverseLoginState(); - void requestDomainLoginState(); + void setMetaverseLoginState(); + void setDomainLoginState(); bool getIsDomainLogin() { return _isDomainLogin; } QString getDomainLoginDomain() { return _domainLoginDomain; } @@ -90,8 +90,6 @@ private: bool _addressBarVisible { false }; void setDomainLogin(bool isDomainLogin, const QString& domain = ""); - void setMetaverseLoginState(); - void setDomainLoginState(); bool _isDomainLogin { false }; QString _domainLoginDomain; }; diff --git a/interface/src/ui/LoginDialog.cpp b/interface/src/ui/LoginDialog.cpp index 71ae1eec83..b45a62ae3a 100644 --- a/interface/src/ui/LoginDialog.cpp +++ b/interface/src/ui/LoginDialog.cpp @@ -108,7 +108,7 @@ void LoginDialog::toggleAction() { // if not in login state, show. if (!qApp->getLoginDialogPoppedUp()) { auto dialogsManager = DependencyManager::get(); - dialogsManager->requestMetaverseLoginState(); + dialogsManager->setMetaverseLoginState(); LoginDialog::showWithSelection(); } }); From 4d3ca2fdc5b74cb94f521a8ca410204fad1d0acd Mon Sep 17 00:00:00 2001 From: kasenvr <52365539+kasenvr@users.noreply.github.com> Date: Wed, 5 Aug 2020 02:31:10 -0400 Subject: [PATCH 13/15] Apply suggestions from code review Co-authored-by: David Rowe --- domain-server/resources/describe-settings.json | 4 ++-- interface/resources/qml/LoginDialog/LinkAccountBody.qml | 4 ++-- interface/src/Menu.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/domain-server/resources/describe-settings.json b/domain-server/resources/describe-settings.json index d658e5d8ce..9c220b740e 100644 --- a/domain-server/resources/describe-settings.json +++ b/domain-server/resources/describe-settings.json @@ -414,7 +414,7 @@ "name": "group_permissions", "type": "table", "caption": "Permissions for Users in Groups", - "help": "For groups that are supplied through OAuth, you will need to denote them by putting an \"@\" symbol in front of each item. e.g. \"@silver\"", + "help": "For groups that are provided from WordPress you need to denote them by putting an \"@\" symbol in front of each item, e.g., \"@silver\"". "categorize_by_key": "permissions_id", "can_add_new_categories": true, "can_add_new_rows": false, @@ -543,7 +543,7 @@ "name": "group_forbiddens", "type": "table", "caption": "Permissions Denied to Users in Groups", - "help": "For groups that are supplied through OAuth, you will need to denote them by putting an \"@\" symbol in front of each item. e.g. \"@silver\"", + "help": "For groups that are provided from WordPress you need to denote them by putting an \"@\" symbol in front of each item, e.g., \"@silver\"". "categorize_by_key": "permissions_id", "can_add_new_categories": true, "can_add_new_rows": false, diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index bba46e78c5..04e980f0bb 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -189,7 +189,7 @@ Item { anchors { top: parent.top left: parent.left - right: parent.right; + right: parent.right topMargin: 1.5 * hifi.dimensions.contentSpacing.y // horizontalCenter: mainContainer.horizontalCenter } @@ -595,7 +595,7 @@ Item { leftMargin: hifi.dimensions.contentSpacing.x } - text: "Sign Up" + text: "Sign Up" linkColor: hifi.colors.blueAccent onLinkActivated: { diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index f40082c1e7..64cdf98239 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -10,7 +10,7 @@ // // For happ(ier) development of QML, use these two things: -// This forces QML files to be pulled from the source as you edit it: HIFI_USE_SOURCE_TREE_RESOURCES=1 +// This forces QML files to be pulled from the source as you edit it: set environment variable HIFI_USE_SOURCE_TREE_RESOURCES=1 // Use this to live reload: DependencyManager::get()->clearCache(); #include "Menu.h" From b948f24a56d288dbcf1ae28e3507199feb7386c9 Mon Sep 17 00:00:00 2001 From: kasenvr <52365539+kasenvr@users.noreply.github.com> Date: Wed, 5 Aug 2020 02:31:26 -0400 Subject: [PATCH 14/15] Apply suggestions from code review Co-authored-by: David Rowe --- interface/resources/qml/LoginDialog/LinkAccountBody.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 04e980f0bb..9ce80c0cb8 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -469,7 +469,7 @@ Item { font.pixelSize: linkAccountBody.textFieldFontSize font.bold: linkAccountBody.fontBold - text: " Can't access your account?" + text: " Can't access your account?" verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter From d89cf867d2a2e63600fdf4c89a89d52f257589d1 Mon Sep 17 00:00:00 2001 From: Kasen IO Date: Wed, 5 Aug 2020 02:41:39 -0400 Subject: [PATCH 15/15] Center error text correctly. --- .../resources/qml/LoginDialog/LinkAccountBody.qml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 9ce80c0cb8..694fd6158f 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -161,9 +161,10 @@ Item { width: parent.width height: loginErrorMessageTextMetrics.height anchors { - bottom: loginDialogTextContainer.top; - bottomMargin: hifi.dimensions.contentSpacing.y; - left: loginDialogTextContainer.left; + bottom: loginDialogTextContainer.top + bottomMargin: hifi.dimensions.contentSpacing.y + left: loginDialogTextContainer.left + right: loginDialogTextContainer.right } TextMetrics { id: loginErrorMessageTextMetrics @@ -176,6 +177,11 @@ Item { font.family: linkAccountBody.fontFamily font.pixelSize: linkAccountBody.textFieldFontSize font.bold: linkAccountBody.fontBold + anchors { + top: parent.top + left: parent.left + right: parent.right + } verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter text: "" @@ -191,7 +197,6 @@ Item { left: parent.left right: parent.right topMargin: 1.5 * hifi.dimensions.contentSpacing.y - // horizontalCenter: mainContainer.horizontalCenter } Text {