From 1bea6c9ea38f223d730f409542bb965d43858b93 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 5 Sep 2018 10:38:12 -0700 Subject: [PATCH 01/34] if not already logged in, show login dialog at launch-time rather than connect-to-domain-time --- interface/src/Application.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 67dbcf355f..a2f5033622 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2299,6 +2299,19 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo connect(&AndroidHelper::instance(), &AndroidHelper::enterForeground, this, &Application::enterForeground); AndroidHelper::instance().notifyLoadComplete(); #endif + + static int CHECK_LOGIN_TIMER = 3000; + QTimer* checkLoginTimer = new QTimer(this); + checkLoginTimer->setInterval(CHECK_LOGIN_TIMER); + checkLoginTimer->setSingleShot(true); + connect(checkLoginTimer, &QTimer::timeout, this, []() { + auto accountManager = DependencyManager::get(); + auto dialogsManager = DependencyManager::get(); + if (!accountManager->isLoggedIn()) { + dialogsManager->showLoginDialog(); + } + }); + checkLoginTimer->start(); } void Application::updateVerboseLogging() { From dcf2e00bd7b38482fde9d69bf41d42ccfc72fd1f Mon Sep 17 00:00:00 2001 From: Alexia Mandeville Date: Wed, 5 Sep 2018 14:55:12 -0700 Subject: [PATCH 02/34] Adding placeholder text --- interface/resources/qml/LoginDialog/LinkAccountBody.qml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 4c6e5f6fce..55d157fdd8 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -124,6 +124,7 @@ Item { width: parent.width focus: true label: "Username or Email" + placeholderText: "Username or Email" activeFocusOnPress: true ShortcutText { @@ -151,8 +152,8 @@ Item { TextField { id: passwordField width: parent.width - label: "Password" + placeholderText: "Password" echoMode: showPassword.checked ? TextInput.Normal : TextInput.Password activeFocusOnPress: true From 1e697ad45f139d281012d87d4099d90b80f32625 Mon Sep 17 00:00:00 2001 From: Alexia Mandeville Date: Wed, 5 Sep 2018 16:25:18 -0700 Subject: [PATCH 03/34] Removing labels, adding flavor text, moving links --- .../qml/LoginDialog/LinkAccountBody.qml | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 55d157fdd8..f6ad5385c0 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -87,6 +87,21 @@ Item { height: 48 } + FlavorText { + id: flavorTextContainer + anchors { + top: parent.top + margins: 0 + topMargin: hifi.dimensions.contentSpacing.y + } + + text: qsTr("Sign in to High Fidelity to make friends, get HFC, and buy interesting things on the Marketplace!") + wrapMode: Text.WordWrap + lineHeight: 2 + lineHeightMode: Text.ProportionalHeight + horizontalAlignment: Text.AlignHCenter + } + ShortcutText { id: mainTextContainer anchors { @@ -97,7 +112,6 @@ Item { } visible: false - text: qsTr("Username or password incorrect.") wrapMode: Text.WordWrap color: hifi.colors.redAccent @@ -123,15 +137,14 @@ Item { text: Settings.getValue("wallet/savedUsername", ""); width: parent.width focus: true - label: "Username or Email" placeholderText: "Username or Email" activeFocusOnPress: true ShortcutText { z: 10 anchors { - left: usernameField.left - top: usernameField.top + left: usernameField.right + top: usernameField.bottom leftMargin: usernameField.textFieldLabel.contentWidth + 10 topMargin: -19 } @@ -152,7 +165,6 @@ Item { TextField { id: passwordField width: parent.width - label: "Password" placeholderText: "Password" echoMode: showPassword.checked ? TextInput.Normal : TextInput.Password activeFocusOnPress: true @@ -160,8 +172,8 @@ Item { ShortcutText { z: 10 anchors { - left: passwordField.left - top: passwordField.top + left: passwordField.right + top: passwordField.bottom leftMargin: passwordField.textFieldLabel.contentWidth + 10 topMargin: -19 } From 901de120a694fef83871f48b5d07292da50dd88d Mon Sep 17 00:00:00 2001 From: Alexia Mandeville Date: Wed, 5 Sep 2018 17:20:49 -0700 Subject: [PATCH 04/34] Removing flavortext --- .../resources/qml/LoginDialog/LinkAccountBody.qml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index f6ad5385c0..423f6cc73b 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -86,21 +86,6 @@ Item { width: 48 height: 48 } - - FlavorText { - id: flavorTextContainer - anchors { - top: parent.top - margins: 0 - topMargin: hifi.dimensions.contentSpacing.y - } - - text: qsTr("Sign in to High Fidelity to make friends, get HFC, and buy interesting things on the Marketplace!") - wrapMode: Text.WordWrap - lineHeight: 2 - lineHeightMode: Text.ProportionalHeight - horizontalAlignment: Text.AlignHCenter - } ShortcutText { id: mainTextContainer From 78fa52285f25ebbd68f3318b724fe4bd8c8f726f Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 5 Sep 2018 23:48:21 -0700 Subject: [PATCH 05/34] adding show password toggle in textfield --- interface/resources/images/eyeClosed.svg | 5 +++ interface/resources/images/eyeOpen.svg | 4 +++ .../qml/LoginDialog/LinkAccountBody.qml | 36 +++++++++++++++---- 3 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 interface/resources/images/eyeClosed.svg create mode 100644 interface/resources/images/eyeOpen.svg diff --git a/interface/resources/images/eyeClosed.svg b/interface/resources/images/eyeClosed.svg new file mode 100644 index 0000000000..6719471b3d --- /dev/null +++ b/interface/resources/images/eyeClosed.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/interface/resources/images/eyeOpen.svg b/interface/resources/images/eyeOpen.svg new file mode 100644 index 0000000000..ec5ceb5238 --- /dev/null +++ b/interface/resources/images/eyeOpen.svg @@ -0,0 +1,4 @@ + + + + diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 423f6cc73b..c40dff61ee 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -86,7 +86,7 @@ Item { width: 48 height: 48 } - + ShortcutText { id: mainTextContainer anchors { @@ -142,6 +142,7 @@ Item { onLinkActivated: loginDialog.openUrl(link) } + onFocusChanged: { root.text = ""; } @@ -151,7 +152,6 @@ Item { id: passwordField width: parent.width placeholderText: "Password" - echoMode: showPassword.checked ? TextInput.Normal : TextInput.Password activeFocusOnPress: true ShortcutText { @@ -177,12 +177,34 @@ Item { root.isPassword = true; } - Keys.onReturnPressed: linkAccountBody.login() - } + Image { + id: showPasswordImage + x: parent.width - 40 + height: parent.height + width: parent.width - (parent.width - 40) + source: "../../images/eyeOpen.svg" + } - CheckBox { - id: showPassword - text: "Show password" + Rectangle { + z: 10 + x: parent.width - 40 + width: parent.width - (parent.width - 40) + height: parent.height + color: "transparent" + MouseArea { + id: passwordFieldMouseArea + anchors.fill: parent + acceptedButtons: Qt.LeftButton + property bool showPassword: false + onClicked: { + showPassword = !showPassword; + passwordField.echoMode = showPassword ? TextInput.Normal : TextInput.Password; + showPasswordImage.source = showPassword ? "../../images/eyeClosed.svg" : "../../images/eyeOpen.svg"; + } + } + } + + Keys.onReturnPressed: linkAccountBody.login() } InfoItem { From 6d055ba1360e492183d5aa692af7182a415a018c Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 5 Sep 2018 23:49:49 -0700 Subject: [PATCH 06/34] changing sign up label --- 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 c40dff61ee..aed34609e4 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -254,7 +254,7 @@ Item { RalewaySemiBold { size: hifi.fontSizes.inputLabel anchors.verticalCenter: parent.verticalCenter - text: qsTr("Don't have an account?") + text: qsTr("New to High Fidelity?") } Button { From 3f1eba418dd210c6435af80df009b460dcb5f185 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 6 Sep 2018 00:07:23 -0700 Subject: [PATCH 07/34] modifying location of links for user/pw --- .../qml/LoginDialog/LinkAccountBody.qml | 68 +++++++++---------- 1 file changed, 31 insertions(+), 37 deletions(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index aed34609e4..caf5ce0e53 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -116,7 +116,6 @@ Item { } spacing: 2 * hifi.dimensions.contentSpacing.y - TextField { id: usernameField text: Settings.getValue("wallet/savedUsername", ""); @@ -125,28 +124,25 @@ Item { placeholderText: "Username or Email" activeFocusOnPress: true - ShortcutText { - z: 10 - anchors { - left: usernameField.right - top: usernameField.bottom - leftMargin: usernameField.textFieldLabel.contentWidth + 10 - topMargin: -19 - } - - text: "Forgot Username?" - - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignHCenter - linkColor: hifi.colors.blueAccent - - onLinkActivated: loginDialog.openUrl(link) - } - onFocusChanged: { root.text = ""; } } + ShortcutText { + z: 10 + anchors { + leftMargin: usernameField.textFieldLabel.contentWidth + 10 + topMargin: -19 + } + + text: "Forgot Username?" + + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignRight + linkColor: hifi.colors.blueAccent + + onLinkActivated: loginDialog.openUrl(link) + } TextField { id: passwordField @@ -154,24 +150,6 @@ Item { placeholderText: "Password" activeFocusOnPress: true - ShortcutText { - z: 10 - anchors { - left: passwordField.right - top: passwordField.bottom - leftMargin: passwordField.textFieldLabel.contentWidth + 10 - topMargin: -19 - } - - text: "Forgot Password?" - - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignHCenter - linkColor: hifi.colors.blueAccent - - onLinkActivated: loginDialog.openUrl(link) - } - onFocusChanged: { root.text = ""; root.isPassword = true; @@ -207,6 +185,22 @@ Item { Keys.onReturnPressed: linkAccountBody.login() } + ShortcutText { + z: 10 + anchors { + leftMargin: passwordField.textFieldLabel.contentWidth + 10 + topMargin: -19 + } + + text: "Forgot Password?" + + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + linkColor: hifi.colors.blueAccent + + onLinkActivated: loginDialog.openUrl(link) + } + InfoItem { id: additionalInformation From 385027321be1f58f7ee061adcdfa34438a22bff4 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 6 Sep 2018 11:18:35 -0700 Subject: [PATCH 08/34] fixing the eye open/closed pw image --- .../qml/LoginDialog/LinkAccountBody.qml | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index caf5ce0e53..cc682aa1ba 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -129,6 +129,7 @@ Item { } } ShortcutText { + id: forgotUsernameShortcut z: 10 anchors { leftMargin: usernameField.textFieldLabel.contentWidth + 10 @@ -149,24 +150,26 @@ Item { width: parent.width placeholderText: "Password" activeFocusOnPress: true + echoMode: TextInput.Password onFocusChanged: { root.text = ""; root.isPassword = true; } - Image { id: showPasswordImage - x: parent.width - 40 - height: parent.height - width: parent.width - (parent.width - 40) + x: parent.width - ((parent.height) * 31 / 23) + y: (parent.height - (parent.height * 16 / 23)) / 2 + width: parent.width - (parent.width - (((parent.height) * 31/23))) + height: parent.height * 16 / 23 source: "../../images/eyeOpen.svg" } Rectangle { + id: showPasswordHitbox z: 10 - x: parent.width - 40 - width: parent.width - (parent.width - 40) + x: parent.width - (parent.height * 31/16) + width: parent.width - (parent.width - (parent.height * 31/16)) height: parent.height color: "transparent" MouseArea { @@ -178,6 +181,13 @@ Item { showPassword = !showPassword; passwordField.echoMode = showPassword ? TextInput.Normal : TextInput.Password; showPasswordImage.source = showPassword ? "../../images/eyeClosed.svg" : "../../images/eyeOpen.svg"; + showPasswordImage.width = passwordField.width - (passwordField.width - (passwordField.height * 31/23)); + showPasswordImage.x = -(showPasswordImage.width - passwordField.width); + showPasswordImage.height = showPassword ? passwordField.height : passwordField.height * 16 / 23; + showPasswordImage.y = showPassword ? 0 : (passwordField.height - showPasswordImage.height) / 2; + showPasswordHitbox.width = showPasswordImage.width; + showPasswordHitbox.x = showPasswordImage.x; + } } } @@ -186,6 +196,7 @@ Item { } ShortcutText { + id: forgotPasswordShortcut z: 10 anchors { leftMargin: passwordField.textFieldLabel.contentWidth + 10 From a5038850f17af34940c3ed15fc38b335d74b8c1f Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 6 Sep 2018 11:37:35 -0700 Subject: [PATCH 09/34] right align forgot user/pw shortcuts --- interface/resources/qml/LoginDialog/LinkAccountBody.qml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index cc682aa1ba..902466270f 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -143,6 +143,9 @@ Item { linkColor: hifi.colors.blueAccent onLinkActivated: loginDialog.openUrl(link) + Component.onCompleted: { + forgotUsernameShortcut.x = root.implicitWidth - forgotUsernameShortcut.width; + } } TextField { @@ -210,6 +213,9 @@ Item { linkColor: hifi.colors.blueAccent onLinkActivated: loginDialog.openUrl(link) + Component.onCompleted: { + forgotPasswordShortcut.x = root.implicitWidth - forgotPasswordShortcut.width; + } } InfoItem { From 00e10ad684f5823e571c16e9e5e4f536877341ff Mon Sep 17 00:00:00 2001 From: Alexia Mandeville Date: Thu, 6 Sep 2018 14:05:51 -0700 Subject: [PATCH 10/34] Updating sign up text, moving forgotten info links --- .../resources/qml/LoginDialog/LinkAccountBody.qml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 423f6cc73b..783027761a 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -128,9 +128,8 @@ Item { ShortcutText { z: 10 anchors { - left: usernameField.right - top: usernameField.bottom - leftMargin: usernameField.textFieldLabel.contentWidth + 10 + right: usernameField.right + top: usernameField.top topMargin: -19 } @@ -157,9 +156,8 @@ Item { ShortcutText { z: 10 anchors { - left: passwordField.right - top: passwordField.bottom - leftMargin: passwordField.textFieldLabel.contentWidth + 10 + right: passwordField.right + top: passwordField.top topMargin: -19 } @@ -232,7 +230,7 @@ Item { RalewaySemiBold { size: hifi.fontSizes.inputLabel anchors.verticalCenter: parent.verticalCenter - text: qsTr("Don't have an account?") + text: qsTr("New to High Fidelity?") } Button { From aabfda6eb5a90072e7c2f84c8e032ed4f4322f9c Mon Sep 17 00:00:00 2001 From: Alexia Mandeville Date: Thu, 6 Sep 2018 14:16:42 -0700 Subject: [PATCH 11/34] Adding descriptive text --- .../qml/LoginDialog/LinkAccountBody.qml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 783027761a..60c7a26e89 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -87,6 +87,22 @@ Item { height: 48 } + ShortcutText { + id: flavorText + anchors { + top: parent.top + left: parent.left + margins: 0 + topMargin: hifi.dimensions.contentSpacing.y + } + + text: qsTr("Sign in to High Fidelity to make friends, get HFC, and buy interesting things on the Marketplace!") + wrapMode: Text.WordWrap + lineHeight: 1 + lineHeightMode: Text.ProportionalHeight + horizontalAlignment: Text.AlignHCenter + } + ShortcutText { id: mainTextContainer anchors { From 8e5f5cc7965a8a59eab894451ec2a54d5174a568 Mon Sep 17 00:00:00 2001 From: Alexia Mandeville Date: Thu, 6 Sep 2018 16:16:43 -0700 Subject: [PATCH 12/34] Moving forgotten links --- interface/resources/qml/LoginDialog/LinkAccountBody.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 60c7a26e89..d2a97874b1 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -145,7 +145,7 @@ Item { z: 10 anchors { right: usernameField.right - top: usernameField.top + top: usernameField.bottom topMargin: -19 } @@ -173,7 +173,7 @@ Item { z: 10 anchors { right: passwordField.right - top: passwordField.top + top: passwordField.bottom topMargin: -19 } From e76ebf7a0b8a4207436c04d7a30aef1d14919b1b Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 6 Sep 2018 17:29:16 -0700 Subject: [PATCH 13/34] changing location of shortcuts --- .../LoginDialog/+android/LinkAccountBody.qml | 40 ++++----- .../qml/LoginDialog/LinkAccountBody.qml | 87 ++++++++++--------- 2 files changed, 66 insertions(+), 61 deletions(-) diff --git a/interface/resources/qml/LoginDialog/+android/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/+android/LinkAccountBody.qml index bf7807c85d..96b638c911 100644 --- a/interface/resources/qml/LoginDialog/+android/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/+android/LinkAccountBody.qml @@ -117,27 +117,27 @@ Item { } spacing: hifi.dimensions.contentSpacing.y / 2 - TextField { - id: usernameField - anchors { - horizontalCenter: parent.horizontalCenter - } - width: 1080 - placeholderText: qsTr("Username or Email") + TextField { + id: usernameField + anchors { + horizontalCenter: parent.horizontalCenter } + width: 1080 + placeholderText: qsTr("Username or Email") + } - TextField { - id: passwordField - anchors { - horizontalCenter: parent.horizontalCenter - } - width: 1080 - - placeholderText: qsTr("Password") - echoMode: TextInput.Password - - Keys.onReturnPressed: linkAccountBody.login() + TextField { + id: passwordField + anchors { + horizontalCenter: parent.horizontalCenter } + width: 1080 + + placeholderText: qsTr("Password") + echoMode: TextInput.Password + + Keys.onReturnPressed: linkAccountBody.login() + } } InfoItem { @@ -176,7 +176,7 @@ Item { anchors { left: parent.left top: form.bottom - topMargin: hifi.dimensions.contentSpacing.y / 2 + topMargin: hifi.dimensions.contentSpacing.y / 2 } spacing: hifi.dimensions.contentSpacing.x @@ -201,7 +201,7 @@ Item { anchors { right: parent.right top: form.bottom - topMargin: hifi.dimensions.contentSpacing.y / 2 + topMargin: hifi.dimensions.contentSpacing.y / 2 } spacing: hifi.dimensions.contentSpacing.x onHeightChanged: d.resize(); onWidthChanged: d.resize(); diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 902466270f..2274d88e04 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -15,13 +15,14 @@ import QtQuick.Controls.Styles 1.4 as OriginalStyles import "../controls-uit" import "../styles-uit" - Item { id: linkAccountBody clip: true height: root.pane.height width: root.pane.width property bool failAfterSignUp: false + property var locale: Qt.locale() + property string dateTimeString function login() { mainTextContainer.visible = false @@ -124,29 +125,27 @@ Item { placeholderText: "Username or Email" activeFocusOnPress: true + ShortcutText { + z: 10 + y: usernameField.height + anchors { + right: usernameField.right + topMargin: -19 + } + + text: "Forgot Username?" + + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + linkColor: hifi.colors.blueAccent + + onLinkActivated: loginDialog.openUrl(link) + } + onFocusChanged: { root.text = ""; } } - ShortcutText { - id: forgotUsernameShortcut - z: 10 - anchors { - leftMargin: usernameField.textFieldLabel.contentWidth + 10 - topMargin: -19 - } - - text: "Forgot Username?" - - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignRight - linkColor: hifi.colors.blueAccent - - onLinkActivated: loginDialog.openUrl(link) - Component.onCompleted: { - forgotUsernameShortcut.x = root.implicitWidth - forgotUsernameShortcut.width; - } - } TextField { id: passwordField @@ -154,11 +153,30 @@ Item { placeholderText: "Password" activeFocusOnPress: true echoMode: TextInput.Password + onHeightChanged: d.resize(); onWidthChanged: d.resize(); + + ShortcutText { + id: forgotPasswordShortcut + y: passwordField.height + z: 10 + anchors { + right: passwordField.right + } + + text: "Forgot Password?" + + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + linkColor: hifi.colors.blueAccent + + onLinkActivated: loginDialog.openUrl(link) + } onFocusChanged: { root.text = ""; root.isPassword = true; } + Image { id: showPasswordImage x: parent.width - ((parent.height) * 31 / 23) @@ -190,7 +208,6 @@ Item { showPasswordImage.y = showPassword ? 0 : (passwordField.height - showPasswordImage.height) / 2; showPasswordHitbox.width = showPasswordImage.width; showPasswordHitbox.x = showPasswordImage.x; - } } } @@ -198,26 +215,6 @@ Item { Keys.onReturnPressed: linkAccountBody.login() } - ShortcutText { - id: forgotPasswordShortcut - z: 10 - anchors { - leftMargin: passwordField.textFieldLabel.contentWidth + 10 - topMargin: -19 - } - - text: "Forgot Password?" - - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignHCenter - linkColor: hifi.colors.blueAccent - - onLinkActivated: loginDialog.openUrl(link) - Component.onCompleted: { - forgotPasswordShortcut.x = root.implicitWidth - forgotPasswordShortcut.width; - } - } - InfoItem { id: additionalInformation @@ -304,6 +301,14 @@ Item { } usernameField.forceActiveFocus(); + + var data = { + "date": new Date().toLocaleString(), + }; + print(new Date().toLocaleString()); + print(model.sessionId); + + //UserActivityLogger.logAction("login_screen_shown", ) } Connections { From 2443723a2bfc324d69e5270e062e699a299c4177 Mon Sep 17 00:00:00 2001 From: Alexia Mandeville Date: Thu, 6 Sep 2018 21:14:04 -0700 Subject: [PATCH 14/34] Removing margins, adding width attribute --- interface/resources/qml/LoginDialog/LinkAccountBody.qml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index d2a97874b1..707c173382 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -97,6 +97,7 @@ Item { } text: qsTr("Sign in to High Fidelity to make friends, get HFC, and buy interesting things on the Marketplace!") + width: parent.width wrapMode: Text.WordWrap lineHeight: 1 lineHeightMode: Text.ProportionalHeight @@ -146,7 +147,6 @@ Item { anchors { right: usernameField.right top: usernameField.bottom - topMargin: -19 } text: "Forgot Username?" @@ -174,7 +174,6 @@ Item { anchors { right: passwordField.right top: passwordField.bottom - topMargin: -19 } text: "Forgot Password?" From 92f218ae29a24edb8ef7a56a62e83a7201998474 Mon Sep 17 00:00:00 2001 From: Alexia Mandeville Date: Thu, 6 Sep 2018 22:59:19 -0700 Subject: [PATCH 15/34] Adding margins to forgotten link text --- interface/resources/qml/LoginDialog/LinkAccountBody.qml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 707c173382..90437c008e 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -147,6 +147,7 @@ Item { anchors { right: usernameField.right top: usernameField.bottom + topMargin: 2 } text: "Forgot Username?" @@ -174,6 +175,7 @@ Item { anchors { right: passwordField.right top: passwordField.bottom + topMargin: 2 } text: "Forgot Password?" From 190a335c7118be684db1e86369759207e16cc29a Mon Sep 17 00:00:00 2001 From: Alexia Mandeville Date: Fri, 7 Sep 2018 00:01:00 -0700 Subject: [PATCH 16/34] Adding more margin to forgotten links --- interface/resources/qml/LoginDialog/LinkAccountBody.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 90437c008e..28523617b6 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -147,7 +147,7 @@ Item { anchors { right: usernameField.right top: usernameField.bottom - topMargin: 2 + topMargin: 4 } text: "Forgot Username?" @@ -175,7 +175,7 @@ Item { anchors { right: passwordField.right top: passwordField.bottom - topMargin: 2 + topMargin: 4 } text: "Forgot Password?" From d9495275cc8ff0dc701486349ecfe1c82cd75b11 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 7 Sep 2018 11:22:31 -0700 Subject: [PATCH 17/34] adding cancel button and signed in checkbox --- interface/resources/qml/LoginDialog.qml | 1 + .../qml/LoginDialog/LinkAccountBody.qml | 23 ++++++++++++++----- .../resources/qml/windows/ModalFrame.qml | 18 +++++++++++++++ .../resources/qml/windows/ModalWindow.qml | 1 + 4 files changed, 37 insertions(+), 6 deletions(-) diff --git a/interface/resources/qml/LoginDialog.qml b/interface/resources/qml/LoginDialog.qml index e21e8b7354..336858502d 100644 --- a/interface/resources/qml/LoginDialog.qml +++ b/interface/resources/qml/LoginDialog.qml @@ -23,6 +23,7 @@ ModalWindow { objectName: "LoginDialog" implicitWidth: 520 implicitHeight: 320 + closeButtonVisible: true destroyOnCloseButton: true destroyOnHidden: true visible: true diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 2274d88e04..4c9fe6ae94 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -234,6 +234,23 @@ Item { onHeightChanged: d.resize(); onWidthChanged: d.resize(); anchors.horizontalCenter: parent.horizontalCenter + CheckBox { + id: autoLogoutCheckbox; + checked: Settings.getValue("wallet/autoLogout", true); + text: "Keep me signed in" + boxSize: 20; + labelFontSize: 15; + color: hifi.colors.black; + onCheckedChanged: { + Settings.setValue("wallet/autoLogout", !checked); + if (checked) { + Settings.setValue("wallet/savedUsername", ""); + } else { + Settings.setValue("wallet/savedUsername", Account.username); + } + } + } + Button { id: linkAccountButton anchors.verticalCenter: parent.verticalCenter @@ -244,12 +261,6 @@ Item { onClicked: linkAccountBody.login() } - - Button { - anchors.verticalCenter: parent.verticalCenter - text: qsTr("Cancel") - onClicked: root.tryDestroy() - } } Row { diff --git a/interface/resources/qml/windows/ModalFrame.qml b/interface/resources/qml/windows/ModalFrame.qml index 211353b5f3..640069a0b3 100644 --- a/interface/resources/qml/windows/ModalFrame.qml +++ b/interface/resources/qml/windows/ModalFrame.qml @@ -94,5 +94,23 @@ 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 + onClicked: { + window.destroy(); + } + } } } diff --git a/interface/resources/qml/windows/ModalWindow.qml b/interface/resources/qml/windows/ModalWindow.qml index 2d56099051..75f5c2d646 100644 --- a/interface/resources/qml/windows/ModalWindow.qml +++ b/interface/resources/qml/windows/ModalWindow.qml @@ -19,6 +19,7 @@ ScrollingWindow { destroyOnHidden: true frame: ModalFrame { } + property bool closeButtonVisible: false property int colorScheme: hifi.colorSchemes.light property bool draggable: false From db96603cdabc35034aa393ed750952c854f618ce Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 7 Sep 2018 11:23:58 -0700 Subject: [PATCH 18/34] removing some unused properties --- interface/resources/qml/LoginDialog/LinkAccountBody.qml | 2 -- 1 file changed, 2 deletions(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 4c9fe6ae94..9bb40fd538 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -21,8 +21,6 @@ Item { height: root.pane.height width: root.pane.width property bool failAfterSignUp: false - property var locale: Qt.locale() - property string dateTimeString function login() { mainTextContainer.visible = false From 44d36ec622dd0fee044ebecac11d6c387d4721a6 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 7 Sep 2018 11:31:29 -0700 Subject: [PATCH 19/34] wallet should save username when checked --- interface/resources/qml/LoginDialog/LinkAccountBody.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 9bb40fd538..ca81a6b870 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -242,9 +242,9 @@ Item { onCheckedChanged: { Settings.setValue("wallet/autoLogout", !checked); if (checked) { - Settings.setValue("wallet/savedUsername", ""); - } else { Settings.setValue("wallet/savedUsername", Account.username); + } else { + Settings.setValue("wallet/savedUsername", ""); } } } From 39041f294281f249386a63096faaff4195659924 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 7 Sep 2018 11:36:21 -0700 Subject: [PATCH 20/34] fixing username field --- .../resources/qml/LoginDialog/LinkAccountBody.qml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index ca81a6b870..bc0b8fb2e0 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -242,9 +242,9 @@ Item { onCheckedChanged: { Settings.setValue("wallet/autoLogout", !checked); if (checked) { - Settings.setValue("wallet/savedUsername", Account.username); - } else { Settings.setValue("wallet/savedUsername", ""); + } else { + Settings.setValue("wallet/savedUsername", Account.username); } } } @@ -310,14 +310,6 @@ Item { } usernameField.forceActiveFocus(); - - var data = { - "date": new Date().toLocaleString(), - }; - print(new Date().toLocaleString()); - print(model.sessionId); - - //UserActivityLogger.logAction("login_screen_shown", ) } Connections { From ff86e480baa26c02353ad20103a320605c18ca18 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Mon, 10 Sep 2018 11:36:45 -0700 Subject: [PATCH 21/34] adding debug statement to check for window close --- interface/resources/qml/LoginDialog.qml | 7 ++++ .../qml/dialogs/TabletLoginDialog.qml | 6 ++++ .../networking/src/UserActivityLogger.cpp | 36 +++++++++---------- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/interface/resources/qml/LoginDialog.qml b/interface/resources/qml/LoginDialog.qml index e21e8b7354..99c999249b 100644 --- a/interface/resources/qml/LoginDialog.qml +++ b/interface/resources/qml/LoginDialog.qml @@ -84,4 +84,11 @@ ModalWindow { break } } + Component.onDestruction: { +/* var data = { + "action": "userOptedOut" + }; + UserActivityLogger.logAction("LoginDialogAction", data); */ + print("destroyed"); + } } diff --git a/interface/resources/qml/dialogs/TabletLoginDialog.qml b/interface/resources/qml/dialogs/TabletLoginDialog.qml index c85b2b2ba0..3be4d8217d 100644 --- a/interface/resources/qml/dialogs/TabletLoginDialog.qml +++ b/interface/resources/qml/dialogs/TabletLoginDialog.qml @@ -173,4 +173,10 @@ TabletModalWindow { break } } + onDestroy: { + var data = { + "action": "userOptedOut" + }; + UserActivityLogger.logAction("LoginDialogAction", data); + } } diff --git a/libraries/networking/src/UserActivityLogger.cpp b/libraries/networking/src/UserActivityLogger.cpp index a5ee417939..c05daf0217 100644 --- a/libraries/networking/src/UserActivityLogger.cpp +++ b/libraries/networking/src/UserActivityLogger.cpp @@ -38,10 +38,10 @@ void UserActivityLogger::logAction(QString action, QJsonObject details, JSONCall if (_disabled.get()) { return; } - + auto accountManager = DependencyManager::get(); QHttpMultiPart* multipart = new QHttpMultiPart(QHttpMultiPart::FormDataType); - + // Adding the action name QHttpPart actionPart; actionPart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data; name=\"action_name\""); @@ -53,7 +53,7 @@ void UserActivityLogger::logAction(QString action, QJsonObject details, JSONCall elapsedPart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data; name=\"elapsed_ms\""); elapsedPart.setBody(QString::number(_timer.elapsed()).toLocal8Bit()); multipart->append(elapsedPart); - + // If there are action details, add them to the multipart if (!details.isEmpty()) { QHttpPart detailsPart; @@ -62,13 +62,13 @@ void UserActivityLogger::logAction(QString action, QJsonObject details, JSONCall detailsPart.setBody(QJsonDocument(details).toJson(QJsonDocument::Compact)); multipart->append(detailsPart); } - + // if no callbacks specified, call our owns if (params.isEmpty()) { params.callbackReceiver = this; params.errorCallbackMethod = "requestError"; } - + accountManager->sendRequest(USER_ACTIVITY_URL, AccountManagerAuth::Optional, QNetworkAccessManager::PostOperation, @@ -88,7 +88,7 @@ void UserActivityLogger::launch(QString applicationVersion, bool previousSession actionDetails.insert(VERSION_KEY, applicationVersion); actionDetails.insert(CRASH_KEY, previousSessionCrashed); actionDetails.insert(RUNTIME_KEY, previousSessionRuntime); - + logAction(ACTION_NAME, actionDetails); } @@ -105,9 +105,9 @@ void UserActivityLogger::changedDisplayName(QString displayName) { const QString ACTION_NAME = "changed_display_name"; QJsonObject actionDetails; const QString DISPLAY_NAME = "display_name"; - + actionDetails.insert(DISPLAY_NAME, displayName); - + logAction(ACTION_NAME, actionDetails); } @@ -116,10 +116,10 @@ void UserActivityLogger::changedModel(QString typeOfModel, QString modelURL) { QJsonObject actionDetails; const QString TYPE_OF_MODEL = "type_of_model"; const QString MODEL_URL = "model_url"; - + actionDetails.insert(TYPE_OF_MODEL, typeOfModel); actionDetails.insert(MODEL_URL, modelURL); - + logAction(ACTION_NAME, actionDetails); } @@ -127,9 +127,9 @@ void UserActivityLogger::changedDomain(QString domainURL) { const QString ACTION_NAME = "changed_domain"; QJsonObject actionDetails; const QString DOMAIN_URL = "domain_url"; - + actionDetails.insert(DOMAIN_URL, domainURL); - + logAction(ACTION_NAME, actionDetails); } @@ -151,10 +151,10 @@ void UserActivityLogger::connectedDevice(QString typeOfDevice, QString deviceNam QJsonObject actionDetails; const QString TYPE_OF_DEVICE = "type_of_device"; const QString DEVICE_NAME = "device_name"; - + actionDetails.insert(TYPE_OF_DEVICE, typeOfDevice); actionDetails.insert(DEVICE_NAME, deviceName); - + logAction(ACTION_NAME, actionDetails); } @@ -163,9 +163,9 @@ void UserActivityLogger::loadedScript(QString scriptName) { const QString ACTION_NAME = "loaded_script"; QJsonObject actionDetails; const QString SCRIPT_NAME = "script_name"; - + actionDetails.insert(SCRIPT_NAME, scriptName); - + logAction(ACTION_NAME, actionDetails); } @@ -199,10 +199,10 @@ void UserActivityLogger::wentTo(AddressManager::LookupTrigger lookupTrigger, QSt const QString TRIGGER_TYPE_KEY = "trigger"; const QString DESTINATION_TYPE_KEY = "destination_type"; const QString DESTINATION_NAME_KEY = "detination_name"; - + actionDetails.insert(TRIGGER_TYPE_KEY, trigger); actionDetails.insert(DESTINATION_TYPE_KEY, destinationType); actionDetails.insert(DESTINATION_NAME_KEY, destinationName); - + logAction(ACTION_NAME, actionDetails); } From e7616c7d34d431abdd1fe0874c44c8cf35aaba43 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Mon, 10 Sep 2018 15:06:14 -0700 Subject: [PATCH 22/34] added logging + activity logging --- interface/resources/qml/LoginDialog.qml | 11 +++++---- .../qml/LoginDialog/LinkAccountBody.qml | 23 +++++++++++-------- .../qml/dialogs/TabletLoginDialog.qml | 2 +- .../resources/qml/windows/ModalFrame.qml | 1 + .../resources/qml/windows/ModalWindow.qml | 2 ++ interface/src/Application.cpp | 5 +++- interface/src/ui/LoginDialog.cpp | 5 ++++ interface/src/ui/LoginDialog.h | 5 ++++ 8 files changed, 37 insertions(+), 17 deletions(-) diff --git a/interface/resources/qml/LoginDialog.qml b/interface/resources/qml/LoginDialog.qml index d5db8f9fb1..6ad6cdf93d 100644 --- a/interface/resources/qml/LoginDialog.qml +++ b/interface/resources/qml/LoginDialog.qml @@ -86,10 +86,11 @@ ModalWindow { } } Component.onDestruction: { -/* var data = { - "action": "userOptedOut" - }; - UserActivityLogger.logAction("LoginDialogAction", data); */ - print("destroyed"); + if (closeButtonVisible && clickedCloseButton) { + var data = { + "action": "opted out" + }; + UserActivityLogger.logAction("encourageLoginDialog", data); + } } } diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 6637a96fbb..d19837a023 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -195,22 +195,25 @@ Item { root.isPassword = true; } - Image { - id: showPasswordImage - x: parent.width - ((parent.height) * 31 / 23) - y: (parent.height - (parent.height * 16 / 23)) / 2 - width: parent.width - (parent.width - (((parent.height) * 31/23))) - height: parent.height * 16 / 23 - source: "../../images/eyeOpen.svg" - } - Rectangle { id: showPasswordHitbox z: 10 - x: parent.width - (parent.height * 31/16) + // x: parent.width - (parent.height * 31/16) + x: passwordField.width - ((passwordField.height) * 31 / 23) width: parent.width - (parent.width - (parent.height * 31/16)) + // width: passwordField.width - (passwordField.width - (((passwordField.height) * 31/23))) height: parent.height color: "transparent" + + Image { + id: showPasswordImage + // x: passwordField.width - ((passwordField.height) * 31 / 23) + y: (passwordField.height - (passwordField.height * 16 / 23)) / 2 + width: passwordField.width - (passwordField.width - (((passwordField.height) * 31/23))) + height: passwordField.height * 16 / 23 + source: "../../images/eyeOpen.svg" + } + MouseArea { id: passwordFieldMouseArea anchors.fill: parent diff --git a/interface/resources/qml/dialogs/TabletLoginDialog.qml b/interface/resources/qml/dialogs/TabletLoginDialog.qml index 3be4d8217d..c3889b6a30 100644 --- a/interface/resources/qml/dialogs/TabletLoginDialog.qml +++ b/interface/resources/qml/dialogs/TabletLoginDialog.qml @@ -173,7 +173,7 @@ TabletModalWindow { break } } - onDestroy: { + Component.onDestruction: { var data = { "action": "userOptedOut" }; diff --git a/interface/resources/qml/windows/ModalFrame.qml b/interface/resources/qml/windows/ModalFrame.qml index 820c04f500..cb23ccd5ad 100644 --- a/interface/resources/qml/windows/ModalFrame.qml +++ b/interface/resources/qml/windows/ModalFrame.qml @@ -110,6 +110,7 @@ Frame { glyph: hifi.glyphs.close size: 23 onClicked: { + window.clickedCloseButton = true; window.destroy(); } } diff --git a/interface/resources/qml/windows/ModalWindow.qml b/interface/resources/qml/windows/ModalWindow.qml index 75f5c2d646..ebd5293b0a 100644 --- a/interface/resources/qml/windows/ModalWindow.qml +++ b/interface/resources/qml/windows/ModalWindow.qml @@ -20,6 +20,8 @@ ScrollingWindow { frame: ModalFrame { } property bool closeButtonVisible: false + // only applicable for if close button is visible. + property bool clickedCloseButton: false property int colorScheme: hifi.colorSchemes.light property bool draggable: false diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 9a56a757dd..15545a0275 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2308,8 +2308,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo connect(checkLoginTimer, &QTimer::timeout, this, []() { auto accountManager = DependencyManager::get(); auto dialogsManager = DependencyManager::get(); - if (!accountManager->isLoggedIn()) { + if (!accountManager->isLoggedIn() && !qApp->isHMDMode()) { dialogsManager->showLoginDialog(); + QJsonObject loginData = {}; + loginData["action"] = "login dialog shown"; + UserActivityLogger::getInstance().logAction("encourageLoginDialog", loginData); } }); checkLoginTimer->start(); diff --git a/interface/src/ui/LoginDialog.cpp b/interface/src/ui/LoginDialog.cpp index 8a40ee2f83..31a995c70b 100644 --- a/interface/src/ui/LoginDialog.cpp +++ b/interface/src/ui/LoginDialog.cpp @@ -28,6 +28,7 @@ #include "scripting/HMDScriptingInterface.h" HIFI_QML_DEF(LoginDialog) +Q_LOGGING_CATEGORY(login_dialog, "hifi.login.dialog") LoginDialog::LoginDialog(QQuickItem *parent) : OffscreenQmlDialog(parent) { auto accountManager = DependencyManager::get(); @@ -40,6 +41,10 @@ LoginDialog::LoginDialog(QQuickItem *parent) : OffscreenQmlDialog(parent) { } +LoginDialog::~LoginDialog() { + qCDebug(login_dialog) << "killing"; +} + void LoginDialog::showWithSelection() { auto tabletScriptingInterface = DependencyManager::get(); diff --git a/interface/src/ui/LoginDialog.h b/interface/src/ui/LoginDialog.h index ad8cab9699..210438b856 100644 --- a/interface/src/ui/LoginDialog.h +++ b/interface/src/ui/LoginDialog.h @@ -15,6 +15,9 @@ #define hifi_LoginDialog_h #include +#include + +Q_DECLARE_LOGGING_CATEGORY(login_dialog) class QNetworkReply; @@ -27,6 +30,8 @@ public: LoginDialog(QQuickItem* parent = nullptr); + virtual ~LoginDialog(); + static void showWithSelection(); signals: void handleLoginCompleted(); From dcacfdba7cd0d9d59b467b4b03bd5f3c60b9790a Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Mon, 10 Sep 2018 16:22:55 -0700 Subject: [PATCH 23/34] adding popup property to qml --- interface/src/Application.cpp | 3 +++ interface/src/Application.h | 2 ++ interface/src/ui/DialogsManager.cpp | 4 ++++ interface/src/ui/DialogsManager.h | 1 + interface/src/ui/LoginDialog.h | 6 ++++++ 5 files changed, 16 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 15545a0275..cdf19ea6ac 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2301,6 +2301,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo AndroidHelper::instance().notifyLoadComplete(); #endif + connect(this, &Application::loginDialogPoppedUp, DependencyManager::get().data(), &DialogsManager::loginDialogPoppedUp); + static int CHECK_LOGIN_TIMER = 3000; QTimer* checkLoginTimer = new QTimer(this); checkLoginTimer->setInterval(CHECK_LOGIN_TIMER); @@ -2309,6 +2311,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo auto accountManager = DependencyManager::get(); auto dialogsManager = DependencyManager::get(); if (!accountManager->isLoggedIn() && !qApp->isHMDMode()) { + emit loginDialogPoppedUp(); dialogsManager->showLoginDialog(); QJsonObject loginData = {}; loginData["action"] = "login dialog shown"; diff --git a/interface/src/Application.h b/interface/src/Application.h index aa8323cd38..d661a74bcb 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -331,6 +331,8 @@ signals: void uploadRequest(QString path); + void loginDialogPoppedUp(); + public slots: QVector pasteEntities(float x, float y, float z); bool exportEntities(const QString& filename, const QVector& entityIDs, const glm::vec3* givenOffset = nullptr); diff --git a/interface/src/ui/DialogsManager.cpp b/interface/src/ui/DialogsManager.cpp index 83601a2797..960b099d22 100644 --- a/interface/src/ui/DialogsManager.cpp +++ b/interface/src/ui/DialogsManager.cpp @@ -117,6 +117,10 @@ void DialogsManager::showLoginDialog() { LoginDialog::showWithSelection(); } +void DialogsManager::loginDialogPoppedUp() { + LoginDialog::setLoginDialogPoppedUp(true); +} + void DialogsManager::showUpdateDialog() { UpdateDialog::show(); } diff --git a/interface/src/ui/DialogsManager.h b/interface/src/ui/DialogsManager.h index 0633dec573..9dc70d0cd0 100644 --- a/interface/src/ui/DialogsManager.h +++ b/interface/src/ui/DialogsManager.h @@ -48,6 +48,7 @@ public slots: void setDomainConnectionFailureVisibility(bool visible); void toggleLoginDialog(); void showLoginDialog(); + void loginDialogPoppedUp(); void octreeStatsDetails(); void lodTools(); void hmdTools(bool showTools); diff --git a/interface/src/ui/LoginDialog.h b/interface/src/ui/LoginDialog.h index 210438b856..f9580d0bfe 100644 --- a/interface/src/ui/LoginDialog.h +++ b/interface/src/ui/LoginDialog.h @@ -23,6 +23,7 @@ class QNetworkReply; class LoginDialog : public OffscreenQmlDialog { Q_OBJECT + Q_PROPERTY(bool poppedUp READ getLoginDialogPoppedUp) HIFI_QML_DECL public: @@ -33,6 +34,9 @@ public: virtual ~LoginDialog(); static void showWithSelection(); + + bool getLoginDialogPoppedUp() { return _poppedUp; } + void setLoginDialogPoppedUp(bool poppedUp) { _poppedUp = poppedUp; } signals: void handleLoginCompleted(); void handleLoginFailed(); @@ -68,6 +72,8 @@ protected slots: Q_INVOKABLE void openUrl(const QString& url) const; +private: + bool _poppedUp {false}; }; #endif // hifi_LoginDialog_h From 5ece8d8707f65f02896944c570295c6d0652840b Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Mon, 10 Sep 2018 18:32:21 -0700 Subject: [PATCH 24/34] using different paradigm for checking login dialog popup --- interface/resources/qml/LoginDialog.qml | 3 ++- interface/src/Application.cpp | 12 ++++++++---- interface/src/ui/DialogsManager.cpp | 4 ---- interface/src/ui/DialogsManager.h | 1 - interface/src/ui/LoginDialog.cpp | 13 +++++++++++-- interface/src/ui/LoginDialog.h | 3 --- 6 files changed, 21 insertions(+), 15 deletions(-) diff --git a/interface/resources/qml/LoginDialog.qml b/interface/resources/qml/LoginDialog.qml index 6ad6cdf93d..227fce3454 100644 --- a/interface/resources/qml/LoginDialog.qml +++ b/interface/resources/qml/LoginDialog.qml @@ -86,11 +86,12 @@ ModalWindow { } } Component.onDestruction: { - if (closeButtonVisible && clickedCloseButton) { + if (closeButtonVisible && clickedCloseButton && Settings.getValue("loginDialogPoppedUp", false)) { var data = { "action": "opted out" }; UserActivityLogger.logAction("encourageLoginDialog", data); } + Settings.setValue("loginDialogPoppedUp", false); } } diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index cdf19ea6ac..7f437e273c 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2301,23 +2301,24 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo AndroidHelper::instance().notifyLoadComplete(); #endif - connect(this, &Application::loginDialogPoppedUp, DependencyManager::get().data(), &DialogsManager::loginDialogPoppedUp); - static int CHECK_LOGIN_TIMER = 3000; QTimer* checkLoginTimer = new QTimer(this); checkLoginTimer->setInterval(CHECK_LOGIN_TIMER); checkLoginTimer->setSingleShot(true); - connect(checkLoginTimer, &QTimer::timeout, this, []() { + connect(checkLoginTimer, &QTimer::timeout, this, [this]() { auto accountManager = DependencyManager::get(); auto dialogsManager = DependencyManager::get(); if (!accountManager->isLoggedIn() && !qApp->isHMDMode()) { - emit loginDialogPoppedUp(); + Settings settings; + settings.setValue("loginDialogPoppedUp", true); dialogsManager->showLoginDialog(); QJsonObject loginData = {}; loginData["action"] = "login dialog shown"; UserActivityLogger::getInstance().logAction("encourageLoginDialog", loginData); } }); + Settings settings; + settings.setValue("loginDialogPoppedUp", false); checkLoginTimer->start(); } @@ -4948,6 +4949,9 @@ void Application::loadSettings() { } void Application::saveSettings() const { + Settings settings; + settings.setValue("loginDialogPoppedUp", false); + sessionRunTime.set(_sessionRunTimer.elapsed() / MSECS_PER_SECOND); DependencyManager::get()->saveSettings(); DependencyManager::get()->saveSettings(); diff --git a/interface/src/ui/DialogsManager.cpp b/interface/src/ui/DialogsManager.cpp index 960b099d22..83601a2797 100644 --- a/interface/src/ui/DialogsManager.cpp +++ b/interface/src/ui/DialogsManager.cpp @@ -117,10 +117,6 @@ void DialogsManager::showLoginDialog() { LoginDialog::showWithSelection(); } -void DialogsManager::loginDialogPoppedUp() { - LoginDialog::setLoginDialogPoppedUp(true); -} - void DialogsManager::showUpdateDialog() { UpdateDialog::show(); } diff --git a/interface/src/ui/DialogsManager.h b/interface/src/ui/DialogsManager.h index 9dc70d0cd0..0633dec573 100644 --- a/interface/src/ui/DialogsManager.h +++ b/interface/src/ui/DialogsManager.h @@ -48,7 +48,6 @@ public slots: void setDomainConnectionFailureVisibility(bool visible); void toggleLoginDialog(); void showLoginDialog(); - void loginDialogPoppedUp(); void octreeStatsDetails(); void lodTools(); void hmdTools(bool showTools); diff --git a/interface/src/ui/LoginDialog.cpp b/interface/src/ui/LoginDialog.cpp index 31a995c70b..6d94e1419b 100644 --- a/interface/src/ui/LoginDialog.cpp +++ b/interface/src/ui/LoginDialog.cpp @@ -20,6 +20,8 @@ #include #include +#include + #include "AccountManager.h" #include "DependencyManager.h" #include "Menu.h" @@ -38,11 +40,18 @@ LoginDialog::LoginDialog(QQuickItem *parent) : OffscreenQmlDialog(parent) { connect(accountManager.data(), &AccountManager::loginFailed, this, &LoginDialog::handleLoginFailed); #endif - } LoginDialog::~LoginDialog() { - qCDebug(login_dialog) << "killing"; + Settings settings; + Setting::Handle loginDialogPoppedUp{ "loginDialogPoppedUp", false }; + auto poppedUp = loginDialogPoppedUp.get(); + if (poppedUp) { + QJsonObject data; + data["action"] = "user opted out"; + UserActivityLogger::getInstance().logAction("encourageLoginDialog", data); + } + settings.setValue("loginDialogPoppedUp", false); } void LoginDialog::showWithSelection() diff --git a/interface/src/ui/LoginDialog.h b/interface/src/ui/LoginDialog.h index f9580d0bfe..155970e33d 100644 --- a/interface/src/ui/LoginDialog.h +++ b/interface/src/ui/LoginDialog.h @@ -23,7 +23,6 @@ class QNetworkReply; class LoginDialog : public OffscreenQmlDialog { Q_OBJECT - Q_PROPERTY(bool poppedUp READ getLoginDialogPoppedUp) HIFI_QML_DECL public: @@ -35,8 +34,6 @@ public: static void showWithSelection(); - bool getLoginDialogPoppedUp() { return _poppedUp; } - void setLoginDialogPoppedUp(bool poppedUp) { _poppedUp = poppedUp; } signals: void handleLoginCompleted(); void handleLoginFailed(); From 69ae475787ded665abe60b820f7c1648e9e4d070 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Mon, 10 Sep 2018 23:04:50 -0700 Subject: [PATCH 25/34] adding user activity logging --- interface/resources/qml/LoginDialog.qml | 9 --------- .../resources/qml/LoginDialog/LinkAccountBody.qml | 12 ++++++++++++ interface/src/Application.cpp | 11 ++++------- interface/src/ui/LoginDialog.cpp | 3 +-- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/interface/resources/qml/LoginDialog.qml b/interface/resources/qml/LoginDialog.qml index 227fce3454..336858502d 100644 --- a/interface/resources/qml/LoginDialog.qml +++ b/interface/resources/qml/LoginDialog.qml @@ -85,13 +85,4 @@ ModalWindow { break } } - Component.onDestruction: { - if (closeButtonVisible && clickedCloseButton && Settings.getValue("loginDialogPoppedUp", false)) { - var data = { - "action": "opted out" - }; - UserActivityLogger.logAction("encourageLoginDialog", data); - } - Settings.setValue("loginDialogPoppedUp", false); - } } diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index d19837a023..f7216584e0 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -350,11 +350,23 @@ Item { bodyLoader.item.width = root.pane.width bodyLoader.item.height = root.pane.height } + if (Settings.getValue("loginDialogPoppedUp", false)) { + var data = { + "action": "user logged in" + }; + UserActivityLogger.logAction("encourageLoginDialog", data); + } } onHandleLoginFailed: { console.log("Login Failed") mainTextContainer.visible = true toggleLoading(false) + if (Settings.getValue("loginDialogPoppedUp", false)) { + var data = { + "action": "user failed logging in" + }; + UserActivityLogger.logAction("encourageLoginDialog", data); + } } onHandleLinkCompleted: { console.log("Link Succeeded") diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 7f437e273c..de788de99f 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2309,16 +2309,14 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo auto accountManager = DependencyManager::get(); auto dialogsManager = DependencyManager::get(); if (!accountManager->isLoggedIn() && !qApp->isHMDMode()) { - Settings settings; - settings.setValue("loginDialogPoppedUp", true); + Setting::Handle{"loginDialogPoppedUp", false}.set(true); dialogsManager->showLoginDialog(); QJsonObject loginData = {}; loginData["action"] = "login dialog shown"; UserActivityLogger::getInstance().logAction("encourageLoginDialog", loginData); } }); - Settings settings; - settings.setValue("loginDialogPoppedUp", false); + Setting::Handle{"loginDialogPoppedUp", false}.set(false); checkLoginTimer->start(); } @@ -2453,6 +2451,8 @@ void Application::onAboutToQuit() { // so its persisted explicitly here Setting::Handle{ ACTIVE_DISPLAY_PLUGIN_SETTING_NAME }.set(getActiveDisplayPlugin()->getName()); + Setting::Handle{"loginDialogPoppedUp", false}.set(false); + getActiveDisplayPlugin()->deactivate(); if (_autoSwitchDisplayModeSupportedHMDPlugin && _autoSwitchDisplayModeSupportedHMDPlugin->isSessionActive()) { @@ -4949,9 +4949,6 @@ void Application::loadSettings() { } void Application::saveSettings() const { - Settings settings; - settings.setValue("loginDialogPoppedUp", false); - sessionRunTime.set(_sessionRunTimer.elapsed() / MSECS_PER_SECOND); DependencyManager::get()->saveSettings(); DependencyManager::get()->saveSettings(); diff --git a/interface/src/ui/LoginDialog.cpp b/interface/src/ui/LoginDialog.cpp index 6d94e1419b..5116c2a92c 100644 --- a/interface/src/ui/LoginDialog.cpp +++ b/interface/src/ui/LoginDialog.cpp @@ -43,7 +43,6 @@ LoginDialog::LoginDialog(QQuickItem *parent) : OffscreenQmlDialog(parent) { } LoginDialog::~LoginDialog() { - Settings settings; Setting::Handle loginDialogPoppedUp{ "loginDialogPoppedUp", false }; auto poppedUp = loginDialogPoppedUp.get(); if (poppedUp) { @@ -51,7 +50,7 @@ LoginDialog::~LoginDialog() { data["action"] = "user opted out"; UserActivityLogger::getInstance().logAction("encourageLoginDialog", data); } - settings.setValue("loginDialogPoppedUp", false); + loginDialogPoppedUp.set(false); } void LoginDialog::showWithSelection() From 030ee13f319e8123bb7069ddfcd4a0f02b9ddd58 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Mon, 10 Sep 2018 23:05:31 -0700 Subject: [PATCH 26/34] removing logging from tabletlogindialog --- interface/resources/qml/dialogs/TabletLoginDialog.qml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/interface/resources/qml/dialogs/TabletLoginDialog.qml b/interface/resources/qml/dialogs/TabletLoginDialog.qml index c3889b6a30..c85b2b2ba0 100644 --- a/interface/resources/qml/dialogs/TabletLoginDialog.qml +++ b/interface/resources/qml/dialogs/TabletLoginDialog.qml @@ -173,10 +173,4 @@ TabletModalWindow { break } } - Component.onDestruction: { - var data = { - "action": "userOptedOut" - }; - UserActivityLogger.logAction("LoginDialogAction", data); - } } From 565bf7f6bd0c69c5ff314302f5b38b566b08f997 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 11 Sep 2018 09:08:35 -0700 Subject: [PATCH 27/34] adding correct implementation of show password --- .../resources/qml/LoginDialog/LinkAccountBody.qml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index f7216584e0..06a371c478 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -198,19 +198,23 @@ Item { Rectangle { id: showPasswordHitbox z: 10 - // x: parent.width - (parent.height * 31/16) x: passwordField.width - ((passwordField.height) * 31 / 23) width: parent.width - (parent.width - (parent.height * 31/16)) - // width: passwordField.width - (passwordField.width - (((passwordField.height) * 31/23))) height: parent.height + anchors { + right: parent.right + } color: "transparent" Image { id: showPasswordImage - // x: passwordField.width - ((passwordField.height) * 31 / 23) y: (passwordField.height - (passwordField.height * 16 / 23)) / 2 width: passwordField.width - (passwordField.width - (((passwordField.height) * 31/23))) height: passwordField.height * 16 / 23 + anchors { + right: parent.right + rightMargin: 3 + } source: "../../images/eyeOpen.svg" } @@ -223,12 +227,8 @@ Item { showPassword = !showPassword; passwordField.echoMode = showPassword ? TextInput.Normal : TextInput.Password; showPasswordImage.source = showPassword ? "../../images/eyeClosed.svg" : "../../images/eyeOpen.svg"; - showPasswordImage.width = passwordField.width - (passwordField.width - (passwordField.height * 31/23)); - showPasswordImage.x = -(showPasswordImage.width - passwordField.width); showPasswordImage.height = showPassword ? passwordField.height : passwordField.height * 16 / 23; showPasswordImage.y = showPassword ? 0 : (passwordField.height - showPasswordImage.height) / 2; - showPasswordHitbox.width = showPasswordImage.width; - showPasswordHitbox.x = showPasswordImage.x; } } } From ee516fd79f65825aa486a3f6f64bcc606e89214e Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 11 Sep 2018 09:36:46 -0700 Subject: [PATCH 28/34] adding proper checking for saved username/login --- .../qml/LoginDialog/LinkAccountBody.qml | 16 ++-- interface/src/ui/LoginDialog.cpp | 80 ++++++++----------- 2 files changed, 42 insertions(+), 54 deletions(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 06a371c478..4196b7f168 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -161,6 +161,10 @@ Item { onFocusChanged: { root.text = ""; } + Component.onCompleted: { + var savedUsername = Settings.getValue("wallet/savedUsername", ""); + usernameField.text = savedUsername === "Unknown user" ? "" : savedUsername; + } } TextField { @@ -256,18 +260,18 @@ Item { anchors.horizontalCenter: parent.horizontalCenter CheckBox { - id: autoLogoutCheckbox; - checked: Settings.getValue("wallet/autoLogout", true); + id: autoLogoutCheckbox + checked: !Settings.getValue("wallet/autoLogout", true) text: "Keep me signed in" boxSize: 20; - labelFontSize: 15; - color: hifi.colors.black; + labelFontSize: 15 + color: hifi.colors.black onCheckedChanged: { Settings.setValue("wallet/autoLogout", !checked); if (checked) { - Settings.setValue("wallet/savedUsername", ""); - } else { Settings.setValue("wallet/savedUsername", Account.username); + } else { + Settings.setValue("wallet/savedUsername", ""); } } Component.onDestruction: { diff --git a/interface/src/ui/LoginDialog.cpp b/interface/src/ui/LoginDialog.cpp index 5116c2a92c..0d574fdc5d 100644 --- a/interface/src/ui/LoginDialog.cpp +++ b/interface/src/ui/LoginDialog.cpp @@ -32,20 +32,17 @@ HIFI_QML_DEF(LoginDialog) Q_LOGGING_CATEGORY(login_dialog, "hifi.login.dialog") -LoginDialog::LoginDialog(QQuickItem *parent) : OffscreenQmlDialog(parent) { +LoginDialog::LoginDialog(QQuickItem* parent) : OffscreenQmlDialog(parent) { auto accountManager = DependencyManager::get(); #if !defined(Q_OS_ANDROID) - connect(accountManager.data(), &AccountManager::loginComplete, - this, &LoginDialog::handleLoginCompleted); - connect(accountManager.data(), &AccountManager::loginFailed, - this, &LoginDialog::handleLoginFailed); + connect(accountManager.data(), &AccountManager::loginComplete, this, &LoginDialog::handleLoginCompleted); + connect(accountManager.data(), &AccountManager::loginFailed, this, &LoginDialog::handleLoginFailed); #endif } LoginDialog::~LoginDialog() { Setting::Handle loginDialogPoppedUp{ "loginDialogPoppedUp", false }; - auto poppedUp = loginDialogPoppedUp.get(); - if (poppedUp) { + if (loginDialogPoppedUp.get()) { QJsonObject data; data["action"] = "user opted out"; UserActivityLogger::getInstance().logAction("encourageLoginDialog", data); @@ -53,8 +50,7 @@ LoginDialog::~LoginDialog() { loginDialogPoppedUp.set(false); } -void LoginDialog::showWithSelection() -{ +void LoginDialog::showWithSelection() { auto tabletScriptingInterface = DependencyManager::get(); auto tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); auto hmd = DependencyManager::get(); @@ -86,9 +82,7 @@ void LoginDialog::toggleAction() { } else { // change the menu item to login loginAction->setText("Login / Sign Up"); - connection = connect(loginAction, &QAction::triggered, [] { - LoginDialog::showWithSelection(); - }); + connection = connect(loginAction, &QAction::triggered, [] { LoginDialog::showWithSelection(); }); } } @@ -136,9 +130,8 @@ void LoginDialog::linkSteam() { payload.insert("steam_auth_ticket", QJsonValue::fromVariant(QVariant(ticket))); auto accountManager = DependencyManager::get(); - accountManager->sendRequest(LINK_STEAM_PATH, AccountManagerAuth::Required, - QNetworkAccessManager::PostOperation, callbackParams, - QJsonDocument(payload).toJson()); + accountManager->sendRequest(LINK_STEAM_PATH, AccountManagerAuth::Required, QNetworkAccessManager::PostOperation, + callbackParams, QJsonDocument(payload).toJson()); }); } } @@ -167,28 +160,24 @@ void LoginDialog::createAccountFromStream(QString username) { auto accountManager = DependencyManager::get(); accountManager->sendRequest(CREATE_ACCOUNT_FROM_STEAM_PATH, AccountManagerAuth::None, - QNetworkAccessManager::PostOperation, callbackParams, - QJsonDocument(payload).toJson()); + QNetworkAccessManager::PostOperation, callbackParams, QJsonDocument(payload).toJson()); }); } - } void LoginDialog::openUrl(const QString& url) const { - auto tablet = dynamic_cast(DependencyManager::get()->getTablet("com.highfidelity.interface.tablet.system")); + auto tablet = dynamic_cast( + DependencyManager::get()->getTablet("com.highfidelity.interface.tablet.system")); auto hmd = DependencyManager::get(); auto offscreenUi = DependencyManager::get(); if (tablet->getToolbarMode()) { - offscreenUi->load("Browser.qml", [=](QQmlContext* context, QObject* newObject) { - newObject->setProperty("url", url); - }); + offscreenUi->load("Browser.qml", [=](QQmlContext* context, QObject* newObject) { newObject->setProperty("url", url); }); LoginDialog::hide(); } else { if (!hmd->getShouldShowTablet() && !qApp->isHMDMode()) { - offscreenUi->load("Browser.qml", [=](QQmlContext* context, QObject* newObject) { - newObject->setProperty("url", url); - }); + offscreenUi->load("Browser.qml", + [=](QQmlContext* context, QObject* newObject) { newObject->setProperty("url", url); }); LoginDialog::hide(); } else { tablet->gotoWebScreen(url); @@ -213,28 +202,26 @@ void LoginDialog::createFailed(QNetworkReply* reply) { } void LoginDialog::signup(const QString& email, const QString& username, const QString& password) { - JSONCallbackParameters callbackParams; callbackParams.callbackReceiver = this; callbackParams.jsonCallbackMethod = "signupCompleted"; callbackParams.errorCallbackMethod = "signupFailed"; - + QJsonObject payload; - + QJsonObject userObject; userObject.insert("email", email); userObject.insert("username", username); userObject.insert("password", password); - + payload.insert("user", userObject); - + static const QString API_SIGNUP_PATH = "api/v1/users"; - + qDebug() << "Sending a request to create an account for" << username; - + auto accountManager = DependencyManager::get(); - accountManager->sendRequest(API_SIGNUP_PATH, AccountManagerAuth::None, - QNetworkAccessManager::PostOperation, callbackParams, + accountManager->sendRequest(API_SIGNUP_PATH, AccountManagerAuth::None, QNetworkAccessManager::PostOperation, callbackParams, QJsonDocument(payload).toJson()); } @@ -253,41 +240,38 @@ QString errorStringFromAPIObject(const QJsonValue& apiObject) { } void LoginDialog::signupFailed(QNetworkReply* reply) { - // parse the returned JSON to see what the problem was auto jsonResponse = QJsonDocument::fromJson(reply->readAll()); - + static const QString RESPONSE_DATA_KEY = "data"; - + auto dataJsonValue = jsonResponse.object()[RESPONSE_DATA_KEY]; - + if (dataJsonValue.isObject()) { auto dataObject = dataJsonValue.toObject(); - + static const QString EMAIL_DATA_KEY = "email"; static const QString USERNAME_DATA_KEY = "username"; static const QString PASSWORD_DATA_KEY = "password"; - + QStringList errorStringList; - + if (dataObject.contains(EMAIL_DATA_KEY)) { errorStringList.append(QString("Email %1.").arg(errorStringFromAPIObject(dataObject[EMAIL_DATA_KEY]))); } - + if (dataObject.contains(USERNAME_DATA_KEY)) { errorStringList.append(QString("Username %1.").arg(errorStringFromAPIObject(dataObject[USERNAME_DATA_KEY]))); } - + if (dataObject.contains(PASSWORD_DATA_KEY)) { errorStringList.append(QString("Password %1.").arg(errorStringFromAPIObject(dataObject[PASSWORD_DATA_KEY]))); } - + emit handleSignupFailed(errorStringList.join('\n')); } else { - static const QString DEFAULT_SIGN_UP_FAILURE_MESSAGE = "There was an unknown error while creating your account. Please try again later."; + static const QString DEFAULT_SIGN_UP_FAILURE_MESSAGE = + "There was an unknown error while creating your account. Please try again later."; emit handleSignupFailed(DEFAULT_SIGN_UP_FAILURE_MESSAGE); } - - } - From 9d7ba377ca72b99c900c159a758937139bdb5449 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 11 Sep 2018 09:42:53 -0700 Subject: [PATCH 29/34] removing logging for login dialog --- interface/src/ui/LoginDialog.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/interface/src/ui/LoginDialog.h b/interface/src/ui/LoginDialog.h index 155970e33d..717e089f3e 100644 --- a/interface/src/ui/LoginDialog.h +++ b/interface/src/ui/LoginDialog.h @@ -15,9 +15,6 @@ #define hifi_LoginDialog_h #include -#include - -Q_DECLARE_LOGGING_CATEGORY(login_dialog) class QNetworkReply; From aa62a89318d818513139ceecf8283e270380577a Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 11 Sep 2018 09:49:12 -0700 Subject: [PATCH 30/34] removing more logging for login dialog --- interface/src/ui/LoginDialog.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/interface/src/ui/LoginDialog.cpp b/interface/src/ui/LoginDialog.cpp index 0d574fdc5d..c1b9e5ccf3 100644 --- a/interface/src/ui/LoginDialog.cpp +++ b/interface/src/ui/LoginDialog.cpp @@ -30,7 +30,6 @@ #include "scripting/HMDScriptingInterface.h" HIFI_QML_DEF(LoginDialog) -Q_LOGGING_CATEGORY(login_dialog, "hifi.login.dialog") LoginDialog::LoginDialog(QQuickItem* parent) : OffscreenQmlDialog(parent) { auto accountManager = DependencyManager::get(); From 2a7e2af44ff17afe323edeb8a58c5f37c8270f3d Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 11 Sep 2018 10:36:10 -0700 Subject: [PATCH 31/34] syntax reversion + removing poppedUp var --- interface/src/ui/LoginDialog.cpp | 39 +++++++++++++++++++------------- interface/src/ui/LoginDialog.h | 3 --- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/interface/src/ui/LoginDialog.cpp b/interface/src/ui/LoginDialog.cpp index c1b9e5ccf3..d6f6eef58c 100644 --- a/interface/src/ui/LoginDialog.cpp +++ b/interface/src/ui/LoginDialog.cpp @@ -19,7 +19,6 @@ #include #include #include - #include #include "AccountManager.h" @@ -31,11 +30,13 @@ HIFI_QML_DEF(LoginDialog) -LoginDialog::LoginDialog(QQuickItem* parent) : OffscreenQmlDialog(parent) { +LoginDialog::LoginDialog(QQuickItem *parent) : OffscreenQmlDialog(parent) { auto accountManager = DependencyManager::get(); #if !defined(Q_OS_ANDROID) - connect(accountManager.data(), &AccountManager::loginComplete, this, &LoginDialog::handleLoginCompleted); - connect(accountManager.data(), &AccountManager::loginFailed, this, &LoginDialog::handleLoginFailed); + connect(accountManager.data(), &AccountManager::loginComplete, + this, &LoginDialog::handleLoginCompleted); + connect(accountManager.data(), &AccountManager::loginFailed, + this, &LoginDialog::handleLoginFailed); #endif } @@ -77,7 +78,9 @@ void LoginDialog::toggleAction() { if (accountManager->isLoggedIn()) { // change the menu item to logout loginAction->setText("Logout " + accountManager->getAccountInfo().getUsername()); - connection = connect(loginAction, &QAction::triggered, accountManager.data(), &AccountManager::logout); + connection = connect(loginAction, &QAction::triggered, [] { + LoginDialog::showWithSelection(); + }); } else { // change the menu item to login loginAction->setText("Login / Sign Up"); @@ -129,8 +132,9 @@ void LoginDialog::linkSteam() { payload.insert("steam_auth_ticket", QJsonValue::fromVariant(QVariant(ticket))); auto accountManager = DependencyManager::get(); - accountManager->sendRequest(LINK_STEAM_PATH, AccountManagerAuth::Required, QNetworkAccessManager::PostOperation, - callbackParams, QJsonDocument(payload).toJson()); + accountManager->sendRequest(LINK_STEAM_PATH, AccountManagerAuth::Required, + QNetworkAccessManager::PostOperation, callbackParams, + QJsonDocument(payload).toJson()); }); } } @@ -159,24 +163,27 @@ void LoginDialog::createAccountFromStream(QString username) { auto accountManager = DependencyManager::get(); accountManager->sendRequest(CREATE_ACCOUNT_FROM_STEAM_PATH, AccountManagerAuth::None, - QNetworkAccessManager::PostOperation, callbackParams, QJsonDocument(payload).toJson()); + QNetworkAccessManager::PostOperation, callbackParams, + QJsonDocument(payload).toJson()); }); } } void LoginDialog::openUrl(const QString& url) const { - auto tablet = dynamic_cast( - DependencyManager::get()->getTablet("com.highfidelity.interface.tablet.system")); + auto tablet = dynamic_cast(DependencyManager::get()->getTablet("com.highfidelity.interface.tablet.system")); auto hmd = DependencyManager::get(); auto offscreenUi = DependencyManager::get(); if (tablet->getToolbarMode()) { - offscreenUi->load("Browser.qml", [=](QQmlContext* context, QObject* newObject) { newObject->setProperty("url", url); }); + offscreenUi->load("Browser.qml", [=](QQmlContext* context, QObject* newObject) { + newObject->setProperty("url", url); + }); LoginDialog::hide(); } else { if (!hmd->getShouldShowTablet() && !qApp->isHMDMode()) { - offscreenUi->load("Browser.qml", - [=](QQmlContext* context, QObject* newObject) { newObject->setProperty("url", url); }); + offscreenUi->load("Browser.qml", [=](QQmlContext* context, QObject* newObject) { + newObject->setProperty("url", url); + }); LoginDialog::hide(); } else { tablet->gotoWebScreen(url); @@ -220,7 +227,8 @@ void LoginDialog::signup(const QString& email, const QString& username, const QS qDebug() << "Sending a request to create an account for" << username; auto accountManager = DependencyManager::get(); - accountManager->sendRequest(API_SIGNUP_PATH, AccountManagerAuth::None, QNetworkAccessManager::PostOperation, callbackParams, + accountManager->sendRequest(API_SIGNUP_PATH, AccountManagerAuth::None, + QNetworkAccessManager::PostOperation, callbackParams, QJsonDocument(payload).toJson()); } @@ -269,8 +277,7 @@ void LoginDialog::signupFailed(QNetworkReply* reply) { emit handleSignupFailed(errorStringList.join('\n')); } else { - static const QString DEFAULT_SIGN_UP_FAILURE_MESSAGE = - "There was an unknown error while creating your account. Please try again later."; + static const QString DEFAULT_SIGN_UP_FAILURE_MESSAGE = "There was an unknown error while creating your account. Please try again later."; emit handleSignupFailed(DEFAULT_SIGN_UP_FAILURE_MESSAGE); } } diff --git a/interface/src/ui/LoginDialog.h b/interface/src/ui/LoginDialog.h index 717e089f3e..b3f3d8a1a4 100644 --- a/interface/src/ui/LoginDialog.h +++ b/interface/src/ui/LoginDialog.h @@ -65,9 +65,6 @@ protected slots: Q_INVOKABLE void signup(const QString& email, const QString& username, const QString& password); Q_INVOKABLE void openUrl(const QString& url) const; - -private: - bool _poppedUp {false}; }; #endif // hifi_LoginDialog_h From e931b661a5ac2d4d213263b786609369c58e4162 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 11 Sep 2018 11:00:39 -0700 Subject: [PATCH 32/34] login dialog pops up in HMD again --- interface/src/Application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index c2bbc72e5b..bb315a4254 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2308,7 +2308,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo connect(checkLoginTimer, &QTimer::timeout, this, [this]() { auto accountManager = DependencyManager::get(); auto dialogsManager = DependencyManager::get(); - if (!accountManager->isLoggedIn() && !qApp->isHMDMode()) { + if (!accountManager->isLoggedIn()) { Setting::Handle{"loginDialogPoppedUp", false}.set(true); dialogsManager->showLoginDialog(); QJsonObject loginData = {}; From e7aef92e992af2541515353cab35174a2ef36eea Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 11 Sep 2018 12:51:51 -0700 Subject: [PATCH 33/34] fixing logout bug from syntax reversion --- interface/src/ui/LoginDialog.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/interface/src/ui/LoginDialog.cpp b/interface/src/ui/LoginDialog.cpp index d6f6eef58c..43da6ea863 100644 --- a/interface/src/ui/LoginDialog.cpp +++ b/interface/src/ui/LoginDialog.cpp @@ -78,9 +78,7 @@ void LoginDialog::toggleAction() { if (accountManager->isLoggedIn()) { // change the menu item to logout loginAction->setText("Logout " + accountManager->getAccountInfo().getUsername()); - connection = connect(loginAction, &QAction::triggered, [] { - LoginDialog::showWithSelection(); - }); + connection = connect(loginAction, &QAction::triggered, accountManager.data(), &AccountManager::logout); } else { // change the menu item to login loginAction->setText("Login / Sign Up"); From 9ee21c9956dc1cb53cc86f90602faccb9c569023 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 11 Sep 2018 16:49:11 -0700 Subject: [PATCH 34/34] removing `virtual` keyword from destructor --- interface/src/ui/LoginDialog.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/ui/LoginDialog.h b/interface/src/ui/LoginDialog.h index b3f3d8a1a4..ae069f9ab1 100644 --- a/interface/src/ui/LoginDialog.h +++ b/interface/src/ui/LoginDialog.h @@ -27,7 +27,7 @@ public: LoginDialog(QQuickItem* parent = nullptr); - virtual ~LoginDialog(); + ~LoginDialog(); static void showWithSelection();