aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llprefsvoice.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:04 -0500
committerJacek Antonelli2008-08-15 23:45:04 -0500
commit117e22047c5752352342d64e3fb7ce00a4eb8113 (patch)
treee32de2cfba0dda8705ae528fcd1fbe23ba075685 /linden/indra/newview/llprefsvoice.cpp
parentSecond Life viewer sources 1.18.0.6 (diff)
downloadmeta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.zip
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.gz
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.bz2
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.xz
Second Life viewer sources 1.18.1.2
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llprefsvoice.cpp277
1 files changed, 277 insertions, 0 deletions
diff --git a/linden/indra/newview/llprefsvoice.cpp b/linden/indra/newview/llprefsvoice.cpp
new file mode 100644
index 0000000..c66a3d0
--- /dev/null
+++ b/linden/indra/newview/llprefsvoice.cpp
@@ -0,0 +1,277 @@
1/**
2 * @file llprefsvoice.cpp
3 * @author Richard Nelson
4 * @brief Voice chat preferences panel
5 *
6 * Copyright (c) 2003-2007, Linden Research, Inc.
7 *
8 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement
12 * ("Other License"), formally executed by you and Linden Lab. Terms of
13 * the GPL can be found in doc/GPL-license.txt in this distribution, or
14 * online at http://secondlife.com/developers/opensource/gplv2
15 *
16 * There are special exceptions to the terms and conditions of the GPL as
17 * it is applied to this Source Code. View the full text of the exception
18 * in the file doc/FLOSS-exception.txt in this software distribution, or
19 * online at http://secondlife.com/developers/opensource/flossexception
20 *
21 * By copying, modifying or distributing this software, you acknowledge
22 * that you have read and understood your obligations described above,
23 * and agree to abide by those obligations.
24 *
25 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
26 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
27 * COMPLETENESS OR PERFORMANCE.
28 */
29
30#include "llviewerprecompiledheaders.h"
31
32#include "llprefsvoice.h"
33
34#include "llcheckboxctrl.h"
35#include "llcombobox.h"
36
37#include "llviewercontrol.h"
38#include "llvieweruictrlfactory.h"
39
40#include "llmodaldialog.h"
41#include "llkeyboard.h"
42#include "llfocusmgr.h"
43#include "llfloatervoicewizard.h"
44
45#include "viewer.h"
46
47#include "llvoiceclient.h"
48
49class LLVoiceHotkeySelectDialog : public LLModalDialog
50{
51private:
52 LLPrefsVoiceLogic *mParent;
53 LLFloater *mOldFrontmost;
54
55public:
56 LLVoiceHotkeySelectDialog( LLPrefsVoiceLogic *parent )
57 : LLModalDialog( "", 240, 100 ),
58 mParent( parent )
59 {
60 mOldFrontmost = gFloaterView->getFrontmost();
61
62 gUICtrlFactory->buildFloater(this, "floater_select_key.xml");
63
64 childSetAction("Cancel", LLVoiceHotkeySelectDialog::onCancel, this );
65 childSetFocus("Cancel");
66 }
67
68 /*virtual*/ void setFocus( BOOL b )
69 {
70 LLFloater::setFocus(b);
71
72 // This forces keyboard processing to happen at the raw key level instead of going through handleUnicodeChar.
73 gFocusMgr.removeKeyboardFocusWithoutCallback(gFocusMgr.getKeyboardFocus());
74 }
75
76 static void onCancel( void* userdata );
77
78 BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent );
79
80};
81
82LLPrefsVoiceLogic::LLPrefsVoiceLogic(LLPanel* panelp) :
83 mPanel(panelp)
84{
85 init();
86}
87
88void LLPrefsVoiceLogic::init()
89{
90 mEnableVoice = gSavedSettings.getBOOL("EnableVoiceChat");
91
92 mVoiceCallsFriendsOnly = gSavedSettings.getBOOL("VoiceCallsFriendsOnly");
93 mEnablePushToTalk = gSavedSettings.getBOOL("EnablePushToTalk");
94 mModifier = gSavedSettings.getString("PushToTalkButton");
95 mPushToTalkToggle = gSavedSettings.getBOOL("PushToTalkToggle");
96 mEarLocation = gSavedSettings.getS32("VoiceEarLocation");
97
98 mCtrlEarLocation = LLUICtrlFactory::getSelectionInterfaceByName(mPanel, "ear_location");
99 mCtrlEarLocation->selectByValue(LLSD(gSavedSettings.getS32("VoiceEarLocation")));
100 mPanel->childSetCommitCallback("ear_location", onEarLocationCommit, this );
101
102 mPanel->childSetAction("launch_voice_wizard_button", onClickLaunchWizard, this);
103 mPanel->childSetAction("set_voice_hotkey_button", onClickSetKey, this);
104 mPanel->childSetAction("set_voice_middlemouse_button", onClickSetMiddleMouse, this);
105
106 refresh();
107 mEatNextSetKeyClick = FALSE;
108}
109
110void LLPrefsVoiceLogic::refresh()
111{
112 mPanel->childSetVisible("voice_unavailable", gDisableVoice);
113 mPanel->childSetVisible("enable_voice_check", !gDisableVoice);
114 mPanel->childSetEnabled("enable_voice_check", !gDisableVoice);
115
116 bool enable = !gDisableVoice && gSavedSettings.getBOOL("EnableVoiceChat");
117
118 mPanel->childSetEnabled("push_to_talk_check", enable);
119 mPanel->childSetEnabled("push_to_talk_label", enable);
120 mPanel->childSetEnabled("voice_call_friends_only_check", enable);
121 mPanel->childSetEnabled("push_to_talk_toggle_check", enable /*&& gSavedSettings.getBOOL("EnablePushToTalk")*/);
122 mPanel->childSetEnabled("ear_location", enable);
123 mPanel->childSetEnabled("set_voice_hotkey_button", enable /*&& gSavedSettings.getBOOL("EnablePushToTalk")*/);
124 mPanel->childSetEnabled("set_voice_middlemouse_button", enable /*&& gSavedSettings.getBOOL("EnablePushToTalk")*/);
125}
126
127void LLPrefsVoiceLogic::cancel()
128{
129 gSavedSettings.setBOOL("EnableVoiceChat", mEnableVoice);
130 gSavedSettings.setBOOL("VoiceCallsFriendsOnly", mVoiceCallsFriendsOnly);
131 gSavedSettings.setBOOL("EnablePushToTalk", mEnablePushToTalk );
132 gSavedSettings.setString("PushToTalkButton", mModifier);
133 gSavedSettings.setBOOL("PushToTalkToggle", mPushToTalkToggle );
134 gSavedSettings.setS32("VoiceEarLocation", mEarLocation);
135}
136
137void LLPrefsVoiceLogic::apply()
138{
139}
140
141//static
142void LLPrefsVoiceLogic::onEarLocationCommit(LLUICtrl* ctrl, void* user_data)
143{
144 LLCtrlSelectionInterface* interfacep = ctrl->getSelectionInterface();
145 if (interfacep)
146 {
147 gSavedSettings.setS32("VoiceEarLocation", interfacep->getSimpleSelectedValue().asInteger());
148 }
149}
150
151//static
152void LLPrefsVoiceLogic::onClickLaunchWizard(void* user_data)
153{
154 LLFloaterVoiceWizard::showInstance();
155}
156
157// static
158void LLPrefsVoiceLogic::onClickSetKey(void* user_data)
159{
160 LLPrefsVoiceLogic* self=(LLPrefsVoiceLogic*)user_data;
161 if(self->mEatNextSetKeyClick)
162 {
163 self->mEatNextSetKeyClick = false;
164 }
165 else
166 {
167 LLVoiceHotkeySelectDialog* dialog = new LLVoiceHotkeySelectDialog( self );
168 dialog->startModal();
169 // dialog will delete itself
170 }
171}
172
173
174// static
175void LLPrefsVoiceLogic::onClickSetMiddleMouse(void* user_data)
176{
177// LLPrefsVoiceLogic* self=(LLPrefsVoiceLogic*)user_data;
178
179 gSavedSettings.setString("PushToTalkButton", "MiddleMouse");
180}
181
182void LLPrefsVoiceLogic::setKey(KEY key, MASK mask)
183{
184 std::string keystring = LLKeyboard::stringFromKey(key);
185 gSavedSettings.setString("PushToTalkButton", keystring);
186
187 if(key == ' ')
188 {
189 // This will cause the select dialog to immediately reopen.
190 // Eat the next click event.
191 mEatNextSetKeyClick = TRUE;
192 }
193}
194
195void LLVoiceHotkeySelectDialog::onCancel( void* userdata )
196{
197 LLVoiceHotkeySelectDialog* self = (LLVoiceHotkeySelectDialog*) userdata;
198 self->close(); // destroys this object
199 self->mOldFrontmost->setFrontmost(TRUE);
200}
201
202BOOL LLVoiceHotkeySelectDialog::handleKey(KEY key, MASK mask, BOOL called_from_parent )
203{
204 BOOL result = TRUE;
205
206 // Suck up all keystokes except CTRL-Q.
207 BOOL is_quit = ('Q' == key) && (MASK_CONTROL == mask);
208 if(is_quit)
209 {
210 result = FALSE;
211 }
212 else
213 {
214 mParent->setKey(key, mask);
215 }
216
217 close(); // destroys this object
218 mOldFrontmost->setFrontmost(TRUE);
219
220 return result;
221}
222
223//---------------------------------------------------------------------------
224
225
226LLPrefsVoice::LLPrefsVoice()
227: LLPanel("Voice Chat Panel")
228{
229 gUICtrlFactory->buildPanel(this, "panel_preferences_voice.xml");
230 mLogic = new LLPrefsVoiceLogic(this);
231 childSetAction("device_settings_btn", onClickDeviceSettingsBtn, this);
232
233 // create floater immediately and keep it hidden
234 // since it stores preference state for audio devices
235 mDeviceSettings = LLFloaterDeviceSettings::getInstance();
236 //*FIXME: getInstance() needs to not show the floater
237 LLFloaterDeviceSettings::hideInstance();
238}
239
240LLPrefsVoice::~LLPrefsVoice()
241{
242 delete mLogic;
243}
244
245void LLPrefsVoice::draw()
246{
247 bool enable = !gDisableVoice && gSavedSettings.getBOOL("EnableVoiceChat");
248 childSetEnabled("device_settings_btn", enable);
249
250 mLogic->refresh();
251 mDeviceSettings->refresh();
252 LLPanel::draw();
253}
254
255void LLPrefsVoice::apply()
256{
257 mLogic->apply();
258 mDeviceSettings->apply();
259}
260
261void LLPrefsVoice::cancel()
262{
263 mLogic->cancel();
264 mDeviceSettings->cancel();
265}
266
267//static
268void LLPrefsVoice::onClickDeviceSettingsBtn(void* user_data)
269{
270 LLPrefsVoice* prefs = (LLPrefsVoice*)user_data;
271 prefs->mDeviceSettings->open();
272 LLFloater* parent_floater = gFloaterView->getParentFloater(prefs);
273 if (parent_floater)
274 {
275 parent_floater->addDependentFloater(prefs->mDeviceSettings, FALSE);
276 }
277}