Annotation of /trunk/indra/newview/hbprefscool.cpp
Parent Directory
|
Revision Log
Revision 138 - (view) (download)
| 1 : | mjm | 135 | /** |
| 2 : | * @file hbprefscool.cpp | ||
| 3 : | * @author Henri Beauchamp | ||
| 4 : | * @brief Cool SL Viewer preferences panel | ||
| 5 : | * | ||
| 6 : | * $LicenseInfo:firstyear=2008&license=viewergpl$ | ||
| 7 : | * | ||
| 8 : | * Copyright (c) 2008, Henri Beauchamp. | ||
| 9 : | * | ||
| 10 : | * Second Life Viewer Source Code | ||
| 11 : | * The source code in this file ("Source Code") is provided by Linden Lab | ||
| 12 : | * to you under the terms of the GNU General Public License, version 2.0 | ||
| 13 : | * ("GPL"), unless you have obtained a separate licensing agreement | ||
| 14 : | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
| 15 : | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
| 16 : | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
| 17 : | * | ||
| 18 : | * There are special exceptions to the terms and conditions of the GPL as | ||
| 19 : | * it is applied to this Source Code. View the full text of the exception | ||
| 20 : | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
| 21 : | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
| 22 : | * | ||
| 23 : | * By copying, modifying or distributing this software, you acknowledge | ||
| 24 : | * that you have read and understood your obligations described above, | ||
| 25 : | * and agree to abide by those obligations. | ||
| 26 : | * | ||
| 27 : | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
| 28 : | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
| 29 : | * COMPLETENESS OR PERFORMANCE. | ||
| 30 : | * $/LicenseInfo$ | ||
| 31 : | */ | ||
| 32 : | |||
| 33 : | #include "llviewerprecompiledheaders.h" | ||
| 34 : | |||
| 35 : | #include "hbprefscool.h" | ||
| 36 : | |||
| 37 : | #include "llstartup.h" | ||
| 38 : | #include "llviewercontrol.h" | ||
| 39 : | #include "lluictrlfactory.h" | ||
| 40 : | #include "llcombobox.h" | ||
| 41 : | |||
| 42 : | class HippoPrefsImpl : public LLPanel | ||
| 43 : | { | ||
| 44 : | public: | ||
| 45 : | HippoPrefsImpl(); | ||
| 46 : | /*virtual*/ ~HippoPrefsImpl() { }; | ||
| 47 : | |||
| 48 : | virtual void refresh(); | ||
| 49 : | |||
| 50 : | void apply(); | ||
| 51 : | void cancel(); | ||
| 52 : | |||
| 53 : | private: | ||
| 54 : | static void onCommitCheckBox(LLUICtrl* ctrl, void* user_data); | ||
| 55 : | void refreshValues(); | ||
| 56 : | BOOL mShowGrids; | ||
| 57 : | BOOL mSaveScriptsAsMono; | ||
| 58 : | BOOL mDoubleClickTeleport; | ||
| 59 : | BOOL mHideNotificationsInChat; | ||
| 60 : | BOOL mDisableMessagesSpacing; | ||
| 61 : | BOOL mHideMasterRemote; | ||
| 62 : | BOOL mShowGroupsButton; | ||
| 63 : | BOOL mUseOldChatHistory; | ||
| 64 : | BOOL mUseOldStatusBarIcons; | ||
| 65 : | BOOL mUseOldTrackingDots; | ||
| 66 : | BOOL mAllowMUpose; | ||
| 67 : | BOOL mAutoCloseOOC; | ||
| 68 : | BOOL mPlayTypingSound; | ||
| 69 : | BOOL mPrivateLookAt; | ||
| 70 : | BOOL mFetchInventoryOnLogin; | ||
| 71 : | mjm | 138 | BOOL mRestrainedLove; |
| 72 : | mjm | 135 | BOOL mSecondsInChatAndIMs; |
| 73 : | BOOL mPreviewAnimInWorld; | ||
| 74 : | BOOL mSpeedRez; | ||
| 75 : | BOOL mRevokePermsOnStandUp; | ||
| 76 : | mjm | 138 | BOOL mRezWithLandGroup; |
| 77 : | mjm | 135 | U32 mSpeedRezInterval; |
| 78 : | U32 mDecimalsForTools; | ||
| 79 : | U32 mLinksForChattingObjects; | ||
| 80 : | U32 mTimeFormat; | ||
| 81 : | U32 mDateFormat; | ||
| 82 : | }; | ||
| 83 : | |||
| 84 : | |||
| 85 : | HippoPrefsImpl::HippoPrefsImpl() | ||
| 86 : | : LLPanel("Hippo Prefs Panel") | ||
| 87 : | { | ||
| 88 : | LLUICtrlFactory::getInstance()->buildPanel(this, "panel_preferences_cool.xml"); | ||
| 89 : | childSetCommitCallback("restrained_life_check", onCommitCheckBox, this); | ||
| 90 : | childSetCommitCallback("speed_rez_check", onCommitCheckBox, this); | ||
| 91 : | refresh(); | ||
| 92 : | } | ||
| 93 : | |||
| 94 : | //static | ||
| 95 : | void HippoPrefsImpl::onCommitCheckBox(LLUICtrl* ctrl, void* user_data) | ||
| 96 : | { | ||
| 97 : | HippoPrefsImpl* self = (HippoPrefsImpl*)user_data; | ||
| 98 : | |||
| 99 : | if (self->childGetValue("restrained_life_check").asBoolean()) | ||
| 100 : | { | ||
| 101 : | gSavedSettings.setBOOL("FetchInventoryOnLogin", TRUE); | ||
| 102 : | self->childSetValue("fetch_inventory_on_login_check", TRUE); | ||
| 103 : | self->childDisable("fetch_inventory_on_login_check"); | ||
| 104 : | } | ||
| 105 : | else | ||
| 106 : | { | ||
| 107 : | self->childEnable("fetch_inventory_on_login_check"); | ||
| 108 : | } | ||
| 109 : | |||
| 110 : | if (self->childGetValue("speed_rez_check").asBoolean()) | ||
| 111 : | { | ||
| 112 : | self->childEnable("speed_rez_interval"); | ||
| 113 : | self->childEnable("speed_rez_seconds"); | ||
| 114 : | } | ||
| 115 : | else | ||
| 116 : | { | ||
| 117 : | self->childDisable("speed_rez_interval"); | ||
| 118 : | self->childDisable("speed_rez_seconds"); | ||
| 119 : | } | ||
| 120 : | } | ||
| 121 : | |||
| 122 : | void HippoPrefsImpl::refreshValues() | ||
| 123 : | { | ||
| 124 : | mSaveScriptsAsMono = gSavedSettings.getBOOL("SaveScriptsAsMono"); | ||
| 125 : | mDoubleClickTeleport = gSavedSettings.getBOOL("DoubleClickTeleport"); | ||
| 126 : | mHideNotificationsInChat = gSavedSettings.getBOOL("HideNotificationsInChat"); | ||
| 127 : | mDisableMessagesSpacing = gSavedSettings.getBOOL("DisableMessagesSpacing"); | ||
| 128 : | mHideMasterRemote = gSavedSettings.getBOOL("HideMasterRemote"); | ||
| 129 : | mShowGroupsButton = gSavedSettings.getBOOL("ShowGroupsButton"); | ||
| 130 : | mUseOldChatHistory = gSavedSettings.getBOOL("UseOldChatHistory"); | ||
| 131 : | mUseOldStatusBarIcons = gSavedSettings.getBOOL("UseOldStatusBarIcons"); | ||
| 132 : | mUseOldTrackingDots = gSavedSettings.getBOOL("UseOldTrackingDots"); | ||
| 133 : | mAllowMUpose = gSavedSettings.getBOOL("AllowMUpose"); | ||
| 134 : | mAutoCloseOOC = gSavedSettings.getBOOL("AutoCloseOOC"); | ||
| 135 : | mPlayTypingSound = gSavedSettings.getBOOL("PlayTypingSound"); | ||
| 136 : | mPrivateLookAt = gSavedSettings.getBOOL("PrivateLookAt"); | ||
| 137 : | mSecondsInChatAndIMs = gSavedSettings.getBOOL("SecondsInChatAndIMs"); | ||
| 138 : | mjm | 138 | mRestrainedLove = gSavedSettings.getBOOL("RestrainedLove"); |
| 139 : | if (mRestrainedLove) | ||
| 140 : | mjm | 135 | { |
| 141 : | mFetchInventoryOnLogin = TRUE; | ||
| 142 : | gSavedSettings.setBOOL("FetchInventoryOnLogin", TRUE); | ||
| 143 : | } | ||
| 144 : | else | ||
| 145 : | { | ||
| 146 : | mFetchInventoryOnLogin = gSavedSettings.getBOOL("FetchInventoryOnLogin"); | ||
| 147 : | } | ||
| 148 : | mPreviewAnimInWorld = gSavedSettings.getBOOL("PreviewAnimInWorld"); | ||
| 149 : | mSpeedRez = gSavedSettings.getBOOL("SpeedRez"); | ||
| 150 : | mSpeedRezInterval = gSavedSettings.getU32("SpeedRezInterval"); | ||
| 151 : | mDecimalsForTools = gSavedSettings.getU32("DecimalsForTools"); | ||
| 152 : | mLinksForChattingObjects = gSavedSettings.getU32("LinksForChattingObjects"); | ||
| 153 : | mRevokePermsOnStandUp = gSavedSettings.getBOOL("RevokePermsOnStandUp"); | ||
| 154 : | mjm | 138 | mRezWithLandGroup = gSavedSettings.getBOOL("RezWithLandGroup"); |
| 155 : | mjm | 135 | } |
| 156 : | |||
| 157 : | void HippoPrefsImpl::refresh() | ||
| 158 : | { | ||
| 159 : | refreshValues(); | ||
| 160 : | |||
| 161 : | if (LLStartUp::getStartupState() != STATE_STARTED) | ||
| 162 : | { | ||
| 163 : | childDisable("restrained_life_check"); | ||
| 164 : | } | ||
| 165 : | |||
| 166 : | mjm | 138 | if (mRestrainedLove) |
| 167 : | mjm | 135 | { |
| 168 : | childSetValue("fetch_inventory_on_login_check", TRUE); | ||
| 169 : | childDisable("fetch_inventory_on_login_check"); | ||
| 170 : | } | ||
| 171 : | else | ||
| 172 : | { | ||
| 173 : | childEnable("fetch_inventory_on_login_check"); | ||
| 174 : | } | ||
| 175 : | |||
| 176 : | if (mSpeedRez) | ||
| 177 : | { | ||
| 178 : | childEnable("speed_rez_interval"); | ||
| 179 : | childEnable("speed_rez_seconds"); | ||
| 180 : | } | ||
| 181 : | else | ||
| 182 : | { | ||
| 183 : | childDisable("speed_rez_interval"); | ||
| 184 : | childDisable("speed_rez_seconds"); | ||
| 185 : | } | ||
| 186 : | |||
| 187 : | std::string format = gSavedSettings.getString("ShortTimeFormat"); | ||
| 188 : | if (format.find("%p") == -1) | ||
| 189 : | { | ||
| 190 : | mTimeFormat = 0; | ||
| 191 : | } | ||
| 192 : | else | ||
| 193 : | { | ||
| 194 : | mTimeFormat = 1; | ||
| 195 : | } | ||
| 196 : | |||
| 197 : | format = gSavedSettings.getString("ShortDateFormat"); | ||
| 198 : | if (format.find("%m/%d/%") != -1) | ||
| 199 : | { | ||
| 200 : | mDateFormat = 2; | ||
| 201 : | } | ||
| 202 : | else if (format.find("%d/%m/%") != -1) | ||
| 203 : | { | ||
| 204 : | mDateFormat = 1; | ||
| 205 : | } | ||
| 206 : | else | ||
| 207 : | { | ||
| 208 : | mDateFormat = 0; | ||
| 209 : | } | ||
| 210 : | |||
| 211 : | // time format combobox | ||
| 212 : | LLComboBox* combo = getChild<LLComboBox>("time_format_combobox"); | ||
| 213 : | if (combo) | ||
| 214 : | { | ||
| 215 : | combo->setCurrentByIndex(mTimeFormat); | ||
| 216 : | } | ||
| 217 : | |||
| 218 : | // date format combobox | ||
| 219 : | combo = getChild<LLComboBox>("date_format_combobox"); | ||
| 220 : | if (combo) | ||
| 221 : | { | ||
| 222 : | combo->setCurrentByIndex(mDateFormat); | ||
| 223 : | } | ||
| 224 : | } | ||
| 225 : | |||
| 226 : | void HippoPrefsImpl::cancel() | ||
| 227 : | { | ||
| 228 : | gSavedSettings.setBOOL("SaveScriptsAsMono", mSaveScriptsAsMono); | ||
| 229 : | gSavedSettings.setBOOL("DoubleClickTeleport", mDoubleClickTeleport); | ||
| 230 : | gSavedSettings.setBOOL("HideNotificationsInChat", mHideNotificationsInChat); | ||
| 231 : | gSavedSettings.setBOOL("DisableMessagesSpacing", mDisableMessagesSpacing); | ||
| 232 : | gSavedSettings.setBOOL("HideMasterRemote", mHideMasterRemote); | ||
| 233 : | gSavedSettings.setBOOL("ShowGroupsButton", mShowGroupsButton); | ||
| 234 : | gSavedSettings.setBOOL("UseOldChatHistory", mUseOldChatHistory); | ||
| 235 : | gSavedSettings.setBOOL("UseOldStatusBarIcons", mUseOldStatusBarIcons); | ||
| 236 : | gSavedSettings.setBOOL("UseOldTrackingDots", mUseOldTrackingDots); | ||
| 237 : | gSavedSettings.setBOOL("AllowMUpose", mAllowMUpose); | ||
| 238 : | gSavedSettings.setBOOL("AutoCloseOOC", mAutoCloseOOC); | ||
| 239 : | gSavedSettings.setBOOL("PlayTypingSound", mPlayTypingSound); | ||
| 240 : | gSavedSettings.setBOOL("PrivateLookAt", mPrivateLookAt); | ||
| 241 : | gSavedSettings.setBOOL("FetchInventoryOnLogin", mFetchInventoryOnLogin); | ||
| 242 : | mjm | 138 | gSavedSettings.setBOOL("RestrainedLove", mRestrainedLove); |
| 243 : | mjm | 135 | gSavedSettings.setBOOL("SecondsInChatAndIMs", mSecondsInChatAndIMs); |
| 244 : | gSavedSettings.setBOOL("PreviewAnimInWorld", mPreviewAnimInWorld); | ||
| 245 : | gSavedSettings.setBOOL("SpeedRez", mSpeedRez); | ||
| 246 : | gSavedSettings.setU32("SpeedRezInterval", mSpeedRezInterval); | ||
| 247 : | gSavedSettings.setU32("DecimalsForTools", mDecimalsForTools); | ||
| 248 : | gSavedSettings.setU32("LinksForChattingObjects", mLinksForChattingObjects); | ||
| 249 : | gSavedSettings.setBOOL("RevokePermsOnStandUp", mRevokePermsOnStandUp); | ||
| 250 : | mjm | 138 | gSavedSettings.setBOOL("RezWithLandGroup", mRezWithLandGroup); |
| 251 : | mjm | 135 | } |
| 252 : | |||
| 253 : | void HippoPrefsImpl::apply() | ||
| 254 : | { | ||
| 255 : | std::string short_date, long_date, short_time, long_time, timestamp; | ||
| 256 : | |||
| 257 : | LLComboBox* combo = getChild<LLComboBox>("time_format_combobox"); | ||
| 258 : | if (combo) { | ||
| 259 : | mTimeFormat = combo->getCurrentIndex(); | ||
| 260 : | } | ||
| 261 : | |||
| 262 : | combo = getChild<LLComboBox>("date_format_combobox"); | ||
| 263 : | if (combo) | ||
| 264 : | { | ||
| 265 : | mDateFormat = combo->getCurrentIndex(); | ||
| 266 : | } | ||
| 267 : | |||
| 268 : | if (mTimeFormat == 0) | ||
| 269 : | { | ||
| 270 : | short_time = "%H:%M"; | ||
| 271 : | long_time = "%H:%M:%S"; | ||
| 272 : | timestamp = " %H:%M:%S"; | ||
| 273 : | } | ||
| 274 : | else | ||
| 275 : | { | ||
| 276 : | short_time = "%I:%M %p"; | ||
| 277 : | long_time = "%I:%M:%S %p"; | ||
| 278 : | timestamp = " %I:%M %p"; | ||
| 279 : | } | ||
| 280 : | |||
| 281 : | if (mDateFormat == 0) | ||
| 282 : | { | ||
| 283 : | short_date = "%Y-%m-%d"; | ||
| 284 : | long_date = "%A %d %B %Y"; | ||
| 285 : | timestamp = "%a %d %b %Y" + timestamp; | ||
| 286 : | } | ||
| 287 : | else if (mDateFormat == 1) | ||
| 288 : | { | ||
| 289 : | short_date = "%d/%m/%Y"; | ||
| 290 : | long_date = "%A %d %B %Y"; | ||
| 291 : | timestamp = "%a %d %b %Y" + timestamp; | ||
| 292 : | } | ||
| 293 : | else | ||
| 294 : | { | ||
| 295 : | short_date = "%m/%d/%Y"; | ||
| 296 : | long_date = "%A, %B %d %Y"; | ||
| 297 : | timestamp = "%a %b %d %Y" + timestamp; | ||
| 298 : | } | ||
| 299 : | |||
| 300 : | gSavedSettings.setString("ShortDateFormat", short_date); | ||
| 301 : | gSavedSettings.setString("LongDateFormat", long_date); | ||
| 302 : | gSavedSettings.setString("ShortTimeFormat", short_time); | ||
| 303 : | gSavedSettings.setString("LongTimeFormat", long_time); | ||
| 304 : | gSavedSettings.setString("TimestampFormat", timestamp); | ||
| 305 : | |||
| 306 : | refreshValues(); | ||
| 307 : | } | ||
| 308 : | |||
| 309 : | //--------------------------------------------------------------------------- | ||
| 310 : | |||
| 311 : | HippoPrefs::HippoPrefs() | ||
| 312 : | : impl(* new HippoPrefsImpl()) | ||
| 313 : | { | ||
| 314 : | } | ||
| 315 : | |||
| 316 : | HippoPrefs::~HippoPrefs() | ||
| 317 : | { | ||
| 318 : | delete &impl; | ||
| 319 : | } | ||
| 320 : | |||
| 321 : | void HippoPrefs::apply() | ||
| 322 : | { | ||
| 323 : | impl.apply(); | ||
| 324 : | } | ||
| 325 : | |||
| 326 : | void HippoPrefs::cancel() | ||
| 327 : | { | ||
| 328 : | impl.cancel(); | ||
| 329 : | } | ||
| 330 : | |||
| 331 : | LLPanel* HippoPrefs::getPanel() | ||
| 332 : | { | ||
| 333 : | return &impl; | ||
| 334 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

