diff options
Diffstat (limited to 'indra/newview/llfloaterpreference.cpp')
-rw-r--r-- | indra/newview/llfloaterpreference.cpp | 98 |
1 files changed, 60 insertions, 38 deletions
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 4434a8013d..83c784c1f7 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -56,9 +56,12 @@ #include "llfloaterabout.h" #include "llfloaterhardwaresettings.h" #include "llfloatervoicedevicesettings.h" +#include "llimfloater.h" #include "llkeyboard.h" #include "llmodaldialog.h" #include "llnavigationbar.h" +#include "llnotifications.h" +#include "llnotificationsutil.h" #include "llpanellogin.h" #include "llradiogroup.h" #include "llsearchcombobox.h" @@ -164,7 +167,6 @@ BOOL LLVoiceSetKeyDialog::handleKeyHere(KEY key, MASK mask) { mParent->setKey(key); } - closeFloater(); return result; } @@ -203,7 +205,7 @@ viewer_media_t get_web_media() bool callback_clear_browser_cache(const LLSD& notification, const LLSD& response) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if ( option == 0 ) // YES { // clean web @@ -216,7 +218,7 @@ bool callback_clear_browser_cache(const LLSD& notification, const LLSD& response // flag client texture cache for clearing next time the client runs gSavedSettings.setBOOL("PurgeCacheOnNextStartup", TRUE); - LLNotifications::instance().add("CacheWillClear"); + LLNotificationsUtil::add("CacheWillClear"); LLSearchHistory::getInstance()->clearHistory(); LLSearchHistory::getInstance()->save(); @@ -241,7 +243,7 @@ void handleNameTagOptionChanged(const LLSD& newvalue) bool callback_skip_dialogs(const LLSD& notification, const LLSD& response, LLFloaterPreference* floater) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if (0 == option && floater ) { if ( floater ) @@ -256,7 +258,7 @@ bool callback_skip_dialogs(const LLSD& notification, const LLSD& response, LLFlo bool callback_reset_dialogs(const LLSD& notification, const LLSD& response, LLFloaterPreference* floater) { - S32 option = LLNotification::getSelectedOption(notification, response); + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if ( 0 == option && floater ) { if ( floater ) @@ -310,7 +312,8 @@ F32 LLFloaterPreference::sAspectRatio = 0.0; LLFloaterPreference::LLFloaterPreference(const LLSD& key) : LLFloater(key), mGotPersonalInfo(false), - mOriginalIMViaEmail(false) + mOriginalIMViaEmail(false), + mCancelOnClose(true) { //Build Floater is now Called from LLFloaterReg::add("preferences", "floater_preferences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreference>); @@ -338,7 +341,6 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key) mCommitCallbackRegistrar.add("Pref.ClickEnablePopup", boost::bind(&LLFloaterPreference::onClickEnablePopup, this)); mCommitCallbackRegistrar.add("Pref.ClickDisablePopup", boost::bind(&LLFloaterPreference::onClickDisablePopup, this)); mCommitCallbackRegistrar.add("Pref.LogPath", boost::bind(&LLFloaterPreference::onClickLogPath, this)); - mCommitCallbackRegistrar.add("Pref.Logging", boost::bind(&LLFloaterPreference::onCommitLogging, this)); mCommitCallbackRegistrar.add("Pref.UpdateMeterText", boost::bind(&LLFloaterPreference::updateMeterText, this, _1)); mCommitCallbackRegistrar.add("Pref.HardwareSettings", boost::bind(&LLFloaterPreference::onOpenHardwareSettings, this)); mCommitCallbackRegistrar.add("Pref.HardwareDefaults", boost::bind(&LLFloaterPreference::setHardwareDefaults, this)); @@ -358,6 +360,8 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key) BOOL LLFloaterPreference::postBuild() { + gSavedSettings.getControl("PlainTextChatHistory")->getSignal()->connect(boost::bind(&LLIMFloater::processChatHistoryStyleUpdate, _2)); + LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core"); if (!tabcontainer->selectTab(gSavedSettings.getS32("LastPrefTab"))) tabcontainer->selectFirstTab(); @@ -391,12 +395,26 @@ void LLFloaterPreference::draw() LLFloater::draw(); } +void LLFloaterPreference::saveSettings() +{ + LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core"); + child_list_t::const_iterator iter = tabcontainer->getChildList()->begin(); + child_list_t::const_iterator end = tabcontainer->getChildList()->end(); + for ( ; iter != end; ++iter) + { + LLView* view = *iter; + LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view); + if (panel) + panel->saveSettings(); + } +} + void LLFloaterPreference::apply() { LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core"); if (sSkin != gSavedSettings.getString("SkinCurrent")) { - LLNotifications::instance().add("ChangeSkin"); + LLNotificationsUtil::add("ChangeSkin"); refreshSkin(this); } // Call apply() on all panels that derive from LLPanelPreference @@ -445,6 +463,8 @@ void LLFloaterPreference::apply() // LLWString busy_response = utf8str_to_wstring(getChild<LLUICtrl>("busy_response")->getValue().asString()); // LLWStringUtil::replaceTabsWithSpaces(busy_response, 4); + + gSavedSettings.setBOOL("PlainTextChatHistory", childGetValue("plain_text_chat_history").asBoolean()); if(mGotPersonalInfo) { @@ -552,6 +572,11 @@ void LLFloaterPreference::onOpen(const LLSD& key) LLPanelLogin::setAlwaysRefresh(true); refresh(); + + // Make sure the current state of prefs are saved away when + // when the floater is opened. That will make cancel do its + // job + saveSettings(); } void LLFloaterPreference::onVertexShaderEnable() @@ -570,7 +595,7 @@ void LLFloaterPreference::onClose(bool app_quitting) { gSavedSettings.setS32("LastPrefTab", getChild<LLTabContainer>("pref core")->getCurrentPanelIndex()); LLPanelLogin::setAlwaysRefresh(false); - cancel(); // will be a no-op if OK or apply was performed just prior. + if (mCancelOnClose) cancel(); } void LLFloaterPreference::onOpenHardwareSettings() @@ -593,7 +618,11 @@ void LLFloaterPreference::onBtnOK() if (canClose()) { apply(); + // Here we do not want to cancel on close, so we do this funny thing + // that prevents cancel from undoing our changes when we hit OK + mCancelOnClose = false; closeFloater(false); + mCancelOnClose = true; gSavedSettings.saveToFile( gSavedSettings.getString("ClientSettingsFile"), TRUE ); LLUIColorTable::instance().saveUserSettings(); std::string crash_settings_filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, CRASH_SETTINGS_FILE); @@ -621,6 +650,7 @@ void LLFloaterPreference::onBtnApply( ) } } apply(); + saveSettings(); LLPanelLogin::refreshLocation( false ); } @@ -637,7 +667,8 @@ void LLFloaterPreference::onBtnCancel() } refresh(); } - closeFloater(); // side effect will also cancel any unsaved changes. + cancel(); + closeFloater(); } // static @@ -684,13 +715,13 @@ void LLFloaterPreference::onClickClearCache() { // flag client cache for clearing next time the client runs gSavedSettings.setBOOL("PurgeCacheOnNextStartup", TRUE); - LLNotifications::instance().add("CacheWillClear"); + LLNotificationsUtil::add("CacheWillClear"); } */ void LLFloaterPreference::onClickBrowserClearCache() { - LLNotifications::instance().add("ConfirmClearBrowserCache", LLSD(), LLSD(), callback_clear_browser_cache); + LLNotificationsUtil::add("ConfirmClearBrowserCache", LLSD(), LLSD(), callback_clear_browser_cache); } void LLFloaterPreference::onClickSetCache() @@ -710,7 +741,7 @@ void LLFloaterPreference::onClickSetCache() if (!dir_name.empty() && dir_name != cur_name) { std::string new_top_folder(gDirUtilp->getBaseFileName(dir_name)); - LLNotifications::instance().add("CacheWillBeMoved"); + LLNotificationsUtil::add("CacheWillBeMoved"); gSavedSettings.setString("NewCacheLocation", dir_name); gSavedSettings.setString("NewCacheLocationTopFolder", new_top_folder); } @@ -729,7 +760,7 @@ void LLFloaterPreference::onClickResetCache() { gSavedSettings.setString("NewCacheLocation", ""); gSavedSettings.setString("NewCacheLocationTopFolder", ""); - LLNotifications::instance().add("CacheWillBeMoved"); + LLNotificationsUtil::add("CacheWillBeMoved"); } std::string cache_location = gDirUtilp->getCacheDir(true); gSavedSettings.setString("CacheLocation", cache_location); @@ -1051,12 +1082,12 @@ void LLFloaterPreference::onClickSetMiddleMouse() void LLFloaterPreference::onClickSkipDialogs() { - LLNotifications::instance().add("SkipShowNextTimeDialogs", LLSD(), LLSD(), boost::bind(&callback_skip_dialogs, _1, _2, this)); + LLNotificationsUtil::add("SkipShowNextTimeDialogs", LLSD(), LLSD(), boost::bind(&callback_skip_dialogs, _1, _2, this)); } void LLFloaterPreference::onClickResetDialogs() { - LLNotifications::instance().add("ResetShowNextTimeDialogs", LLSD(), LLSD(), boost::bind(&callback_reset_dialogs, _1, _2, this)); + LLNotificationsUtil::add("ResetShowNextTimeDialogs", LLSD(), LLSD(), boost::bind(&callback_reset_dialogs, _1, _2, this)); } void LLFloaterPreference::onClickEnablePopup() @@ -1133,27 +1164,6 @@ void LLFloaterPreference::onClickLogPath() gSavedPerAccountSettings.setString("InstantMessageLogFolder",chat_log_top_folder); } -void LLFloaterPreference::onCommitLogging() -{ - enableHistory(); -} - -void LLFloaterPreference::enableHistory() -{ - if (childGetValue("log_instant_messages").asBoolean()) - { - childEnable("ChatIMLogs"); - childEnable("log_path_button"); - childEnable("show_timestamps_check_im"); - } - else - { - childDisable("ChatIMLogs"); - childDisable("log_path_button"); - childDisable("show_timestamps_check_im"); - } -} - void LLFloaterPreference::setPersonalInfo(const std::string& visibility, bool im_via_email, const std::string& email) { mGotPersonalInfo = true; @@ -1183,6 +1193,8 @@ void LLFloaterPreference::setPersonalInfo(const std::string& visibility, bool im childSetLabelArg("online_visibility", "[DIR_VIS]", mDirectoryVisibility); childEnable("send_im_to_email"); childSetValue("send_im_to_email", im_via_email); + childEnable("plain_text_chat_history"); + childSetValue("plain_text_chat_history", gSavedSettings.getBOOL("PlainTextChatHistory")); childEnable("log_instant_messages"); // childEnable("log_chat"); // childEnable("busy_response"); @@ -1193,7 +1205,12 @@ void LLFloaterPreference::setPersonalInfo(const std::string& visibility, bool im // childSetText("busy_response", gSavedSettings.getString("BusyModeResponse2")); - enableHistory(); + childEnable("log_nearby_chat"); + childEnable("log_instant_messages"); + childEnable("show_timestamps_check_im"); + childEnable("log_path_string"); + childEnable("log_path_button"); + std::string display_email(email); childSetText("email_address",display_email); @@ -1510,6 +1527,11 @@ BOOL LLPanelPreference::postBuild() void LLPanelPreference::apply() { + // no-op +} + +void LLPanelPreference::saveSettings() +{ // Save the value of all controls in the hierarchy mSavedValues.clear(); std::list<LLView*> view_stack; |