|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Setting List |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include <aknnotewrappers.h> |
|
22 #include <aknsettingpage.h> |
|
23 #include <aknslidersettingpage.h> |
|
24 #include <eikfrlbd.h> |
|
25 #include <eikfrlb.h> |
|
26 #include <mpxlog.h> |
|
27 |
|
28 #include <mpxaudioeffectsview.rsg> |
|
29 #include <avkon.rsg> |
|
30 #include <StringLoader.h> |
|
31 |
|
32 // User Includes |
|
33 #include "mpxaudioeffectsitems.h" |
|
34 |
|
35 // ================= MEMBER FUNCTIONS ======================= |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CMPXAudioEffectsItems::CMPXAudioEffectsItems() |
|
39 // Constructor |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 CMPXAudioEffectsItems::CMPXAudioEffectsItems(CMPXAudioEffectsModel* aModel) |
|
43 { |
|
44 iModel = aModel; |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CMPXAudioEffectsItems::~CMPXAudioEffectsItems() |
|
49 // Destructor |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CMPXAudioEffectsItems::~CMPXAudioEffectsItems() |
|
53 { |
|
54 } |
|
55 |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CMPXAudioEffectsItems::SizeChanged() |
|
59 // (other items were commented in a header). |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 void CMPXAudioEffectsItems::SizeChanged() |
|
63 { |
|
64 if( ListBox() ) |
|
65 { |
|
66 ListBox()->SetRect( Rect() ); |
|
67 } |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CMPXAudioEffectsItems::CreateSettingItemL() |
|
72 // (other items were commented in a header). |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 CAknSettingItem* CMPXAudioEffectsItems::CreateSettingItemL(TInt aIdentifier) |
|
76 { |
|
77 CAknSettingItem* settingItem = NULL; |
|
78 |
|
79 switch (aIdentifier) |
|
80 { |
|
81 case EEqualizerSettingItem: // Not used |
|
82 settingItem = new (ELeave) CAknTextSettingItem(aIdentifier, |
|
83 iModel->iPresetName); |
|
84 break; |
|
85 case EBalanceSettingItem: |
|
86 settingItem = new (ELeave) CAknSliderSettingItem(aIdentifier, |
|
87 iModel->iBalance); |
|
88 break; |
|
89 case EReverbSettingItem: |
|
90 settingItem = new ( ELeave ) CAknEnumeratedTextPopupSettingItem( |
|
91 aIdentifier,iModel->iReverb); |
|
92 break; |
|
93 case EStereoWideningSettingItem: |
|
94 settingItem = new (ELeave) CAknBinaryPopupSettingItem(aIdentifier, |
|
95 iModel->iStereo); |
|
96 break; |
|
97 case ELoudnessItem: |
|
98 settingItem = new (ELeave) CAknBinaryPopupSettingItem(aIdentifier, |
|
99 iModel->iLoudness); |
|
100 break; |
|
101 } |
|
102 return settingItem; |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CMPXAudioEffectsItems::ChangeSelectedItemL() |
|
107 // (other items were commented in a header). |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 void CMPXAudioEffectsItems::ChangeSelectedItemL() |
|
111 { |
|
112 EditItemL(ListBox()->CurrentItemIndex(), ETrue); |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // CMPXAudioEffectsItems::EditItemL() |
|
117 // (other items were commented in a header). |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 void CMPXAudioEffectsItems::EditItemL(TInt aIndex, TBool aCalledFromMenu) |
|
121 { |
|
122 if (aIndex==0) //balance |
|
123 { |
|
124 TInt oldValue = iModel->iBalance; |
|
125 |
|
126 CAknSliderSettingPage* dlg = |
|
127 new(ELeave) CAknSliderSettingPage(R_BALANCE_SETTING_PAGE, |
|
128 iModel->iBalance); |
|
129 dlg->SetSettingId(EBalanceSettingItem); |
|
130 dlg->SetSettingPageObserver(this); |
|
131 SetBalanceTextL(dlg); |
|
132 dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged); |
|
133 |
|
134 MPX_TRAPD( err, iModel->SetBalanceL() ); |
|
135 if(err != KErrNone)// the slider button will return to the previous |
|
136 // position if an error accures |
|
137 { |
|
138 iModel->iBalance = oldValue; |
|
139 TRAP_IGNORE(iModel->SetBalanceL()); // update value in file |
|
140 } |
|
141 |
|
142 // Redraw the text box correctly |
|
143 CAknSliderSettingItem* settingItem = (CAknSliderSettingItem*) |
|
144 SettingItemArray()->At(0); |
|
145 settingItem->LoadL(); |
|
146 settingItem->UpdateListBoxTextL(); |
|
147 } |
|
148 else if (aIndex==1) //Loundness |
|
149 { |
|
150 TBool oldLoudnessValue = iModel->iLoudness; |
|
151 CAknSettingItemList::EditItemL( aIndex, aCalledFromMenu ); |
|
152 (*SettingItemArray())[aIndex]->StoreL(); //activates change in listbox |
|
153 MPX_TRAPD( err, iModel->SetLoudnessL() ); //calls engine to change API |
|
154 |
|
155 if (err != KErrNone) //change in UI will not accure if API is not changed |
|
156 { |
|
157 CAknSettingItemList::EditItemL( aIndex, EFalse ); |
|
158 iModel->iLoudness = oldLoudnessValue; |
|
159 TRAP_IGNORE(iModel->SetLoudnessL()); |
|
160 } |
|
161 } |
|
162 else if (aIndex==2)//stereo widening |
|
163 { |
|
164 TBool oldStereoValue = iModel->iStereo; |
|
165 CAknSettingItemList::EditItemL( aIndex, aCalledFromMenu ); |
|
166 (*SettingItemArray())[aIndex]->StoreL(); //activates change in listbox |
|
167 MPX_TRAPD( err, iModel->SetStereoWideningL() ); //calls engine to change API |
|
168 |
|
169 if (err != KErrNone) //change in UI will not accure if API is not |
|
170 //changed(=error in API) |
|
171 { |
|
172 CAknSettingItemList::EditItemL( aIndex, EFalse ); |
|
173 iModel->iStereo = oldStereoValue; |
|
174 TRAP_IGNORE(iModel->SetStereoWideningL()); // update value in file |
|
175 } |
|
176 } |
|
177 DrawDeferred(); |
|
178 } |
|
179 |
|
180 |
|
181 // ----------------------------------------------------------------------------- |
|
182 // CMPXAudioEffectsItems::HandleSettingPageEventL() |
|
183 // (other items were commented in a header). |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 void CMPXAudioEffectsItems::HandleSettingPageEventL( |
|
187 CAknSettingPage* aSettingPage, |
|
188 TAknSettingPageEvent aEventType) |
|
189 { |
|
190 TInt id = aSettingPage->SettingId(); |
|
191 |
|
192 if (aEventType == EEventSettingChanged) |
|
193 { |
|
194 switch (id) |
|
195 { |
|
196 case EBalanceSettingItem: |
|
197 { |
|
198 CAknSliderSettingPage* slider = |
|
199 static_cast<CAknSliderSettingPage*>(aSettingPage); |
|
200 iModel->iBalance = slider->SliderControl()->Value(); |
|
201 iModel->SetBalanceL(); |
|
202 SetBalanceTextL( slider ); |
|
203 break; |
|
204 } |
|
205 default: |
|
206 break; |
|
207 } |
|
208 } |
|
209 } |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // CMPXAudioEffectsItems::SetBalanceTextL() |
|
213 // (other items were commented in a header). |
|
214 // ----------------------------------------------------------------------------- |
|
215 // |
|
216 void CMPXAudioEffectsItems::SetBalanceTextL( CAknSliderSettingPage* slider ) |
|
217 { |
|
218 HBufC* title = NULL; |
|
219 |
|
220 switch ( iModel->iBalance ) |
|
221 { |
|
222 |
|
223 case -100: |
|
224 { |
|
225 title = StringLoader::LoadLC( R_AUDIOEFFECT_BALANCE_LEFT100 ); |
|
226 break; |
|
227 } |
|
228 case -75: |
|
229 { |
|
230 title = StringLoader::LoadLC( R_AUDIOEFFECT_BALANCE_LEFT75 ); |
|
231 break; |
|
232 } |
|
233 case -50: |
|
234 { |
|
235 title = StringLoader::LoadLC( R_AUDIOEFFECT_BALANCE_LEFT50 ); |
|
236 break; |
|
237 } |
|
238 case -25: |
|
239 { |
|
240 title = StringLoader::LoadLC( R_AUDIOEFFECT_BALANCE_LEFT25 ); |
|
241 break; |
|
242 } |
|
243 case 0: |
|
244 { |
|
245 title = StringLoader::LoadLC( R_AUDIOEFFECT_BALANCE_CENTER ); |
|
246 break; |
|
247 } |
|
248 case 25: |
|
249 { |
|
250 title = StringLoader::LoadLC( R_AUDIOEFFECT_BALANCE_RIGHT25 ); |
|
251 break; |
|
252 } |
|
253 case 50: |
|
254 { |
|
255 title = StringLoader::LoadLC( R_AUDIOEFFECT_BALANCE_RIGHT50 ); |
|
256 break; |
|
257 } |
|
258 case 75: |
|
259 { |
|
260 title = StringLoader::LoadLC( R_AUDIOEFFECT_BALANCE_RIGHT75 ); |
|
261 break; |
|
262 } |
|
263 case 100: |
|
264 { |
|
265 title = StringLoader::LoadLC( R_AUDIOEFFECT_BALANCE_RIGHT100 ); |
|
266 break; |
|
267 } |
|
268 default: |
|
269 break; |
|
270 } |
|
271 |
|
272 if( title ) |
|
273 { |
|
274 slider->SetSettingTextL( *title ); |
|
275 slider->DrawNow(); |
|
276 CleanupStack::PopAndDestroy( title ); |
|
277 } |
|
278 } |
|
279 |
|
280 // End of file |