diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llfloaterpreference.cpp | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/llfloaterpreference.cpp')
-rw-r--r-- | linden/indra/newview/llfloaterpreference.cpp | 384 |
1 files changed, 384 insertions, 0 deletions
diff --git a/linden/indra/newview/llfloaterpreference.cpp b/linden/indra/newview/llfloaterpreference.cpp new file mode 100644 index 0000000..5dbfc78 --- /dev/null +++ b/linden/indra/newview/llfloaterpreference.cpp | |||
@@ -0,0 +1,384 @@ | |||
1 | /** | ||
2 | * @file llfloaterpreference.cpp | ||
3 | * @brief LLPreferenceCore class implementation | ||
4 | * | ||
5 | * Copyright (c) 2002-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | /* | ||
29 | * App-wide preferences. Note that these are not per-user, | ||
30 | * because we need to load many preferences before we have | ||
31 | * a login name. | ||
32 | */ | ||
33 | |||
34 | #include "llviewerprecompiledheaders.h" | ||
35 | |||
36 | #include "llfloaterpreference.h" | ||
37 | |||
38 | #include "llbutton.h" | ||
39 | #include "llcheckboxctrl.h" | ||
40 | #include "lldir.h" | ||
41 | #include "llfocusmgr.h" | ||
42 | #include "llscrollbar.h" | ||
43 | #include "llspinctrl.h" | ||
44 | #include "message.h" | ||
45 | |||
46 | #include "llfloaterabout.h" | ||
47 | #include "llpanelnetwork.h" | ||
48 | #include "llpanelaudioprefs.h" | ||
49 | #include "llpaneldisplay.h" | ||
50 | #include "llpaneldebug.h" | ||
51 | #include "llpanelgeneral.h" | ||
52 | #include "llpanelinput.h" | ||
53 | #include "llpanelmsgs.h" | ||
54 | //#include "llpanelweb.h" | ||
55 | #include "llprefschat.h" | ||
56 | #include "llprefsim.h" | ||
57 | #include "llresizehandle.h" | ||
58 | #include "llresmgr.h" | ||
59 | #include "llassetstorage.h" | ||
60 | #include "llagent.h" | ||
61 | #include "llviewercontrol.h" | ||
62 | #include "llviewernetwork.h" | ||
63 | #include "llvieweruictrlfactory.h" | ||
64 | #include "llviewerwindow.h" | ||
65 | //#include "viewer.h" | ||
66 | #include "llkeyboard.h" | ||
67 | #include "llscrollcontainer.h" | ||
68 | |||
69 | |||
70 | const S32 PREF_BORDER = 4; | ||
71 | const S32 PREF_PAD = 5; | ||
72 | const S32 PREF_BUTTON_WIDTH = 70; | ||
73 | const S32 PREF_CATEGORY_WIDTH = 150; | ||
74 | |||
75 | const S32 PREF_FLOATER_MIN_HEIGHT = 2 * SCROLLBAR_SIZE + 2 * LLPANEL_BORDER_WIDTH + 96; | ||
76 | |||
77 | LLFloaterPreference* LLFloaterPreference::sInstance = NULL; | ||
78 | |||
79 | // Must be done at run time, not compile time. JC | ||
80 | S32 pref_min_width() | ||
81 | { | ||
82 | return | ||
83 | 2 * PREF_BORDER + | ||
84 | 2 * PREF_BUTTON_WIDTH + | ||
85 | PREF_PAD + RESIZE_HANDLE_WIDTH + | ||
86 | PREF_CATEGORY_WIDTH + | ||
87 | PREF_PAD; | ||
88 | } | ||
89 | |||
90 | S32 pref_min_height() | ||
91 | { | ||
92 | return | ||
93 | 2 * PREF_BORDER + | ||
94 | 3*(BTN_HEIGHT + PREF_PAD) + | ||
95 | PREF_FLOATER_MIN_HEIGHT; | ||
96 | } | ||
97 | |||
98 | |||
99 | LLPreferenceCore::LLPreferenceCore(LLTabContainerCommon* tab_container, LLButton * default_btn) : | ||
100 | mTabContainer(tab_container), | ||
101 | mGeneralPanel(NULL), | ||
102 | mInputPanel(NULL), | ||
103 | mNetworkPanel(NULL), | ||
104 | mDisplayPanel(NULL), | ||
105 | mDisplayPanel2(NULL), | ||
106 | mAudioPanel(NULL), | ||
107 | mMsgPanel(NULL) | ||
108 | { | ||
109 | mGeneralPanel = new LLPanelGeneral(); | ||
110 | mTabContainer->addTabPanel(mGeneralPanel, mGeneralPanel->getLabel(), FALSE, onTabChanged, mTabContainer); | ||
111 | mGeneralPanel->setDefaultBtn(default_btn); | ||
112 | |||
113 | mInputPanel = new LLPanelInput(); | ||
114 | mTabContainer->addTabPanel(mInputPanel, mInputPanel->getLabel(), FALSE, onTabChanged, mTabContainer); | ||
115 | mInputPanel->setDefaultBtn(default_btn); | ||
116 | |||
117 | mNetworkPanel = new LLPanelNetwork(); | ||
118 | mTabContainer->addTabPanel(mNetworkPanel, mNetworkPanel->getLabel(), FALSE, onTabChanged, mTabContainer); | ||
119 | mNetworkPanel->setDefaultBtn(default_btn); | ||
120 | |||
121 | mDisplayPanel = new LLPanelDisplay(); | ||
122 | mTabContainer->addTabPanel(mDisplayPanel, mDisplayPanel->getLabel(), FALSE, onTabChanged, mTabContainer); | ||
123 | mDisplayPanel->setDefaultBtn(default_btn); | ||
124 | |||
125 | mDisplayPanel3 = new LLPanelDisplay3(); | ||
126 | mTabContainer->addTabPanel(mDisplayPanel3, mDisplayPanel3->getLabel(), FALSE, onTabChanged, mTabContainer); | ||
127 | mDisplayPanel3->setDefaultBtn(default_btn); | ||
128 | |||
129 | mDisplayPanel2 = new LLPanelDisplay2(); | ||
130 | mTabContainer->addTabPanel(mDisplayPanel2, mDisplayPanel2->getLabel(), FALSE, onTabChanged, mTabContainer); | ||
131 | mDisplayPanel2->setDefaultBtn(default_btn); | ||
132 | |||
133 | mAudioPanel = new LLPanelAudioPrefs(); | ||
134 | mTabContainer->addTabPanel(mAudioPanel, mAudioPanel->getLabel(), FALSE, onTabChanged, mTabContainer); | ||
135 | mAudioPanel->setDefaultBtn(default_btn); | ||
136 | |||
137 | mPrefsChat = new LLPrefsChat(); | ||
138 | mTabContainer->addTabPanel(mPrefsChat->getPanel(), mPrefsChat->getPanel()->getLabel(), FALSE, onTabChanged, mTabContainer); | ||
139 | mPrefsChat->getPanel()->setDefaultBtn(default_btn); | ||
140 | |||
141 | mPrefsIM = new LLPrefsIM(); | ||
142 | mTabContainer->addTabPanel(mPrefsIM->getPanel(), mPrefsIM->getPanel()->getLabel(), FALSE, onTabChanged, mTabContainer); | ||
143 | mPrefsIM->getPanel()->setDefaultBtn(default_btn); | ||
144 | |||
145 | mMsgPanel = new LLPanelMsgs(); | ||
146 | gUICtrlFactory->buildPanel(mMsgPanel, "panel_settings_msgbox.xml"); | ||
147 | mTabContainer->addTabPanel(mMsgPanel, mMsgPanel->getLabel(), FALSE, onTabChanged, mTabContainer); | ||
148 | mMsgPanel->setDefaultBtn(default_btn); | ||
149 | |||
150 | mTabContainer->selectTab(gSavedSettings.getS32("LastPrefTab")); | ||
151 | |||
152 | // Web prefs removed from Loopy build | ||
153 | // mWebPanel = new LLPanelWeb(); | ||
154 | // gUICtrlFactory->buildPanel(mWebPanel, "panel_settings_web.xml"); | ||
155 | // addTabPanel(mWebPanel, "Web", FALSE, onTabChanged, this); | ||
156 | } | ||
157 | |||
158 | void LLPreferenceCore::apply() | ||
159 | { | ||
160 | mGeneralPanel->apply(); | ||
161 | mInputPanel->apply(); | ||
162 | mNetworkPanel->apply(); | ||
163 | mDisplayPanel->apply(); | ||
164 | mDisplayPanel2->apply(); | ||
165 | mDisplayPanel3->apply(); | ||
166 | mAudioPanel->apply(); | ||
167 | mPrefsChat->apply(); | ||
168 | mPrefsIM->apply(); | ||
169 | mMsgPanel->apply(); | ||
170 | // mWebPanel->apply(); | ||
171 | } | ||
172 | |||
173 | |||
174 | void LLPreferenceCore::cancel() | ||
175 | { | ||
176 | mGeneralPanel->cancel(); | ||
177 | mInputPanel->cancel(); | ||
178 | mNetworkPanel->cancel(); | ||
179 | mDisplayPanel->cancel(); | ||
180 | mDisplayPanel2->cancel(); | ||
181 | mDisplayPanel3->cancel(); | ||
182 | mAudioPanel->cancel(); | ||
183 | mPrefsChat->cancel(); | ||
184 | mPrefsIM->cancel(); | ||
185 | mMsgPanel->cancel(); | ||
186 | // mWebPanel->cancel(); | ||
187 | } | ||
188 | |||
189 | // static | ||
190 | void LLPreferenceCore::onTabChanged(void* user_data, bool from_click) | ||
191 | { | ||
192 | LLTabContainerCommon* self = (LLTabContainerCommon*)user_data; | ||
193 | |||
194 | gSavedSettings.setS32("LastPrefTab", self->getCurrentPanelIndex()); | ||
195 | } | ||
196 | |||
197 | |||
198 | void LLPreferenceCore::setPersonalInfo( | ||
199 | const char* visibility, | ||
200 | BOOL im_via_email, | ||
201 | const char* email) | ||
202 | { | ||
203 | mPrefsIM->setPersonalInfo(visibility, im_via_email, email); | ||
204 | } | ||
205 | |||
206 | ////////////////////////////////////////////// | ||
207 | // LLFloaterPreference | ||
208 | |||
209 | LLFloaterPreference::LLFloaterPreference() | ||
210 | { | ||
211 | gUICtrlFactory->buildFloater(this, "floater_preferences.xml"); | ||
212 | } | ||
213 | |||
214 | BOOL LLFloaterPreference::postBuild() | ||
215 | { | ||
216 | requires("About...", WIDGET_TYPE_BUTTON); | ||
217 | requires("OK", WIDGET_TYPE_BUTTON); | ||
218 | requires("Cancel", WIDGET_TYPE_BUTTON); | ||
219 | requires("Apply", WIDGET_TYPE_BUTTON); | ||
220 | requires("pref core", WIDGET_TYPE_TAB_CONTAINER); | ||
221 | |||
222 | if (!checkRequirements()) | ||
223 | { | ||
224 | return FALSE; | ||
225 | } | ||
226 | |||
227 | mAboutBtn = LLUICtrlFactory::getButtonByName(this, "About..."); | ||
228 | mAboutBtn->setClickedCallback(onClickAbout, this); | ||
229 | |||
230 | mApplyBtn = LLUICtrlFactory::getButtonByName(this, "Apply"); | ||
231 | mApplyBtn->setClickedCallback(onBtnApply, this); | ||
232 | |||
233 | mCancelBtn = LLUICtrlFactory::getButtonByName(this, "Cancel"); | ||
234 | mCancelBtn->setClickedCallback(onBtnCancel, this); | ||
235 | |||
236 | mOKBtn = LLUICtrlFactory::getButtonByName(this, "OK"); | ||
237 | mOKBtn->setClickedCallback(onBtnOK, this); | ||
238 | |||
239 | mPreferenceCore = new LLPreferenceCore( | ||
240 | LLUICtrlFactory::getTabContainerByName(this, "pref core"), | ||
241 | static_cast<LLButton *>(getChildByName("OK")) | ||
242 | ); | ||
243 | |||
244 | sInstance = this; | ||
245 | |||
246 | return TRUE; | ||
247 | } | ||
248 | |||
249 | |||
250 | LLFloaterPreference::~LLFloaterPreference() | ||
251 | { | ||
252 | sInstance = NULL; | ||
253 | } | ||
254 | |||
255 | |||
256 | void LLFloaterPreference::draw() | ||
257 | { | ||
258 | if( getVisible() ) | ||
259 | { | ||
260 | LLFloater::draw(); | ||
261 | } | ||
262 | } | ||
263 | |||
264 | |||
265 | void LLFloaterPreference::apply() | ||
266 | { | ||
267 | this->mPreferenceCore->apply(); | ||
268 | } | ||
269 | |||
270 | |||
271 | void LLFloaterPreference::cancel() | ||
272 | { | ||
273 | this->mPreferenceCore->cancel(); | ||
274 | } | ||
275 | |||
276 | |||
277 | // static | ||
278 | void LLFloaterPreference::show(void*) | ||
279 | { | ||
280 | if (!sInstance) | ||
281 | { | ||
282 | new LLFloaterPreference(); | ||
283 | sInstance->center(); | ||
284 | } | ||
285 | |||
286 | sInstance->open(); | ||
287 | |||
288 | if(!gAgent.getID().isNull()) | ||
289 | { | ||
290 | // we're logged in, so we can get this info. | ||
291 | gMessageSystem->newMessageFast(_PREHASH_UserInfoRequest); | ||
292 | gMessageSystem->nextBlockFast(_PREHASH_AgentData); | ||
293 | gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | ||
294 | gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); | ||
295 | gAgent.sendReliableMessage(); | ||
296 | } | ||
297 | } | ||
298 | |||
299 | |||
300 | // static | ||
301 | void LLFloaterPreference::onClickAbout(void*) | ||
302 | { | ||
303 | LLFloaterAbout::show(NULL); | ||
304 | } | ||
305 | |||
306 | |||
307 | // static | ||
308 | void LLFloaterPreference::onBtnOK( void* userdata ) | ||
309 | { | ||
310 | LLFloaterPreference *fp =(LLFloaterPreference *)userdata; | ||
311 | // commit any outstanding text entry | ||
312 | if (fp->hasFocus()) | ||
313 | { | ||
314 | LLUICtrl* cur_focus = gFocusMgr.getKeyboardFocus(); | ||
315 | if (cur_focus->acceptsTextInput()) | ||
316 | { | ||
317 | cur_focus->onCommit(); | ||
318 | } | ||
319 | } | ||
320 | |||
321 | if (fp->canClose()) | ||
322 | { | ||
323 | fp->apply(); | ||
324 | fp->onClose(false); | ||
325 | |||
326 | gSavedSettings.saveToFile( gSettingsFileName, TRUE ); | ||
327 | |||
328 | std::string crash_settings_filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, CRASH_SETTINGS_FILE); | ||
329 | // save all settings, even if equals defaults | ||
330 | gCrashSettings.saveToFile(crash_settings_filename.c_str(), FALSE); | ||
331 | } | ||
332 | else | ||
333 | { | ||
334 | // Show beep, pop up dialog, etc. | ||
335 | llinfos << "Can't close preferences!" << llendl; | ||
336 | } | ||
337 | } | ||
338 | |||
339 | |||
340 | // static | ||
341 | void LLFloaterPreference::onBtnApply( void* userdata ) | ||
342 | { | ||
343 | LLFloaterPreference *fp =(LLFloaterPreference *)userdata; | ||
344 | if (fp->hasFocus()) | ||
345 | { | ||
346 | LLUICtrl* cur_focus = gFocusMgr.getKeyboardFocus(); | ||
347 | if (cur_focus->acceptsTextInput()) | ||
348 | { | ||
349 | cur_focus->onCommit(); | ||
350 | } | ||
351 | } | ||
352 | fp->apply(); | ||
353 | } | ||
354 | |||
355 | |||
356 | // static | ||
357 | void LLFloaterPreference::onBtnCancel( void* userdata ) | ||
358 | { | ||
359 | LLFloaterPreference *fp =(LLFloaterPreference *)userdata; | ||
360 | if (fp->hasFocus()) | ||
361 | { | ||
362 | LLUICtrl* cur_focus = gFocusMgr.getKeyboardFocus(); | ||
363 | if (cur_focus->acceptsTextInput()) | ||
364 | { | ||
365 | cur_focus->onCommit(); | ||
366 | } | ||
367 | } | ||
368 | fp->cancel(); | ||
369 | fp->close(); | ||
370 | } | ||
371 | |||
372 | |||
373 | // static | ||
374 | void LLFloaterPreference::updateUserInfo( | ||
375 | const char* visibility, | ||
376 | BOOL im_via_email, | ||
377 | const char* email) | ||
378 | { | ||
379 | if(sInstance && sInstance->mPreferenceCore) | ||
380 | { | ||
381 | sInstance->mPreferenceCore->setPersonalInfo( | ||
382 | visibility, im_via_email, email); | ||
383 | } | ||
384 | } | ||