From 1eb9a08c86b44300b48e861f91bfde6972af97c6 Mon Sep 17 00:00:00 2001 From: ziree Date: Mon, 7 Jan 2013 23:50:56 +0100 Subject: [PATCH] Added dialog notifications to the settings backup/restore function, more code commenting. FIRE-1723 --- indra/newview/llfloaterpreference.cpp | 35 ++++++++++++++++--- indra/newview/llfloaterpreference.h | 1 + .../skins/default/xui/en/notifications.xml | 28 +++++++++++++++ 3 files changed, 60 insertions(+), 4 deletions(-) diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 9eb87c0ab1..33fce646bb 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -3035,17 +3035,22 @@ void LLFloaterPreference::onClickSetBackupSettingsPath() void LLFloaterPreference::onClickBackupSettings() { - // get settings backup path + // Get settings backup path std::string dir_name=gSavedSettings.getString("SettingsBackupPath"); // If we don't have a path yet, ask the user if(dir_name.empty()) onClickSetBackupSettingsPath(); - // If we still don't have a path, do nothing + // Remember the backup path for next time dir_name=gSavedSettings.getString("SettingsBackupPath"); + + // if the backup path is still empty, complain to the user and do nothing else if(dir_name.empty()) + { + LLNotificationsUtil::add("BackupPathEmpty"); return; + } // get path and file names to the relevant settings files std::string userlower=gDirUtilp->getBaseFileName(gDirUtilp->getLindenUserDir(),false); @@ -3158,21 +3163,43 @@ void LLFloaterPreference::onClickBackupSettings() } } } + LLNotificationsUtil::add("BackupFinished"); } void LLFloaterPreference::onClickRestoreSettings() { - // close the window so the restored settings can't be destroyed by the user - onBtnOK(); + // ask the user if they really want to restore and restart + LLNotificationsUtil::add("SettingsRestoreNeedsLogout",LLSD(),LLSD(),boost::bind(&LLFloaterPreference::doRestoreSettings,this,_1,_2)); +} +void LLFloaterPreference:: doRestoreSettings(const LLSD& notification,const LLSD& response) +{ + // Check the user's answer about restore and restart + S32 option=LLNotificationsUtil::getSelectedOption(notification,response); + + // If canceled, do nothing + if(option==1) + return; + + // Get settings backup path std::string dir_name=gSavedSettings.getString("SettingsBackupPath"); + // Backup path is empty, ask the user where to find the backup if(dir_name.empty()) onClickSetBackupSettingsPath(); + // Remember the backup path for next time dir_name=gSavedSettings.getString("SettingsBackupPath"); + + // If the backup path is still empty, complain to the user and do nothing else if(dir_name.empty()) + { + LLNotificationsUtil::add("BackupPathEmpty"); return; + } + + // Close the window so the restored settings can't be destroyed by the user + onBtnOK(); // get path and file names to the relevant settings files std::string userlower=gDirUtilp->getBaseFileName(gDirUtilp->getLindenUserDir(),false); diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h index a127c54a35..f3ea3be145 100644 --- a/indra/newview/llfloaterpreference.h +++ b/indra/newview/llfloaterpreference.h @@ -202,6 +202,7 @@ public: void onClickSetBackupSettingsPath(); void onClickBackupSettings(); void onClickRestoreSettings(); + void doRestoreSettings(const LLSD& notification,const LLSD& response); // callback for restore dialog // private: static std::string sSkin; diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index cadf6a3099..d45549c69e 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -9396,4 +9396,32 @@ Error in the regular expression: text="No Havok Warning"/> + + + +Your settings have been backed up. + + + +The backup path is empty. Please provide a location to back up and restore your settings first. + + + +Settings restore requires a viewer restart. Do you want to restore your settings and quit the viewer now? + + + +