diff options
Diffstat (limited to 'indra/newview/llpanellogin.cpp')
| -rw-r--r-- | indra/newview/llpanellogin.cpp | 196 |
1 files changed, 123 insertions, 73 deletions
diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp index 0a585722f2..15cc8b421c 100644 --- a/indra/newview/llpanellogin.cpp +++ b/indra/newview/llpanellogin.cpp @@ -51,6 +51,7 @@ #include "llstartup.h" #include "lltextbox.h" #include "llui.h" +#include "llframetimer.h" #include "lluiconstants.h" #include "llslurl.h" #include "llversioninfo.h" @@ -177,6 +178,19 @@ public: }; LLLoginLocationAutoHandler gLoginLocationAutoHandler; +std::string getShortGridLabel(const std::string& slurl_grid) +{ + if (slurl_grid == MAINGRID) + { + return LLTrans::getString("AgniGridLabelShort"); + } + if (slurl_grid == BETAGRID) + { + return LLTrans::getString("AditiGridLabelShort"); + } + return LLGridManager::getInstance()->getGridLabel(slurl_grid); +} + //--------------------------------------------------------------------------- // Public methods //--------------------------------------------------------------------------- @@ -187,11 +201,11 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect, mCallback(callback), mCallbackData(cb_data), mListener(std::make_unique<LLPanelLoginListener>(this)), - mFirstLoginThisInstall(gSavedSettings.getBOOL("FirstLoginThisInstall")), mUsernameLength(0), mPasswordLength(0), mLocationLength(0), - mShowFavorites(false) + mShowFavorites(false), + mAlertNotif(false) { setBackgroundVisible(false); setBackgroundOpaque(true); @@ -206,15 +220,7 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect, login_holder->addChild(this); } - if (mFirstLoginThisInstall) - { - buildFromFile( "panel_login_first.xml"); - } - else - { - buildFromFile( "panel_login.xml"); - } - + buildFromFile( "panel_login.xml"); reshape(rect.getWidth(), rect.getHeight()); LLLineEditor* password_edit(getChild<LLLineEditor>("password_edit")); @@ -222,13 +228,20 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect, // STEAM-14: When user presses Enter with this field in focus, initiate login password_edit->setCommitCallback(boost::bind(&LLPanelLogin::onClickConnect, false)); + childSetAction("connect_btn", onClickConnect, this); + childSetAction("sign_btn", onClickSignUp, this); + + mLoginBtn = getChild<LLButton>("connect_btn"); + setDefaultBtn(mLoginBtn); + // change z sort of clickable text to be behind buttons sendChildToBack(getChildView("forgot_password_text")); - sendChildToBack(getChildView("sign_up_text")); + + mLoginStack = getChild<LLLayoutStack>("login_stack"); + mGridPanel = getChild<LLLayoutPanel>("grid_panel"); std::string current_grid = LLGridManager::getInstance()->getGrid(); - if (!mFirstLoginThisInstall) - { + LLComboBox* favorites_combo = getChild<LLComboBox>("start_location_combo"); updateLocationSelectorsVisibility(); // separate so that it can be called from preferences favorites_combo->setReturnCallback(boost::bind(&LLPanelLogin::onClickConnect, false)); @@ -248,17 +261,16 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect, if (!grid_choice->first.empty() && current_grid != grid_choice->first) { LL_DEBUGS("AppInit") << "adding " << grid_choice->first << LL_ENDL; - server_choice_combo->add(grid_choice->second, grid_choice->first); + server_choice_combo->add(getShortGridLabel(grid_choice->first), grid_choice->first); } } server_choice_combo->sortByName(); LL_DEBUGS("AppInit") << "adding current " << current_grid << LL_ENDL; - server_choice_combo->add(LLGridManager::getInstance()->getGridLabel(), + server_choice_combo->add(getShortGridLabel(current_grid), current_grid, ADD_TOP); server_choice_combo->selectFirstItem(); - } LLSLURL start_slurl(LLStartUp::getStartSLURL()); // The StartSLURL might have been set either by an explicit command-line @@ -298,11 +310,6 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect, onUpdateStartSLURL(start_slurl); // updates grid if needed } - childSetAction("connect_btn", onClickConnect, this); - - LLButton* def_btn = getChild<LLButton>("connect_btn"); - setDefaultBtn(def_btn); - std::string channel = LLVersionInfo::instance().getChannel(); std::string version = stringize(LLVersionInfo::instance().getShortVersion(), " (", LLVersionInfo::instance().getBuild(), ')'); @@ -310,12 +317,9 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect, LLTextBox* forgot_password_text = getChild<LLTextBox>("forgot_password_text"); forgot_password_text->setClickedCallback(onClickForgotPassword, NULL); - LLTextBox* sign_up_text = getChild<LLTextBox>("sign_up_text"); - sign_up_text->setClickedCallback(onClickSignUp, NULL); - // get the web browser control - LLMediaCtrl* web_browser = getChild<LLMediaCtrl>("login_html"); - web_browser->addObserver(this); + mWebBrowser = getChild<LLMediaCtrl>("login_html"); + mWebBrowser->addObserver(this); loadLoginPage(); @@ -330,19 +334,12 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect, LLCheckBoxCtrl* remember_name = getChild<LLCheckBoxCtrl>("remember_name"); remember_name->setCommitCallback(boost::bind(&LLPanelLogin::onRememberUserCheck, this)); getChild<LLCheckBoxCtrl>("remember_password")->setCommitCallback(boost::bind(&LLPanelLogin::onRememberPasswordCheck, this)); + + mAlertListener = LLNotifications::instance().getChannel("Alerts")->connectChanged([this](const LLSD& notify){ return onUpdateNotification(notify); }); } void LLPanelLogin::addFavoritesToStartLocation() { - if (mFirstLoginThisInstall) - { - // first login panel has no favorites, just update name length and buttons - std::string user_defined_name = getChild<LLComboBox>("username_combo")->getSimple(); - mUsernameLength = static_cast<unsigned int>(user_defined_name.length()); - updateLoginButtons(); - return; - } - // Clear the combo. LLComboBox* combo = getChild<LLComboBox>("start_location_combo"); if (!combo) return; @@ -412,7 +409,7 @@ void LLPanelLogin::addFavoritesToStartLocation() gSavedSettings.setBOOL("RememberPassword", save_password); if (!save_password) { - getChild<LLButton>("connect_btn")->setEnabled(false); + mLoginBtn->setEnabled(false); } update_password_setting = false; } @@ -562,16 +559,8 @@ void LLPanelLogin::resetFields() // function is used to reset list in case of changes by external sources return; } - if (sInstance->mFirstLoginThisInstall) - { - // no list to populate - LL_WARNS() << "Shouldn't happen, user should have no ability to modify list on first install" << LL_ENDL; - } - else - { - LLPointer<LLCredential> cred = gSecAPIHandler->loadCredential(LLGridManager::getInstance()->getGrid()); - sInstance->populateUserList(cred); - } + LLPointer<LLCredential> cred = gSecAPIHandler->loadCredential(LLGridManager::getInstance()->getGrid()); + sInstance->populateUserList(cred); } // static @@ -752,6 +741,11 @@ void LLPanelLogin::updateLocationSelectorsVisibility() { server_combo->setVisible(show_server); } + if (LLTextBox* grid_txt = sInstance->getChild<LLTextBox>("grid_text")) + { + grid_txt->setVisible(show_server); + } + sInstance->collapseGridPanel(!show_server); } } @@ -787,7 +781,7 @@ void LLPanelLogin::onUpdateStartSLURL(const LLSLURL& new_start_slurl) // update the grid selector to match the slurl LLComboBox* server_combo = sInstance->getChild<LLComboBox>("server_combo"); - std::string server_label(LLGridManager::getInstance()->getGridLabel(slurl_grid)); + std::string server_label(getShortGridLabel(slurl_grid)); server_combo->setSimple(server_label); updateServer(); // to change the links and splash screen @@ -860,11 +854,9 @@ void LLPanelLogin::setAlwaysRefresh(bool refresh) { if (sInstance && LLStartUp::getStartupState() < STATE_LOGIN_CLEANUP) { - LLMediaCtrl* web_browser = sInstance->getChild<LLMediaCtrl>("login_html"); - - if (web_browser) + if (sInstance->mWebBrowser) { - web_browser->setAlwaysRefresh(refresh); + sInstance->mWebBrowser->setAlwaysRefresh(refresh); } } } @@ -921,16 +913,35 @@ void LLPanelLogin::loadLoginPage() gViewerWindow->setMenuBackgroundColor(false, !LLGridManager::getInstance()->isInProductionGrid()); - LLMediaCtrl* web_browser = sInstance->getChild<LLMediaCtrl>("login_html"); - if (web_browser->getCurrentNavUrl() != login_uri.asString()) + if (sInstance->mWebBrowser) { - LL_DEBUGS("AppInit") << "loading: " << login_uri << LL_ENDL; - web_browser->navigateTo( login_uri.asString(), "text/html" ); + if (sInstance->mWebBrowser->getCurrentNavUrl() != login_uri.asString()) + { + LL_DEBUGS("AppInit") << "loading: " << login_uri << LL_ENDL; + sInstance->mWebBrowser->navigateTo(login_uri.asString(), "text/html"); + } + } + else + { + LL_WARNS("AppInit") << "No web browser control for login panel" << LL_ENDL; } } -void LLPanelLogin::handleMediaEvent(LLPluginClassMedia* /*self*/, EMediaEvent event) +void LLPanelLogin::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event) { + constexpr F32 REFRESH_DELAY = 2.f; + switch (event) + { + case MEDIA_EVENT_SIZE_CHANGED: + { + mForceRefreshTimer.reset(); + mForceRefreshTimer.setTimerExpirySec(REFRESH_DELAY); + mForceRefresh = true; + break; + } + default: + break; + } } //--------------------------------------------------------------------------- @@ -952,7 +963,7 @@ void LLPanelLogin::onClickConnect(bool commit_fields) } #endif - if (sInstance && sInstance->mCallback) + if (sInstance && sInstance->mCallback && !sInstance->mAlertNotif) { if (commit_fields) { @@ -1097,8 +1108,7 @@ void LLPanelLogin::onRememberUserCheck(void*) LLComboBox* user_combo(sInstance->getChild<LLComboBox>("username_combo")); bool remember = remember_name->getValue().asBoolean(); - if (!sInstance->mFirstLoginThisInstall - && user_combo->getCurrentIndex() != -1 + if (user_combo->getCurrentIndex() != -1 && !remember) { remember = true; @@ -1209,21 +1219,16 @@ void LLPanelLogin::updateServer() void LLPanelLogin::updateLoginButtons() { - LLButton* login_btn = getChild<LLButton>("connect_btn"); + mLoginBtn->setEnabled(mUsernameLength != 0 && mPasswordLength != 0 && !mAlertNotif); - login_btn->setEnabled(mUsernameLength != 0 && mPasswordLength != 0); - - if (!mFirstLoginThisInstall) + LLComboBox* user_combo = getChild<LLComboBox>("username_combo"); + LLCheckBoxCtrl* remember_name = getChild<LLCheckBoxCtrl>("remember_name"); + if (user_combo->getCurrentIndex() != -1) { - LLComboBox* user_combo = getChild<LLComboBox>("username_combo"); - LLCheckBoxCtrl* remember_name = getChild<LLCheckBoxCtrl>("remember_name"); - if (user_combo->getCurrentIndex() != -1) - { - remember_name->setValue(true); - LLCheckBoxCtrl* remember_pass = getChild<LLCheckBoxCtrl>("remember_password"); - remember_pass->setEnabled(true); - } // Note: might be good idea to do "else remember_name->setValue(mRememberedState)" but it might behave 'weird' to user - } + remember_name->setValue(true); + LLCheckBoxCtrl* remember_pass = getChild<LLCheckBoxCtrl>("remember_password"); + remember_pass->setEnabled(true); + } // Note: might be good idea to do "else remember_name->setValue(mRememberedState)" but it might behave 'weird' to user } void LLPanelLogin::populateUserList(LLPointer<LLCredential> credential) @@ -1383,3 +1388,48 @@ std::string LLPanelLogin::getUserName(LLPointer<LLCredential> &cred) return "unknown"; } +bool LLPanelLogin::onUpdateNotification(const LLSD& notify) +{ + // disable Login button while alert notification is displayed + LLNotificationPtr notifyp = LLNotifications::instance().find(notify["id"].asUUID()); + if (notifyp && notifyp->getName() == "PromptOptionalUpdate") + { + std::string sigtype = notify["sigtype"].asString(); + if (sigtype == "add") + { + mAlertNotif = true; + } + else if (sigtype == "delete") + { + mAlertNotif = false; + } + updateLoginButtons(); + } + return false; +} + +void LLPanelLogin::collapseGridPanel(bool collapse) +{ + if (mGridPanel->isCollapsed() == collapse) + { + return; + } + mLoginStack->collapsePanel(mGridPanel, collapse); + mLoginStack->updateLayout(); +} + +void LLPanelLogin::draw() +{ + LLPanel::draw(); + + // Workaround for the black screen issue (see #5607) + // Should be removed after the proper fix for resizing is implemented + if (mForceRefresh && mForceRefreshTimer.hasExpired()) + { + if (mWebBrowser->getMediaPlugin()) + { + mWebBrowser->getMediaPlugin()->forceRenderRefresh(); + } + mForceRefresh = false; + } +} |
