From 1ded4b6fb83e4c0a4244568914bbcfd74785ba0c Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 6 Nov 2018 16:45:45 -0800 Subject: [PATCH] hiding previous username/hiding dev menu --- .../resources/qml/LoginDialog/SignInBody.qml | 36 +++++++++++-------- interface/src/Application.cpp | 27 ++++++-------- interface/src/Application.h | 5 ++- interface/src/main.cpp | 11 ------ libraries/ui/src/ui/Menu.cpp | 4 +++ libraries/ui/src/ui/Menu.h | 2 ++ 6 files changed, 39 insertions(+), 46 deletions(-) diff --git a/interface/resources/qml/LoginDialog/SignInBody.qml b/interface/resources/qml/LoginDialog/SignInBody.qml index 260836ffdb..b9083ec23b 100644 --- a/interface/resources/qml/LoginDialog/SignInBody.qml +++ b/interface/resources/qml/LoginDialog/SignInBody.qml @@ -87,7 +87,7 @@ Item { loginButtonAtSignIn.color = hifi.buttons.black; emailField.placeholderText = "Username or Email"; var savedUsername = Settings.getValue("keepMeLoggedIn/savedUsername", ""); - emailField.text = savedUsername === "Unknown user" ? "" : savedUsername; + emailField.text = keepMeLoggedInCheckbox.checked ? savedUsername === "Unknown user" ? "" : savedUsername : ""; emailField.anchors.top = loginContainer.top; emailField.anchors.topMargin = !root.isTablet ? 0.2 * root.height : 0.24 * root.height; cantAccessContainer.anchors.topMargin = !root.isTablet ? 3.5 * hifi.dimensions.contentSpacing.y : hifi.dimensions.contentSpacing.y; @@ -203,10 +203,12 @@ Item { case Qt.Key_Enter: case Qt.Key_Return: event.accepted = true; - if (loginDialog.isLogIn) { - Settings.setValue("keepMeLoggedIn/savedUsername", emailField.text); - } else { - Settings.setValue("keepMeLoggedIn/savedUsername", usernameField.text); + if (keepMeLoggedInCheckbox.checked) { + if (loginDialog.isLogIn) { + Settings.setValue("keepMeLoggedIn/savedUsername", emailField.text); + } else { + Settings.setValue("keepMeLoggedIn/savedUsername", usernameField.text); + } } signInBody.login(); break; @@ -249,10 +251,12 @@ Item { case Qt.Key_Enter: case Qt.Key_Return: event.accepted = true; - if (loginDialog.isLogIn) { - Settings.setValue("keepMeLoggedIn/savedUsername", emailField.text); - } else { - Settings.setValue("keepMeLoggedIn/savedUsername", usernameField.text); + if (keepMeLoggedInCheckbox.checked) { + if (loginDialog.isLogIn) { + Settings.setValue("keepMeLoggedIn/savedUsername", emailField.text); + } else { + Settings.setValue("keepMeLoggedIn/savedUsername", usernameField.text); + } } signInBody.login(); break; @@ -335,10 +339,12 @@ Item { case Qt.Key_Enter: case Qt.Key_Return: event.accepted = true; - if (loginDialog.isLogIn) { - Settings.setValue("keepMeLoggedIn/savedUsername", emailField.text); - } else { - Settings.setValue("keepMeLoggedIn/savedUsername", usernameField.text); + if (keepMeLoggedInCheckbox.checked) { + if (loginDialog.isLogIn) { + Settings.setValue("keepMeLoggedIn/savedUsername", emailField.text); + } else { + Settings.setValue("keepMeLoggedIn/savedUsername", usernameField.text); + } } signInBody.login(); break; @@ -346,7 +352,7 @@ Item { } } HifiControlsUit.CheckBox { - id: autoLogoutCheckbox + id: keepMeLoggedInCheckbox checked: Settings.getValue("keepMeLoggedIn", false); text: qsTr("Keep Me Logged In"); boxSize: 18; @@ -377,7 +383,7 @@ Item { width: cancelText.width height: d.minHeightButton anchors { - top: autoLogoutCheckbox.bottom + top: keepMeLoggedInCheckbox.bottom topMargin: hifi.dimensions.contentSpacing.y left: parent.left leftMargin: (parent.width - passwordField.width) / 2 diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ed1c2cb6f5..14822235f5 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1748,9 +1748,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo userInputMapper->registerDevice(_touchscreenVirtualPadDevice->getInputDevice()); } - QString scriptsSwitch = QString("--").append(SCRIPTS_SWITCH); - _defaultScriptsLocation = getCmdOption(argc, constArgv, scriptsSwitch.toStdString().c_str()); - // Make sure we don't time out during slow operations at startup updateHeartbeat(); @@ -5191,6 +5188,11 @@ void Application::pauseUntilLoginDetermined() { menu->getMenu("View")->setVisible(false); menu->getMenu("Navigate")->setVisible(false); menu->getMenu("Settings")->setVisible(false); + _developerMenuVisible = menu->getMenu("Developer")->isVisible(); + if (_developerMenuVisible) { + menu->getMenu("Developer")->setVisible(false); + } + } void Application::resumeAfterLoginDialogActionTaken() { @@ -5209,19 +5211,7 @@ void Application::resumeAfterLoginDialogActionTaken() { // this will force the model the look at the correct directory (weird order of operations issue) scriptEngines->reloadLocalFiles(); - // do this as late as possible so that all required subsystems are initialized - // If we've overridden the default scripts location, just load default scripts - // otherwise, load 'em all - - // we just want to see if --scripts was set, we've already parsed it and done - // the change in PathUtils. Rather than pass that in the constructor, lets just - // look (this could be debated) - if (!_defaultScriptsLocation.exists()) { - scriptEngines->loadDefaultScripts(); - scriptEngines->defaultScriptsLocationOverridden(true); - } else { - scriptEngines->loadScripts(); - } + scriptEngines->loadScripts(); } auto accountManager = DependencyManager::get(); @@ -5257,6 +5247,9 @@ void Application::resumeAfterLoginDialogActionTaken() { menu->getMenu("View")->setVisible(true); menu->getMenu("Navigate")->setVisible(true); menu->getMenu("Settings")->setVisible(true); + if (_developerMenuVisible) { + menu->getMenu("Developer")->setVisible(true); + } } void Application::loadAvatarScripts(const QVector& urls) { @@ -8499,6 +8492,7 @@ void Application::setShowBulletConstraintLimits(bool value) { void Application::checkReadyToCreateLoginDialogOverlay() { if (qApp->isHMDMode() && qApp->getActiveDisplayPlugin()->isDisplayVisible() && qApp->getLoginDialogPoppedUp() && _loginDialogOverlayID.isNull()) { createLoginDialogOverlay(); + _loginPointerManager.setUp(); } else if (qApp->getLoginDialogPoppedUp()) { if (!qApp->isHMDMode()) { _loginPointerManager.tearDown(); @@ -8528,7 +8522,6 @@ void Application::createLoginDialogOverlay() { { "visible", true } }; _loginDialogOverlayID = overlays.addOverlay("web3d", overlayProperties); - _loginPointerManager.setUp(); } void Application::onDismissedLoginDialog() { diff --git a/interface/src/Application.h b/interface/src/Application.h index 6a99eb14a9..c33511e25c 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -98,7 +98,6 @@ static const UINT UWM_SHOW_APPLICATION = #endif static const QString RUNNING_MARKER_FILENAME = "Interface.running"; -static const QString SCRIPTS_SWITCH = "scripts"; class Application; #if defined(qApp) @@ -664,8 +663,6 @@ private: QPointer _logDialog; QPointer _entityScriptServerLogDialog; - QDir _defaultScriptsLocation{""}; - FileLogger* _logger; TouchEvent _lastTouchEvent; @@ -688,6 +685,8 @@ private: bool _interstitialModeEnabled{ false }; bool _loginDialogPoppedUp = false; + // if visible before login popped up. + bool _developerMenuVisible{ false }; OverlayID _loginDialogOverlayID; LoginPointerManager _loginPointerManager; diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 5af0a9371d..0b02649c6e 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -72,7 +72,6 @@ int main(int argc, const char* argv[]) { QCommandLineOption serverContentPathOption("serverContentPath", "Where to find server content", "serverContentPath"); QCommandLineOption allowMultipleInstancesOption("allowMultipleInstances", "Allow multiple instances to run"); QCommandLineOption overrideAppLocalDataPathOption("cache", "set test cache ", "dir"); - QCommandLineOption overrideScriptsPathOption(SCRIPTS_SWITCH, "set scripts ", "path"); parser.addOption(urlOption); parser.addOption(noUpdaterOption); @@ -80,7 +79,6 @@ int main(int argc, const char* argv[]) { parser.addOption(runServerOption); parser.addOption(serverContentPathOption); parser.addOption(overrideAppLocalDataPathOption); - parser.addOption(overrideScriptsPathOption); parser.addOption(allowMultipleInstancesOption); if (!parser.parse(arguments)) { @@ -167,15 +165,6 @@ int main(int argc, const char* argv[]) { if (allowMultipleInstances) { instanceMightBeRunning = false; } - // this needs to be done here in main, as the mechanism for setting the - // scripts directory appears not to work. See the bug report - // https://highfidelity.fogbugz.com/f/cases/5759/Issues-changing-scripts-directory-in-ScriptsEngine - if (parser.isSet(overrideScriptsPathOption)) { - QDir scriptsPath(parser.value(overrideScriptsPathOption)); - if (scriptsPath.exists()) { - PathUtils::defaultScriptsLocation(scriptsPath.path()); - } - } if (instanceMightBeRunning) { // Try to connect and send message to existing interface instance diff --git a/libraries/ui/src/ui/Menu.cpp b/libraries/ui/src/ui/Menu.cpp index 3d22138f13..1668b3f690 100644 --- a/libraries/ui/src/ui/Menu.cpp +++ b/libraries/ui/src/ui/Menu.cpp @@ -550,6 +550,10 @@ void MenuWrapper::setEnabled(bool enabled) { _realMenu->setEnabled(enabled); } +bool MenuWrapper::isVisible() { + return _realMenu->menuAction()->isVisible(); +} + void MenuWrapper::setVisible(bool visible) { _realMenu->menuAction()->setVisible(visible); } diff --git a/libraries/ui/src/ui/Menu.h b/libraries/ui/src/ui/Menu.h index 98b5bd17e3..08d2d3fbad 100644 --- a/libraries/ui/src/ui/Menu.h +++ b/libraries/ui/src/ui/Menu.h @@ -29,6 +29,8 @@ public: QList actions(); MenuWrapper* addMenu(const QString& menuName); void setEnabled(bool enabled = true); + + bool isVisible(); void setVisible(bool visible = true); QAction* addSeparator(); void addAction(QAction* action);