|
1 /* |
|
2 * Copyright (c) 2005 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: Implementation of CEqualizerPresetsDialog class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <StringLoader.h> |
|
23 #include <akntitle.h> |
|
24 #include <eikenv.h> |
|
25 #include <bldvariant.hrh> |
|
26 #include <aknnotewrappers.h> |
|
27 #include <bautils.h> |
|
28 #include <aknenv.h> |
|
29 #include <aknlists.h> |
|
30 #include <data_caging_path_literals.hrh> |
|
31 #include <eikclbd.h> |
|
32 #include <AknIconArray.h> |
|
33 #include <avkon.hrh> |
|
34 //LAF and Skin changes |
|
35 #include <AknsUtils.h> |
|
36 #include <e32base.h> |
|
37 #include <AknsConstants.h> |
|
38 #include <aknlayout.cdl.h> |
|
39 #include <featmgr.h> |
|
40 #include <hlplch.h> |
|
41 #include <AudioEqualizerUtility.h> |
|
42 #include <sysutil.h> |
|
43 #include <AknGlobalNote.h> |
|
44 #include <aknclearer.h> |
|
45 #include <layoutmetadata.cdl.h> |
|
46 |
|
47 #include <csxhelp/eq.hlp.hrh> |
|
48 #include <Equalizer.rsg> // Contains the resource definition |
|
49 #include <equalizer.mbg> |
|
50 #include "EqualizerPrivateConstants.h" |
|
51 #include "EqualizerPresetsDialog.h" |
|
52 #include "EqualizerPresetListArray.h" |
|
53 #include "EqualizerEditingDialog.h" |
|
54 #include "Equalizer.hrh" |
|
55 |
|
56 // CONSTANTS |
|
57 //Used during building a new preset name |
|
58 _LIT( KEqrFormat, "%d)" ); |
|
59 _LIT( KEqrZero, "0" ); |
|
60 _LIT( KEqrParenthesis, "(" ); |
|
61 |
|
62 // Used for checking if the new preset name contains illegal characters |
|
63 _LIT(KEqrLessThan, "<"); |
|
64 _LIT(KEqrGreaterThan, ">"); |
|
65 _LIT(KEqrQuote, "\""); |
|
66 _LIT(KEqrBackSlash, "\\"); |
|
67 _LIT(KEqrForwardSlash, "/"); |
|
68 _LIT(KEqrOrSymbol, "|"); |
|
69 _LIT(KEqrColon, ":"); |
|
70 _LIT(KEqrAsterisk, "*"); |
|
71 _LIT(KEqrQuestionMark, "?"); |
|
72 |
|
73 // ================= MEMBER FUNCTIONS ======================= |
|
74 |
|
75 // ------------------------------------------------------------------- |
|
76 // CEqualizerPresetsDialog* CEqualizerPresetsDialog::NewL() |
|
77 // Create instance of concrete ECOM interface implementation |
|
78 // ------------------------------------------------------------------- |
|
79 // |
|
80 EXPORT_C CEqualizerPresetsDialog* CEqualizerPresetsDialog::NewL( |
|
81 CAudioEqualizerUtility* aAudEqUtility, |
|
82 TInt aCurrentActivePreset, |
|
83 MEqualizerPresetActivationObserver& aEqrPresetActObserver) |
|
84 { |
|
85 CEqualizerPresetsDialog* self = new (ELeave) CEqualizerPresetsDialog( |
|
86 aAudEqUtility, aEqrPresetActObserver); |
|
87 CleanupStack::PushL(self); |
|
88 self->ConstructL(aCurrentActivePreset); |
|
89 CleanupStack::Pop(self); |
|
90 return self; |
|
91 } |
|
92 |
|
93 // ------------------------------------------------------------------- |
|
94 // CEqualizerPresetsDialog::CEqualizerPresetsDialog( |
|
95 // CAudioEqualizerUtility*& aAudEqUtility, |
|
96 // MEqualizerPresetActivationObserver& aEqrPresetActObserver) |
|
97 // First Phase Construction |
|
98 // ------------------------------------------------------------------- |
|
99 // |
|
100 CEqualizerPresetsDialog::CEqualizerPresetsDialog( |
|
101 CAudioEqualizerUtility* aAudEqUtility, |
|
102 MEqualizerPresetActivationObserver& aEqrPresetActObserver): |
|
103 |
|
104 iAudEqUtility(aAudEqUtility), |
|
105 iEqrPresetActObserver(aEqrPresetActObserver) |
|
106 { |
|
107 } |
|
108 |
|
109 // ------------------------------------------------------------------- |
|
110 // CEqualizerPresetsDialog::ConstructL() |
|
111 // Second Phase Constructor |
|
112 // ------------------------------------------------------------------- |
|
113 // |
|
114 void CEqualizerPresetsDialog::ConstructL(const TInt aCurrentActivePreset) |
|
115 { |
|
116 //Initially set these variable to EFalse |
|
117 iContextSensitiveMenu = EFalse; |
|
118 iIgnoreKeyEvents = EFalse; |
|
119 |
|
120 iRepository = CRepository::NewL(KCRUidMusicPlayerSettings); |
|
121 |
|
122 //Add the resource file |
|
123 |
|
124 // Find which drive this DLL is installed. |
|
125 TFileName fileName; |
|
126 // Get the full resource file |
|
127 TParse fp; |
|
128 // Add the resource dir |
|
129 fp.Set( KEqualizerResourceFileName, &KDC_APP_RESOURCE_DIR, NULL); |
|
130 // Get the filename with full path |
|
131 fileName = fp.FullName(); |
|
132 //for localisation of resource file |
|
133 BaflUtils::NearestLanguageFile( iEikonEnv->FsSession(), fileName ); |
|
134 iResourceFileOffset = iEikonEnv->AddResourceFileL( fileName ); |
|
135 |
|
136 //Read text for preset "None" from rss file |
|
137 iPresetNoneText = StringLoader::LoadL(R_QTN_EQUALIZER_PRESET_NONE); |
|
138 iTitleText = StringLoader::LoadL(R_QTN_EQUALIZER_TITLE_TEXT); |
|
139 |
|
140 iItemArray = CEqualizerPresetListArray::NewL(iAudEqUtility, |
|
141 aCurrentActivePreset); |
|
142 |
|
143 iItemArray->GetCurrentActivePreset(iActivePreset); |
|
144 |
|
145 CAknDialog::ConstructL(R_EQUALIZER_CONTAINER_MENUBAR); |
|
146 } |
|
147 |
|
148 // ------------------------------------------------------------------- |
|
149 // CEqualizerPresetsDialog::~CEqualizerPresetsDialog() |
|
150 // Destructor |
|
151 // -------------------------------------------------------------------- |
|
152 // |
|
153 CEqualizerPresetsDialog::~CEqualizerPresetsDialog() |
|
154 { |
|
155 if (iResourceFileOffset) |
|
156 { |
|
157 iEikonEnv->DeleteResourceFile(iResourceFileOffset); |
|
158 } |
|
159 delete iRepository; |
|
160 if (iAppTitleText) |
|
161 { |
|
162 // restore musicplayer's title |
|
163 CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane(); |
|
164 CAknTitlePane* tp=(CAknTitlePane*)sp->ControlL(TUid::Uid(EEikStatusPaneUidTitle)); |
|
165 tp->SetTextL(*iAppTitleText); |
|
166 delete iAppTitleText; |
|
167 } |
|
168 delete iPresetNoneText; |
|
169 delete iTitleText; |
|
170 delete iItemArray; |
|
171 } |
|
172 |
|
173 // -------------------------------------------------------------------------- |
|
174 // void CEqualizerPresetsDialog::BuildPresetNameL( TDes& aName) const |
|
175 // Returns free folder name |
|
176 // -------------------------------------------------------------------------- |
|
177 // |
|
178 void CEqualizerPresetsDialog::BuildPresetNameL( TDes& aName) const |
|
179 { |
|
180 //set name in the query box to "Preset" |
|
181 HBufC* defaultText = StringLoader::LoadLC( |
|
182 R_QTN_EQ_PRESET_DEFAULT_NAME); |
|
183 |
|
184 TInt n(0); |
|
185 |
|
186 // Numbers start from 1 |
|
187 TBool found( EFalse ); |
|
188 TBuf<KMaxPresetNameLength> number; |
|
189 |
|
190 // The loop is iterated until a free folder name is found. |
|
191 FOREVER |
|
192 { |
|
193 found = EFalse; |
|
194 // Constructs a candidate for the name |
|
195 TBuf<KMaxPresetNameLength> newName; |
|
196 newName.Copy( *defaultText ); |
|
197 |
|
198 if( n > 0 ) |
|
199 // First new is without number ( New folder, New folder(01), New folder(02), ...) |
|
200 { |
|
201 // Creates the current number. |
|
202 number.Format( KEqrFormat, n ); |
|
203 AknTextUtils::LanguageSpecificNumberConversion ( number ); |
|
204 |
|
205 TInt leadingZeroLength( 0 ); |
|
206 if( n < 10 ) |
|
207 { |
|
208 leadingZeroLength = KEqrZero().Length(); |
|
209 } |
|
210 |
|
211 // checks the total length of the costructed string |
|
212 if( ( number.Length() + newName.Length() + KEqrParenthesis().Length() |
|
213 + leadingZeroLength ) > KMaxPresetNameLength ) |
|
214 { |
|
215 User::Leave( KErrOverflow ); |
|
216 } |
|
217 |
|
218 // Appends the first parenthesis |
|
219 newName.Append( KEqrParenthesis ); |
|
220 if( n < 10 ) |
|
221 { |
|
222 // Appends the leading zero ( always two digits 08, 09, 10, 11,...) |
|
223 TBuf< 16 > zero(KEqrZero); |
|
224 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( zero ); |
|
225 newName.Append( KEqrZero ); |
|
226 } |
|
227 newName.Append( number ); |
|
228 } |
|
229 found = SearchPresetL(newName); |
|
230 |
|
231 if( found == KErrNotFound ) |
|
232 { |
|
233 aName = newName; |
|
234 CleanupStack::PopAndDestroy( defaultText); |
|
235 return; |
|
236 } |
|
237 n++; |
|
238 } |
|
239 } |
|
240 |
|
241 // ----------------------------------------------------------------------- |
|
242 // CEqualizerPresetsDialog::GetNewName(TInt aResourceId, TDes& presetName) |
|
243 // |
|
244 // This function is called to display the dialog box to get a new name |
|
245 // during "Raname" or "Create new" |
|
246 // ----------------------------------------------------------------------- |
|
247 // |
|
248 TBool CEqualizerPresetsDialog::GetNewNameL(const TInt aResourceId, TDes& |
|
249 aPresetName) const |
|
250 { |
|
251 CAknTextQueryDialog* dlg; |
|
252 TBool ret = EFalse; |
|
253 |
|
254 while (1) |
|
255 { |
|
256 dlg = CAknTextQueryDialog::NewL(aPresetName); |
|
257 if (dlg->ExecuteLD(aResourceId)) |
|
258 { |
|
259 // Illegal characters in a preset name are < > \" \\ / | : * ?" |
|
260 |
|
261 if ( (aPresetName.FindC( KEqrLessThan ) != KErrNotFound ) || |
|
262 (aPresetName.FindC( KEqrGreaterThan ) != KErrNotFound ) || |
|
263 (aPresetName.FindC( KEqrQuote ) != KErrNotFound ) || |
|
264 (aPresetName.FindC( KEqrBackSlash ) != KErrNotFound ) || |
|
265 (aPresetName.FindC( KEqrForwardSlash ) != KErrNotFound ) || |
|
266 (aPresetName.FindC( KEqrOrSymbol ) != KErrNotFound ) || |
|
267 (aPresetName.FindC( KEqrColon ) != KErrNotFound ) || |
|
268 (aPresetName.FindC( KEqrAsterisk ) != KErrNotFound ) || |
|
269 (aPresetName.FindC( KEqrQuestionMark ) != KErrNotFound ) |
|
270 ) |
|
271 { |
|
272 HBufC* text = StringLoader::LoadLC( |
|
273 R_QTN_FLDR_ILLEGAL_CHARACTERS); |
|
274 CAknInformationNote* note = new( ELeave ) CAknInformationNote(ETrue); |
|
275 note->ExecuteLD( *text ); |
|
276 CleanupStack::PopAndDestroy(text); |
|
277 continue; |
|
278 } |
|
279 |
|
280 TInt error = SearchPresetL(aPresetName); |
|
281 if (error != KErrNotFound) |
|
282 { |
|
283 // display error |
|
284 HBufC* label = StringLoader::LoadLC( |
|
285 R_QTN_FLDR_NAME_ALREADY_USED, aPresetName ); |
|
286 CAknInformationNote* note = new( ELeave ) |
|
287 CAknInformationNote( ETrue ); |
|
288 note->ExecuteLD( *label ); |
|
289 CleanupStack::PopAndDestroy(label); |
|
290 continue; |
|
291 } |
|
292 // New name entered |
|
293 ret = ETrue; |
|
294 } |
|
295 // Break, in case user Cancels the data query or |
|
296 // enters a valid name |
|
297 break; |
|
298 } |
|
299 return ret; |
|
300 } |
|
301 |
|
302 // --------------------------------------------------------------------------- |
|
303 // TPresetName CEqualizerPresetsDialog::GetHighlightedPresetInListBox() const |
|
304 // This function returns the highlighted Preset in ListBox |
|
305 // --------------------------------------------------------------------------- |
|
306 // |
|
307 TPresetName CEqualizerPresetsDialog::GetHighlightedPresetInListBox() const |
|
308 { |
|
309 TInt selectedIndex = iListBox->CurrentItemIndex(); |
|
310 CTextListBoxModel* model = iListBox->Model(); |
|
311 TPresetName selectedItem(model->ItemText(selectedIndex)); |
|
312 TPresetName highlightedPreset = |
|
313 selectedItem.Right(selectedItem.Length()- iItemArray->GetPrefixLength()); |
|
314 return highlightedPreset; |
|
315 } |
|
316 |
|
317 // --------------------------------------------------------------------------- |
|
318 //void CEqualizerPresetsDialog::ActivateEqrPresetL(const TInt aIndex, |
|
319 //const TDesC& aPreset) const |
|
320 // |
|
321 //This function is used for the activation of a preset |
|
322 // --------------------------------------------------------------------------- |
|
323 // |
|
324 void CEqualizerPresetsDialog::ActivateEqrPresetL(const TInt aIndex, |
|
325 const TDesC& aPreset) |
|
326 { |
|
327 TInt err; |
|
328 // Store activated preset in central repository |
|
329 SetCurrentPreset(aPreset); |
|
330 |
|
331 // Set the active preset in the equalizer item array |
|
332 iItemArray->SetCurrentActivePreset(aPreset); |
|
333 |
|
334 // Display Confirmation note |
|
335 HBufC* activateNoteText = StringLoader::LoadLC( |
|
336 R_QTN_EQ_NOTE_INFO_PRESET_ACTIVATED, aPreset); |
|
337 CAknConfirmationNote* dialog = new(ELeave)CAknConfirmationNote(); |
|
338 dialog->ExecuteLD(*activateNoteText); |
|
339 CleanupStack::PopAndDestroy(activateNoteText); |
|
340 |
|
341 // Inform the engine |
|
342 if (aPreset.Compare(*iPresetNoneText) == 0) |
|
343 { |
|
344 TRAP(err, iAudEqUtility->DisableEqualizerL()); |
|
345 } |
|
346 else |
|
347 { |
|
348 TRAP(err, iAudEqUtility->ApplyPresetL(GetEngineIndexL(aPreset))); |
|
349 } |
|
350 |
|
351 if(!err) |
|
352 { |
|
353 iListBox->HandleItemAdditionL(); |
|
354 iListBox->SetCurrentItemIndexAndDraw(aIndex); |
|
355 // To prevent two tickmarks from appearing sometimes |
|
356 iListBox->DrawNow(); |
|
357 } |
|
358 } |
|
359 |
|
360 // --------------------------------------------------------------------------- |
|
361 //void CEqualizerPresetsDialog::RenameEqrPresetL(const TInt aIndex, |
|
362 //const TDesC& aPreset) const |
|
363 // |
|
364 //This function is used for the renaming of a preset |
|
365 // --------------------------------------------------------------------------- |
|
366 // |
|
367 void CEqualizerPresetsDialog::RenameEqrPresetL(const TInt /*aIndex*/, |
|
368 const TDesC& aPreset) |
|
369 { |
|
370 //Check if this is an active preset |
|
371 TPresetName activePresetName = CurrentPreset(); |
|
372 if (aPreset.Compare(activePresetName) == 0) |
|
373 { |
|
374 //Display Confirmation note |
|
375 HBufC* renameText = StringLoader::LoadLC( |
|
376 R_QTN_EQ_NOTE_ERR_PRESET_IN_USE_NO_RENAME); |
|
377 CAknErrorNote* dialog = new(ELeave)CAknErrorNote(); |
|
378 dialog->ExecuteLD(*renameText); |
|
379 CleanupStack::PopAndDestroy(renameText); |
|
380 } |
|
381 else |
|
382 { |
|
383 TPresetName presetName; |
|
384 presetName = aPreset; |
|
385 TBool nameEnteredIsFine = |
|
386 GetNewNameL(R_DIALOG_TEXT_RENAME_ITEM_NAME, presetName); |
|
387 |
|
388 if (nameEnteredIsFine) |
|
389 { |
|
390 TInt engineIndex = GetEngineIndexL(aPreset); |
|
391 //Update Engine |
|
392 iAudEqUtility->GetPresetL(engineIndex); |
|
393 CAudioEqualizer& audioEqualizer = iAudEqUtility->Equalizer(); |
|
394 |
|
395 iAudEqUtility->ModifyPresetL(engineIndex,presetName, |
|
396 audioEqualizer); |
|
397 |
|
398 //Update listbox |
|
399 // Sort the array of user-defined presets |
|
400 iItemArray->UpdateSortedArrayL(); |
|
401 iListBox->SetCurrentItemIndex(SearchPresetL(presetName)); |
|
402 iListBox->DrawNow(); |
|
403 } |
|
404 } |
|
405 } |
|
406 |
|
407 // --------------------------------------------------------------------------- |
|
408 // void CEqualizerPresetsDialog::EditEqrPresetL(const TInt aIndex, |
|
409 // const TDesC& aPreset) const |
|
410 // |
|
411 // This function is used for the editing of a preset |
|
412 // --------------------------------------------------------------------------- |
|
413 // |
|
414 void CEqualizerPresetsDialog::EditEqrPresetL(const TInt /*aIndex*/, |
|
415 const TDesC& aPreset) |
|
416 { |
|
417 //Set application name in the title pane to preset name. |
|
418 CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane(); |
|
419 CAknTitlePane* tp=(CAknTitlePane*)sp->ControlL(TUid::Uid( |
|
420 EEikStatusPaneUidTitle)); |
|
421 tp->SetTextL(aPreset); |
|
422 TInt engineIndex = GetEngineIndexL(aPreset); |
|
423 //Update Engine |
|
424 TBool isActivePreset = (aPreset==CurrentPreset()); |
|
425 |
|
426 DisplaySettingsL(iAudEqUtility, engineIndex, isActivePreset); |
|
427 } |
|
428 |
|
429 // --------------------------------------------------------------------------- |
|
430 // void CEqualizerPresetsDialog::CreateNewEqrPresetL(TInt& aIndex, |
|
431 // TPresetName& aPreset) const |
|
432 // |
|
433 // This function is used for the creation of a new preset. |
|
434 // @param aIndex The index of the preset in the ListBox. This is set |
|
435 // to a the index in the ListBox if preset creation is successful. |
|
436 // If the creation is unscuccessful, then the parameter is not changed. |
|
437 // @param aPreset The name of the preset created |
|
438 // --------------------------------------------------------------------------- |
|
439 // |
|
440 void CEqualizerPresetsDialog::CreateNewEqrPresetL(TInt& aIndex, |
|
441 TPresetName& aPreset) const |
|
442 { |
|
443 RFs fs; |
|
444 User::LeaveIfError( fs.Connect() ); |
|
445 CleanupClosePushL<RFs>( fs ); |
|
446 |
|
447 if (SysUtil::FFSSpaceBelowCriticalLevelL(&fs,0)) |
|
448 { |
|
449 ShowDiskFullNoteL(); // Phone memory full, show note |
|
450 } |
|
451 else |
|
452 { |
|
453 TPresetName presetName; |
|
454 BuildPresetNameL(presetName); |
|
455 |
|
456 TBool nameEnteredIsFine = GetNewNameL(R_DIALOG_TEXT_NEW_ITEM_NAME, |
|
457 presetName); |
|
458 |
|
459 if (nameEnteredIsFine) |
|
460 { |
|
461 //Update Engine |
|
462 CAudioEqualizer& audioEqualizer = iAudEqUtility->Equalizer(); |
|
463 iAudEqUtility->CreatePresetL(presetName, audioEqualizer); |
|
464 |
|
465 //Set the level of all bands to 0. |
|
466 TInt numFreqBand = audioEqualizer.NumberOfBands(); |
|
467 for (TInt i = 0; i < numFreqBand; i++) |
|
468 { |
|
469 audioEqualizer.SetBandLevelL(i+1, 0); |
|
470 } |
|
471 |
|
472 iItemArray->UpdateSortedArrayL(); |
|
473 //Update AudioEqualizerUtility object, setting the level of all |
|
474 // bands to 0 |
|
475 iAudEqUtility->ModifyPresetL(GetEngineIndexL(presetName), |
|
476 presetName, audioEqualizer); |
|
477 |
|
478 //Set the focus to the new preset |
|
479 iListBox->HandleItemAdditionL(); |
|
480 iListBox->SetCurrentItemIndex(SearchPresetL(presetName)); |
|
481 iListBox->DrawNow(); |
|
482 |
|
483 aPreset = presetName; |
|
484 aIndex = iItemArray->MdcaCount()-1; |
|
485 } |
|
486 } |
|
487 CleanupStack::PopAndDestroy(); |
|
488 } |
|
489 |
|
490 // --------------------------------------------------------------------------- |
|
491 //void CEqualizerPresetsDialog::DeleteEqrPresetL(const TInt aIndex, |
|
492 //const TDesC& aPreset) const |
|
493 // |
|
494 //This function is used for the deletion of a preset |
|
495 // --------------------------------------------------------------------------- |
|
496 // |
|
497 void CEqualizerPresetsDialog::DeleteEqrPresetL(const TInt aIndex, |
|
498 const TDesC& aPreset) |
|
499 { |
|
500 //Check if this is an active preset |
|
501 TPresetName activePresetName = CurrentPreset(); |
|
502 if (aPreset.Compare(activePresetName) == 0) |
|
503 { |
|
504 //Display error note |
|
505 HBufC* renameText = |
|
506 StringLoader::LoadLC(R_QTN_EQ_NOTE_ERR_PRESET_IN_USE); |
|
507 CAknErrorNote* dialog = new(ELeave)CAknErrorNote(); |
|
508 dialog->ExecuteLD(*renameText); |
|
509 CleanupStack::PopAndDestroy(renameText); |
|
510 } |
|
511 else |
|
512 { |
|
513 //Delete?\n%U" §qtn.query.common.conf.delete? |
|
514 HBufC* text = |
|
515 StringLoader::LoadLC( R_QTN_QUERY_COMMON_CONF_DELETE, |
|
516 aPreset); |
|
517 |
|
518 // Show confirmation note |
|
519 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
520 TInt result( |
|
521 dlg->ExecuteLD( R_EQUALIZER_CONFIRMATION_QUERY, *text ) ); |
|
522 CleanupStack::PopAndDestroy(text); // text |
|
523 |
|
524 if ( result ) |
|
525 { |
|
526 //Update Engine |
|
527 iAudEqUtility->DeletePresetL(GetEngineIndexL(aPreset)); |
|
528 //Remove from listbox |
|
529 iItemArray->UpdateSortedArrayL(); |
|
530 iListBox->HandleItemRemovalL(); |
|
531 // This is to avoid the gap observed when the last entry present |
|
532 // in the Preset List is deleted |
|
533 iListBox->SetCurrentItemIndexAndDraw(0); |
|
534 //If we are at the last preset set focus to the next preset |
|
535 // else the previous preset |
|
536 if (aIndex == iItemArray->MdcaCount()) |
|
537 { |
|
538 iListBox->SetCurrentItemIndexAndDraw(aIndex - 1); |
|
539 } |
|
540 else |
|
541 { |
|
542 iListBox->SetCurrentItemIndexAndDraw(aIndex); |
|
543 } |
|
544 iListBox->DrawNow(); |
|
545 } |
|
546 } |
|
547 } |
|
548 |
|
549 // ------------------------------------------------------------------- |
|
550 // TInt CEqualizerPresetsDialog::GetEngineIndexL |
|
551 // (const TPresetName& aPresetName) |
|
552 // |
|
553 // This function is called to find the index of a preset in the list of |
|
554 // presets returned by CAudioEqualizerUtility::Presets() |
|
555 // -------------------------------------------------------------------- |
|
556 // |
|
557 TInt CEqualizerPresetsDialog::GetEngineIndexL(const TPresetName& aPresetName) const |
|
558 { |
|
559 TInt engineIndex = KErrNotFound; |
|
560 TInt count; |
|
561 |
|
562 TArray<TEfAudioEqualizerUtilityPreset> presets = iAudEqUtility->Presets(); |
|
563 TInt numPredefinedPresets = iAudEqUtility->NumberOfPreDefinedPresets(); |
|
564 TInt numPresets = presets.Count(); |
|
565 for (count = 0; count < numPresets; count++) |
|
566 { |
|
567 TPresetName selectedItem = iItemArray->MdcaPoint(count+1); |
|
568 TPresetName presetName = selectedItem.Right( |
|
569 selectedItem.Length() - iItemArray->GetPrefixLength()); |
|
570 |
|
571 |
|
572 if (((count < numPredefinedPresets) && (presetName == aPresetName)) |
|
573 || (presets[count].iPresetName == aPresetName)) |
|
574 { |
|
575 engineIndex = count; |
|
576 } |
|
577 } |
|
578 if (engineIndex == KErrNotFound) |
|
579 { |
|
580 // Leave if this function is called for preset "None" or a preset |
|
581 // which is there in the ListBox but not in the Engine. |
|
582 User::Leave(KErrArgument); |
|
583 } |
|
584 |
|
585 return engineIndex; |
|
586 } |
|
587 |
|
588 // ----------------------------------------------------------------------- |
|
589 // CEqualizerPresetsDialog::DisplaySettingsL |
|
590 // (CAudioEqualizerUtility *aAudEqUtility, TInt aIndex, |
|
591 // const TBool aIsActivePreset)) const |
|
592 // |
|
593 // This function is used to display the current equalizer settings |
|
594 // by creating a new dialog. The dialog can also be used for editing, etc. |
|
595 // of the settings. |
|
596 // ------------------------------------------------------------------------ |
|
597 // |
|
598 void CEqualizerPresetsDialog::DisplaySettingsL(CAudioEqualizerUtility* |
|
599 aAudEqUtility, const TInt aIndex, const TBool aIsActivePreset) |
|
600 { |
|
601 TRect rect = Rect(); |
|
602 |
|
603 TInt item; |
|
604 TPresetName preset = GetHighlightedPresetInListBox(); |
|
605 iItemArray->GetPresetKeyFromLocalisedName(item, preset); |
|
606 iEditingDialog = CEqualizerEditingDialog::NewL(aAudEqUtility, |
|
607 aIndex, rect, aIsActivePreset,iEqrPresetActObserver, item); |
|
608 iEditingDialog->ExecuteLD(); |
|
609 iEditingDialog = NULL; |
|
610 } |
|
611 |
|
612 // -------------------------------------------------------------- |
|
613 // CEqualizerPresetsDialog::CurrentPreset() |
|
614 // This function is used to read the currently active preset from |
|
615 // the central repository |
|
616 // -------------------------------------------------------------- |
|
617 // |
|
618 TPresetName CEqualizerPresetsDialog::CurrentPreset() const |
|
619 { |
|
620 TInt res = 0; |
|
621 TPresetName preset; |
|
622 User::LeaveIfError(iRepository->Get(KMPlayerEqPresetId, res)); |
|
623 iItemArray->GetLocalisedPresetNameFromKey(res,preset ); |
|
624 return preset; |
|
625 } |
|
626 |
|
627 // ---------------------------------------------------------------- |
|
628 // CEqualizerPresetsDialog::SetCurrentPreset(const TPtrC& aPreset) |
|
629 // This function is used to store the currently active preset into |
|
630 // the central repository |
|
631 // ---------------------------------------------------------------- |
|
632 // |
|
633 void CEqualizerPresetsDialog::SetCurrentPreset(const TPresetName& aPreset) |
|
634 { |
|
635 TInt activePresetKey; |
|
636 iActivePreset = aPreset; |
|
637 iItemArray->GetPresetKeyFromLocalisedName(activePresetKey, aPreset); |
|
638 iEqrPresetActObserver.HandlePresetActivation(activePresetKey); |
|
639 } |
|
640 |
|
641 // ---------------------------------------------------------------------------- |
|
642 // CEqualizerPresetsDialog::SearchPresetL(const TPresetName& aPreset) const |
|
643 // This function is used to search for a preset name in the ListBox. |
|
644 // It return the index of the preset, if found and KErrNotFound if not found. |
|
645 // ---------------------------------------------------------------------------- |
|
646 // |
|
647 TInt CEqualizerPresetsDialog::SearchPresetL(const TPresetName& aPreset) const |
|
648 { |
|
649 TInt ret = KErrNotFound; |
|
650 iItemArray->UpdateSortedArrayL(); |
|
651 |
|
652 for (TInt i=0; i<iItemArray->MdcaCount(); i++) |
|
653 { |
|
654 TPresetName selectedItem = iItemArray->MdcaPoint(i); |
|
655 TPresetName presetName = selectedItem.Right(selectedItem.Length() - iItemArray->GetPrefixLength()); |
|
656 |
|
657 if (aPreset == presetName) |
|
658 { |
|
659 ret = i; |
|
660 break; |
|
661 } |
|
662 } |
|
663 return ret; |
|
664 } |
|
665 |
|
666 // ---------------------------------------------------------------------------- |
|
667 // CEqualizerPresetsDialog::SetAudioEqualizerL(CAudioEqualizerUtility* |
|
668 // aAudEqUtility) |
|
669 // This function is used to set a new CAudioEqualizerUtility* |
|
670 // ---------------------------------------------------------------------------- |
|
671 // |
|
672 EXPORT_C void CEqualizerPresetsDialog::SetAudioEqualizerL( |
|
673 CAudioEqualizerUtility* aAudEqUtility) |
|
674 { |
|
675 iAudEqUtility=aAudEqUtility; |
|
676 if (iItemArray) |
|
677 { |
|
678 iItemArray->SetAudioEqualizer(iAudEqUtility); |
|
679 } |
|
680 |
|
681 if (iEditingDialog) |
|
682 { |
|
683 iEditingDialog->SetAudioEqualizerL(iAudEqUtility); |
|
684 } |
|
685 |
|
686 |
|
687 if (iAudEqUtility) |
|
688 { |
|
689 iIgnoreKeyEvents = EFalse; |
|
690 } |
|
691 else |
|
692 { |
|
693 iIgnoreKeyEvents = ETrue; |
|
694 } |
|
695 } |
|
696 |
|
697 // ---------------------------------------------------------------------- |
|
698 // CEqualizerPresets::GetListBoxIconsL() |
|
699 // This function is used to load the lisitbox icons into an array |
|
700 // ---------------------------------------------------------------------- |
|
701 // |
|
702 CArrayPtr<CGulIcon>* CEqualizerPresetsDialog::GetListBoxIconsL() const |
|
703 { |
|
704 // Get the icon array and deleted if already exists. Memory leak error. |
|
705 CArrayPtr<CGulIcon>* previcons = iListBox->ItemDrawer()->ColumnData()->IconArray(); |
|
706 if( previcons ) |
|
707 { |
|
708 previcons->ResetAndDestroy(); |
|
709 delete previcons; |
|
710 previcons = NULL; |
|
711 } |
|
712 |
|
713 // CGulIcon class packages two bitmaps: icon image and its mask |
|
714 // CAknIconArray inherits from CArrayPtrFlat |
|
715 CArrayPtr<CGulIcon>* iconList = new (ELeave) |
|
716 CAknIconArray(KEqualizerArrayGranularity); |
|
717 CleanupStack::PushL(iconList); |
|
718 |
|
719 // Find which drive this DLL is installed. |
|
720 TFileName fileName; |
|
721 // Get the full resource file |
|
722 TParse fp; |
|
723 // Add the resource dir |
|
724 fp.Set( KIconsFilename, &KDC_APP_BITMAP_DIR, NULL); |
|
725 |
|
726 // Get the filename with full path |
|
727 fileName = fp.FullName(); |
|
728 |
|
729 MAknsSkinInstance* skinInstance; |
|
730 CFbsBitmap* newIconBmp = NULL; |
|
731 CFbsBitmap* newIconBmpMask = NULL; |
|
732 CGulIcon* newIcon = NULL; |
|
733 |
|
734 skinInstance = AknsUtils::SkinInstance(); |
|
735 |
|
736 //creating blank icon |
|
737 AknsUtils::CreateIconLC(skinInstance,KAknsIIDQgnPropEmpty, |
|
738 newIconBmp,newIconBmpMask,fileName, |
|
739 EMbmEqualizerEmpty13x13, |
|
740 EMbmEqualizerEmpty13x13_mask); |
|
741 |
|
742 newIcon = CGulIcon::NewL(newIconBmp,newIconBmpMask); |
|
743 |
|
744 CleanupStack::Pop(2); |
|
745 CleanupStack::PushL(newIcon); |
|
746 iconList->AppendL(newIcon); |
|
747 |
|
748 CleanupStack::Pop(); |
|
749 |
|
750 //creating TICK mark icon |
|
751 AknsUtils::CreateIconLC(skinInstance,KAknsIIDQgnPropPslnActive, |
|
752 newIconBmp,newIconBmpMask,fileName, |
|
753 EMbmEqualizerQgn_prop_psln_active, |
|
754 EMbmEqualizerQgn_prop_psln_active_mask); |
|
755 |
|
756 |
|
757 newIcon = CGulIcon::NewL(newIconBmp,newIconBmpMask); |
|
758 |
|
759 CleanupStack::Pop(2); |
|
760 CleanupStack::PushL(newIcon); |
|
761 iconList->AppendL(newIcon); |
|
762 |
|
763 CleanupStack::Pop(); |
|
764 |
|
765 CleanupStack::Pop(iconList); |
|
766 |
|
767 newIconBmp = NULL; |
|
768 newIconBmpMask = NULL; |
|
769 newIcon = NULL; |
|
770 |
|
771 return iconList; |
|
772 } |
|
773 |
|
774 // ------------------------------------------------------------------- |
|
775 // CEqualizerPresetsDialog::ExecuteLD() |
|
776 // |
|
777 // This function is called to create a dialog |
|
778 // to display the preset list view of the equalizer |
|
779 // -------------------------------------------------------------------- |
|
780 // |
|
781 EXPORT_C TInt CEqualizerPresetsDialog::ExecuteLD() |
|
782 { |
|
783 TInt ret = CAknDialog::ExecuteLD(R_EQUALIZER_DIALOG); |
|
784 return ret; |
|
785 } |
|
786 |
|
787 // --------------------------------------------------------------------------- |
|
788 // void CEqualizerPresetsDialog::PreLayoutDynInitL(void) |
|
789 // This function is called just before the dialog is displayed |
|
790 // --------------------------------------------------------------------------- |
|
791 // |
|
792 void CEqualizerPresetsDialog::PreLayoutDynInitL(void) |
|
793 { |
|
794 |
|
795 CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane(); |
|
796 CAknTitlePane* tp=(CAknTitlePane*)sp->ControlL(TUid::Uid( |
|
797 EEikStatusPaneUidTitle)); |
|
798 // Store the Application's title text |
|
799 iAppTitleText = tp->Text()->AllocL(); |
|
800 |
|
801 // Set preset name in the title pane |
|
802 tp->SetTextL(*iTitleText); |
|
803 |
|
804 iPreviousStatusPaneLayout = sp->CurrentLayoutResId(); |
|
805 |
|
806 if ( sp ) |
|
807 { |
|
808 if ( R_AVKON_STATUS_PANE_LAYOUT_USUAL != iPreviousStatusPaneLayout ) |
|
809 { |
|
810 sp->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL ); |
|
811 } |
|
812 } |
|
813 iListBox= (CAknSingleGraphicStyleListBox*)Control(ESelectionListControl); |
|
814 iListBox->ItemDrawer()->ColumnData()->SetIconArray(GetListBoxIconsL()); |
|
815 |
|
816 // Set item array to listbox model |
|
817 iListBox->Model()->SetItemTextArray(iItemArray); |
|
818 // Item array is not owned by ListBox so it has to be freed. |
|
819 iListBox->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray); |
|
820 |
|
821 // |
|
822 // Create a scrollbar that will be displayed automatically |
|
823 // if all the items cannot be displayed on screen |
|
824 // |
|
825 iListBox->CreateScrollBarFrameL(ETrue); |
|
826 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
827 CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto); |
|
828 // Set focus to the currently active preset |
|
829 |
|
830 #ifdef RD_SCALABLE_UI_V2 |
|
831 iListBox->SetListBoxObserver(this); |
|
832 #endif //RD_SCALABLE_UI_V2 |
|
833 TPresetName currentPreset = CurrentPreset(); |
|
834 |
|
835 TInt cur = SearchPresetL(currentPreset); |
|
836 if (cur == KErrNotFound) //Some preset should always be active |
|
837 { |
|
838 User::Leave(KErrNotSupported); |
|
839 } |
|
840 iListBox->SetCurrentItemIndexAndDraw(cur); |
|
841 |
|
842 } |
|
843 |
|
844 // ------------------------------------------------------------------- |
|
845 // CEqualizerPresetsDialog::OkToExitL(TInt aButtonId) |
|
846 // |
|
847 // This function is called when the user presses the selection key |
|
848 // for displaying context sesitive menu |
|
849 // -------------------------------------------------------------------- |
|
850 // |
|
851 TBool CEqualizerPresetsDialog::OkToExitL(TInt aButtonId) |
|
852 { |
|
853 TBool ret = EFalse; |
|
854 if (aButtonId == EEikBidOk) |
|
855 { |
|
856 iContextSensitiveMenu = ETrue; |
|
857 DisplayMenuL(); |
|
858 } |
|
859 else if (aButtonId == EAknSoftkeyBack) |
|
860 { |
|
861 CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane(); |
|
862 CAknTitlePane* tp=(CAknTitlePane*)sp->ControlL(TUid::Uid( |
|
863 EEikStatusPaneUidTitle)); |
|
864 |
|
865 if (iAppTitleText) |
|
866 { |
|
867 //set application name in the title pane |
|
868 tp->SetTextL(*iAppTitleText); |
|
869 } |
|
870 ret = CAknDialog::OkToExitL( aButtonId ); |
|
871 } |
|
872 else if (aButtonId == EAknSoftkeySelect) |
|
873 { |
|
874 const TInt index = iListBox->CurrentItemIndex(); |
|
875 TPresetName preset = GetHighlightedPresetInListBox(); |
|
876 ActivateEqrPresetL(index, preset); |
|
877 } |
|
878 else |
|
879 { |
|
880 ret = CAknDialog::OkToExitL( aButtonId ); |
|
881 } |
|
882 |
|
883 if ( ret ) |
|
884 { |
|
885 // Restore landscape layout |
|
886 CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane(); |
|
887 if( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
888 { |
|
889 if ( sp && KErrNone != iPreviousStatusPaneLayout ) |
|
890 { |
|
891 if ( sp->CurrentLayoutResId() != R_AVKON_STATUS_PANE_LAYOUT_USUAL ) |
|
892 { |
|
893 sp->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL ); |
|
894 } |
|
895 } |
|
896 } |
|
897 else |
|
898 { |
|
899 CAknLocalScreenClearer* clearer = CAknLocalScreenClearer::NewLC( ETrue ); |
|
900 sp->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL_FLAT ); |
|
901 CleanupStack::PopAndDestroy( clearer ); |
|
902 } |
|
903 } |
|
904 return ret; |
|
905 } |
|
906 |
|
907 // ------------------------------------------------------------------- |
|
908 // void CEqualizerPresetsDialog::SizeChanged() |
|
909 // |
|
910 // This function is called by the framework whenever there is a change |
|
911 // in the size of the control |
|
912 // ------------------------------------------------------------------- |
|
913 // |
|
914 void CEqualizerPresetsDialog::SizeChanged() |
|
915 { |
|
916 TRect rect = Rect(); |
|
917 //Getting the layout for the list box |
|
918 AknLayoutUtils::LayoutControl(iListBox, rect, AknLayout::list_gen_pane(1)); |
|
919 CAknDialog::SizeChanged(); |
|
920 } |
|
921 |
|
922 // ------------------------------------------------------------------- |
|
923 // void CEqualizerPresetsDialog::HandleForegroundEventL( TBool aForeground) |
|
924 // |
|
925 // Handles changes to the application |
|
926 // when it switches to or from the foreground. |
|
927 // ------------------------------------------------------------------- |
|
928 // |
|
929 void CEqualizerPresetsDialog::HandleForegroundEventL( TBool aForeground) |
|
930 { |
|
931 if (aForeground) |
|
932 { |
|
933 CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane(); |
|
934 CAknTitlePane* tp=(CAknTitlePane*)sp->ControlL(TUid::Uid( |
|
935 EEikStatusPaneUidTitle)); |
|
936 tp->SetTextL(*iTitleText); |
|
937 } |
|
938 } |
|
939 |
|
940 // ------------------------------------------------------------------- |
|
941 // void CEqualizerPresetsDialog::FocusChanged(TDrawNow aDrawNow) |
|
942 // |
|
943 // Responds to a change in focus. |
|
944 // This is called whenever the control gains or loses focus |
|
945 // ------------------------------------------------------------------- |
|
946 // |
|
947 void CEqualizerPresetsDialog::FocusChanged(TDrawNow /*aDrawNow*/) |
|
948 { |
|
949 iItemArray->UpdateSortedArrayL(); |
|
950 TPresetName currentPreset = CurrentPreset(); |
|
951 iItemArray->SetCurrentActivePreset(currentPreset); |
|
952 |
|
953 if(iListBox) |
|
954 { |
|
955 iListBox->HandleItemAdditionL(); |
|
956 } |
|
957 } |
|
958 |
|
959 // ------------------------------------------------------------------- |
|
960 // void CEqualizerFreqBand::HandleResourceChangeL(TInt aType) |
|
961 // |
|
962 // This function is called by the framework whenever there is a |
|
963 // change in skin or layout |
|
964 // ------------------------------------------------------------------- |
|
965 // |
|
966 void CEqualizerPresetsDialog::HandleResourceChangeL(TInt aType) |
|
967 { |
|
968 if (aType == KAknsMessageSkinChange) |
|
969 { |
|
970 //Creating the icons for the new Skin |
|
971 iListBox->ItemDrawer()->ColumnData()->SetIconArray(GetListBoxIconsL()); |
|
972 iListBox->HandleResourceChange(aType); |
|
973 } |
|
974 |
|
975 else if (aType == KEikDynamicLayoutVariantSwitch) |
|
976 { |
|
977 TRect rect; |
|
978 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect); |
|
979 SetRect(rect); |
|
980 } |
|
981 |
|
982 } |
|
983 |
|
984 void CEqualizerPresetsDialog::HandleResourceChange(TInt aType) |
|
985 { |
|
986 CAknDialog::HandleResourceChange( aType ); |
|
987 HandleResourceChangeL(aType); |
|
988 } |
|
989 |
|
990 // --------------------------------------------------------- |
|
991 // CEqualizerPresetsDialog::OfferKeyEventL( |
|
992 // const TKeyEvent& aKeyEvent,TEventCode aType) |
|
993 // This function is used to handle key events |
|
994 // --------------------------------------------------------- |
|
995 // |
|
996 TKeyResponse CEqualizerPresetsDialog::OfferKeyEventL( |
|
997 const TKeyEvent& aKeyEvent, |
|
998 TEventCode aType ) |
|
999 { |
|
1000 if (iIgnoreKeyEvents) |
|
1001 { |
|
1002 return EKeyWasNotConsumed; |
|
1003 } |
|
1004 if (aType == EEventKey) |
|
1005 { |
|
1006 if (aKeyEvent.iCode == EKeyBackspace) |
|
1007 { |
|
1008 // Find the preset highlighted |
|
1009 const TInt listBoxIndex = iListBox->CurrentItemIndex(); |
|
1010 |
|
1011 // pre-defined presets cannot be deleted. |
|
1012 // preset "None" is not stored in engine. |
|
1013 if (listBoxIndex > (TInt) |
|
1014 (iAudEqUtility->NumberOfPreDefinedPresets())) |
|
1015 { |
|
1016 TPresetName preset = GetHighlightedPresetInListBox(); |
|
1017 DeleteEqrPresetL(listBoxIndex, preset); |
|
1018 } |
|
1019 return EKeyWasConsumed; |
|
1020 } |
|
1021 } |
|
1022 return CAknDialog::OfferKeyEventL( aKeyEvent, aType ); |
|
1023 } |
|
1024 |
|
1025 // --------------------------------------------------------------------------- |
|
1026 // CEqualizerPresetsDialog::DynInitMenuPaneL( |
|
1027 // TInt aResourceId,CEikMenuPane* aMenuPane) |
|
1028 // This function is called by the EIKON framework just before it displays |
|
1029 // a menu pane. Its default implementation is empty, and by overriding it, |
|
1030 // the application can set the state of menu items dynamically according |
|
1031 // to the state of application data. |
|
1032 // --------------------------------------------------------------------------- |
|
1033 // |
|
1034 void CEqualizerPresetsDialog::DynInitMenuPaneL( |
|
1035 TInt aResourceId, CEikMenuPane* aMenuPane) |
|
1036 { |
|
1037 TPresetName selectedItem = GetHighlightedPresetInListBox(); |
|
1038 |
|
1039 TInt selectedIndex = iListBox->CurrentItemIndex(); |
|
1040 TInt numberOfPreDefinedPresets = |
|
1041 iAudEqUtility->NumberOfPreDefinedPresets(); |
|
1042 |
|
1043 if ( aResourceId == R_EQUALIZER_CONTAINER_MENU) |
|
1044 { |
|
1045 //Is the menubar invoked from Options menu or selection key? |
|
1046 if (iContextSensitiveMenu == EFalse) |
|
1047 { |
|
1048 // The menubar is invoked from Options menu |
|
1049 iMenuBar->SetMenuType(CEikMenuBar::EMenuOptions); |
|
1050 // The selected preset is "None" |
|
1051 if (selectedItem.Compare(*iPresetNoneText) == 0) |
|
1052 { |
|
1053 aMenuPane->SetItemDimmed(EEqualizerCmdRename, ETrue); |
|
1054 aMenuPane->SetItemDimmed(EEqualizerCmdDelete, ETrue); |
|
1055 aMenuPane->SetItemDimmed(EEqualizerCmdEdit, ETrue); |
|
1056 } |
|
1057 // The selected preset is a pre defined preset other than "None" |
|
1058 if (selectedIndex <= numberOfPreDefinedPresets) |
|
1059 { |
|
1060 aMenuPane->SetItemDimmed(EEqualizerCmdRename, ETrue); |
|
1061 aMenuPane->SetItemDimmed(EEqualizerCmdDelete, ETrue); |
|
1062 } |
|
1063 // Help should be displayed only if the feature is supported |
|
1064 // according to Feature Manager |
|
1065 if (!FeatureManager::FeatureSupported(KFeatureIdHelp)) |
|
1066 { |
|
1067 aMenuPane->SetItemDimmed(EEqualizerCmdHelp, ETrue); |
|
1068 } |
|
1069 } |
|
1070 else |
|
1071 { |
|
1072 // The menubar is invoked from selection key |
|
1073 iMenuBar->SetMenuType(CEikMenuBar::EMenuContext); |
|
1074 // These Options are always hidden |
|
1075 aMenuPane->SetItemDimmed(EEqualizerCmdDelete, ETrue); |
|
1076 aMenuPane->SetItemDimmed(EEqualizerCmdRename, ETrue); |
|
1077 aMenuPane->SetItemDimmed(EEqualizerCmdCreateNew, ETrue); |
|
1078 aMenuPane->SetItemDimmed(EEqualizerCmdHelp, ETrue); |
|
1079 aMenuPane->SetItemDimmed(EAknCmdExit, ETrue); |
|
1080 |
|
1081 // The selected preset is "None" |
|
1082 if (selectedItem.Compare(*iPresetNoneText) == 0) |
|
1083 { |
|
1084 aMenuPane->SetItemDimmed(EEqualizerCmdEdit, ETrue); |
|
1085 } |
|
1086 iContextSensitiveMenu = EFalse; |
|
1087 } |
|
1088 } |
|
1089 } |
|
1090 |
|
1091 // ------------------------------------------------------------------- |
|
1092 // CEqualizerPresetsDialog::ProcessCommandL(TInt aCommandId ) |
|
1093 // |
|
1094 // This function is called to process the menubar command in a dialog |
|
1095 // -------------------------------------------------------------------- |
|
1096 // |
|
1097 void CEqualizerPresetsDialog::ProcessCommandL(TInt aCommandId ) |
|
1098 { |
|
1099 // Need to do this in all cases or menu does not disappear after |
|
1100 // a selection is made |
|
1101 CAknDialog::ProcessCommandL(aCommandId); |
|
1102 |
|
1103 // Find the preset highlighted |
|
1104 const TInt index = iListBox->CurrentItemIndex(); |
|
1105 TPresetName preset = GetHighlightedPresetInListBox(); |
|
1106 |
|
1107 switch(aCommandId) |
|
1108 { |
|
1109 case EAknCmdExit : |
|
1110 case EEikCmdExit : |
|
1111 { |
|
1112 iAvkonAppUi->HandleCommandL( aCommandId ); |
|
1113 break; |
|
1114 } |
|
1115 case EEqualizerCmdEdit: |
|
1116 { |
|
1117 EditEqrPresetL(index, preset); |
|
1118 break; |
|
1119 } |
|
1120 case EEqualizerCmdActivate: |
|
1121 { |
|
1122 ActivateEqrPresetL(index, preset); |
|
1123 break; |
|
1124 } |
|
1125 case EEqualizerCmdCreateNew: |
|
1126 { |
|
1127 TInt presetIndex = -1; |
|
1128 TPresetName presetName; |
|
1129 |
|
1130 CreateNewEqrPresetL(presetIndex, presetName); |
|
1131 |
|
1132 if (presetIndex != -1) |
|
1133 { |
|
1134 // A valid preset name has been entered |
|
1135 EditEqrPresetL(presetIndex, presetName); |
|
1136 } |
|
1137 break; |
|
1138 } |
|
1139 |
|
1140 case EEqualizerCmdDelete: |
|
1141 { |
|
1142 DeleteEqrPresetL(index, preset); |
|
1143 break; |
|
1144 } |
|
1145 |
|
1146 case EEqualizerCmdRename: |
|
1147 { |
|
1148 RenameEqrPresetL(index, preset); |
|
1149 break; |
|
1150 } |
|
1151 |
|
1152 case EEqualizerCmdHelp: |
|
1153 { |
|
1154 HlpLauncher::LaunchHelpApplicationL |
|
1155 ( iEikonEnv->WsSession(), |
|
1156 CEikonEnv::Static()->AppUi()->AppHelpContextL() ); |
|
1157 break; |
|
1158 } |
|
1159 |
|
1160 default: |
|
1161 { |
|
1162 break; |
|
1163 } |
|
1164 } |
|
1165 } |
|
1166 |
|
1167 // ------------------------------------------------------------------- |
|
1168 // void CEqualizerPresetsDialog::GetHelpContext( |
|
1169 // TCoeHelpContext& aContext ) const |
|
1170 // Get help context for the control |
|
1171 // -------------------------------------------------------------------- |
|
1172 // |
|
1173 void CEqualizerPresetsDialog::GetHelpContext( |
|
1174 TCoeHelpContext& aContext ) const |
|
1175 { |
|
1176 aContext.iMajor = KUidEqualizer; |
|
1177 aContext.iContext = KEQ_HLP_LIST_VIEW; |
|
1178 } |
|
1179 |
|
1180 // ------------------------------------------------------------------- |
|
1181 // void CEqualizerPresetsDialog::ShowDiskFullNoteL() |
|
1182 // This function is used to display a note to the user if |
|
1183 // memory is below critical level when creating a new preset. |
|
1184 // -------------------------------------------------------------------- |
|
1185 // |
|
1186 void CEqualizerPresetsDialog::ShowDiskFullNoteL() const |
|
1187 { |
|
1188 HBufC* message = NULL; |
|
1189 message = StringLoader::LoadLC(R_QTN_MEMLO_NOT_ENOUGH_MEMORY); |
|
1190 |
|
1191 CAknGlobalNote* note = CAknGlobalNote::NewLC(); |
|
1192 note->SetSoftkeys(R_AVKON_SOFTKEYS_OK_EMPTY); |
|
1193 note->ShowNoteL(/*status,*/ EAknGlobalErrorNote, *message); |
|
1194 |
|
1195 CleanupStack::PopAndDestroy(note); // note, message |
|
1196 CleanupStack::PopAndDestroy(message); // note, message |
|
1197 } |
|
1198 |
|
1199 #ifdef RD_SCALABLE_UI_V2 |
|
1200 // ------------------------------------------------------------------- |
|
1201 // void CEqualizerPresetsDialog::HandleListBoxEventL |
|
1202 // This function callback from MEikListBoxObserver when a listbox item |
|
1203 // is double clicked using a pen input . |
|
1204 // -------------------------------------------------------------------- |
|
1205 // |
|
1206 void CEqualizerPresetsDialog::HandleListBoxEventL( |
|
1207 CEikListBox* /*aListBox*/, |
|
1208 TListBoxEvent aEventType ) |
|
1209 { |
|
1210 switch ( aEventType ) |
|
1211 { |
|
1212 #ifdef SINGLE_CLICK_INCLUDED |
|
1213 case EEventItemSingleClicked: |
|
1214 #endif |
|
1215 case EEventItemDoubleClicked: |
|
1216 { |
|
1217 const TInt index = iListBox->CurrentItemIndex(); |
|
1218 TPresetName preset = GetHighlightedPresetInListBox(); |
|
1219 ActivateEqrPresetL(index, preset); |
|
1220 break; |
|
1221 } |
|
1222 default: |
|
1223 break; |
|
1224 } |
|
1225 } |
|
1226 #endif //RD_SCALABLE_UI_V2 |
|
1227 // End of File |
|
1228 |