author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 15 Sep 2010 12:47:14 +0300 | |
branch | RCL_3 |
changeset 54 | 53984cc2f70a |
parent 46 | 0ac9a5310753 |
permissions | -rw-r--r-- |
46 | 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 |
// As per 9.2 Spec, No activation note should be shown |
|
336 |
||
337 |
/*HBufC* activateNoteText = StringLoader::LoadLC( |
|
338 |
R_QTN_EQ_NOTE_INFO_PRESET_ACTIVATED, aPreset); |
|
339 |
CAknConfirmationNote* dialog = new(ELeave)CAknConfirmationNote(); |
|
340 |
dialog->ExecuteLD(*activateNoteText); |
|
341 |
CleanupStack::PopAndDestroy(activateNoteText); */ |
|
342 |
||
343 |
// Inform the engine |
|
344 |
if (aPreset.Compare(*iPresetNoneText) == 0) |
|
345 |
{ |
|
346 |
TRAP(err, iAudEqUtility->DisableEqualizerL()); |
|
347 |
} |
|
348 |
else |
|
349 |
{ |
|
350 |
TRAP(err, iAudEqUtility->ApplyPresetL(GetEngineIndexL(aPreset))); |
|
351 |
} |
|
352 |
||
353 |
if(!err) |
|
354 |
{ |
|
355 |
iListBox->HandleItemAdditionL(); |
|
356 |
iListBox->SetCurrentItemIndexAndDraw(aIndex); |
|
357 |
// To prevent two tickmarks from appearing sometimes |
|
358 |
iListBox->DrawNow(); |
|
359 |
} |
|
360 |
else |
|
361 |
{ |
|
362 |
#ifdef _DEBUG |
|
363 |
RDebug::Print(_L("CEqualizerPresetsDialog::ActivateEqrPresetL err = %d "), err); |
|
364 |
#endif |
|
365 |
// To prevent multiple tickmarks from appearing |
|
366 |
iListBox->DrawNow(); |
|
367 |
} |
|
368 |
} |
|
369 |
||
370 |
// --------------------------------------------------------------------------- |
|
371 |
//void CEqualizerPresetsDialog::RenameEqrPresetL(const TInt aIndex, |
|
372 |
//const TDesC& aPreset) const |
|
373 |
// |
|
374 |
//This function is used for the renaming of a preset |
|
375 |
// --------------------------------------------------------------------------- |
|
376 |
// |
|
377 |
void CEqualizerPresetsDialog::RenameEqrPresetL(const TInt /*aIndex*/, |
|
378 |
const TDesC& aPreset) |
|
379 |
{ |
|
380 |
//Check if this is an active preset |
|
381 |
TPresetName activePresetName = CurrentPreset(); |
|
382 |
if (aPreset.Compare(activePresetName) == 0) |
|
383 |
{ |
|
384 |
//Display Confirmation note |
|
385 |
HBufC* renameText = StringLoader::LoadLC( |
|
386 |
R_QTN_EQ_NOTE_ERR_PRESET_IN_USE_NO_RENAME); |
|
387 |
CAknErrorNote* dialog = new(ELeave)CAknErrorNote(); |
|
388 |
dialog->ExecuteLD(*renameText); |
|
389 |
CleanupStack::PopAndDestroy(renameText); |
|
390 |
} |
|
391 |
else |
|
392 |
{ |
|
393 |
TPresetName presetName; |
|
394 |
presetName = aPreset; |
|
395 |
TBool nameEnteredIsFine = |
|
396 |
GetNewNameL(R_DIALOG_TEXT_RENAME_ITEM_NAME, presetName); |
|
397 |
||
398 |
if (nameEnteredIsFine) |
|
399 |
{ |
|
400 |
TInt engineIndex = GetEngineIndexL(aPreset); |
|
401 |
//Update Engine |
|
402 |
iAudEqUtility->GetPresetL(engineIndex); |
|
403 |
CAudioEqualizer& audioEqualizer = iAudEqUtility->Equalizer(); |
|
404 |
||
405 |
iAudEqUtility->ModifyPresetL(engineIndex,presetName, |
|
406 |
audioEqualizer); |
|
407 |
||
408 |
//Update listbox |
|
409 |
// Sort the array of user-defined presets |
|
410 |
iItemArray->UpdateSortedArrayL(); |
|
411 |
iListBox->SetCurrentItemIndex(SearchPresetL(presetName)); |
|
412 |
iListBox->DrawNow(); |
|
413 |
} |
|
414 |
} |
|
415 |
} |
|
416 |
||
417 |
// --------------------------------------------------------------------------- |
|
418 |
// void CEqualizerPresetsDialog::EditEqrPresetL(const TInt aIndex, |
|
419 |
// const TDesC& aPreset) const |
|
420 |
// |
|
421 |
// This function is used for the editing of a preset |
|
422 |
// --------------------------------------------------------------------------- |
|
423 |
// |
|
424 |
void CEqualizerPresetsDialog::EditEqrPresetL(const TInt /*aIndex*/, |
|
425 |
const TDesC& aPreset) |
|
426 |
{ |
|
427 |
//Set application name in the title pane to preset name. |
|
428 |
CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane(); |
|
429 |
CAknTitlePane* tp=(CAknTitlePane*)sp->ControlL(TUid::Uid( |
|
430 |
EEikStatusPaneUidTitle)); |
|
431 |
tp->SetTextL(aPreset); |
|
432 |
TInt engineIndex = GetEngineIndexL(aPreset); |
|
433 |
//Update Engine |
|
434 |
TBool isActivePreset = (aPreset==CurrentPreset()); |
|
435 |
||
436 |
DisplaySettingsL(iAudEqUtility, engineIndex, isActivePreset); |
|
437 |
} |
|
438 |
||
439 |
// --------------------------------------------------------------------------- |
|
440 |
// void CEqualizerPresetsDialog::CreateNewEqrPresetL(TInt& aIndex, |
|
441 |
// TPresetName& aPreset) const |
|
442 |
// |
|
443 |
// This function is used for the creation of a new preset. |
|
444 |
// @param aIndex The index of the preset in the ListBox. This is set |
|
445 |
// to a the index in the ListBox if preset creation is successful. |
|
446 |
// If the creation is unscuccessful, then the parameter is not changed. |
|
447 |
// @param aPreset The name of the preset created |
|
448 |
// --------------------------------------------------------------------------- |
|
449 |
// |
|
450 |
void CEqualizerPresetsDialog::CreateNewEqrPresetL(TInt& aIndex, |
|
451 |
TPresetName& aPreset) const |
|
452 |
{ |
|
453 |
RFs fs; |
|
454 |
User::LeaveIfError( fs.Connect() ); |
|
455 |
CleanupClosePushL<RFs>( fs ); |
|
456 |
||
457 |
if (SysUtil::FFSSpaceBelowCriticalLevelL(&fs,0)) |
|
458 |
{ |
|
459 |
ShowDiskFullNoteL(); // Phone memory full, show note |
|
460 |
} |
|
461 |
else |
|
462 |
{ |
|
463 |
TPresetName presetName; |
|
464 |
BuildPresetNameL(presetName); |
|
465 |
||
466 |
TBool nameEnteredIsFine = GetNewNameL(R_DIALOG_TEXT_NEW_ITEM_NAME, |
|
467 |
presetName); |
|
468 |
||
469 |
if (nameEnteredIsFine) |
|
470 |
{ |
|
471 |
//Update Engine |
|
472 |
CAudioEqualizer& audioEqualizer = iAudEqUtility->Equalizer(); |
|
473 |
iAudEqUtility->CreatePresetL(presetName, audioEqualizer); |
|
474 |
||
475 |
//Set the level of all bands to 0. |
|
476 |
TInt numFreqBand = audioEqualizer.NumberOfBands(); |
|
477 |
for (TInt i = 0; i < numFreqBand; i++) |
|
478 |
{ |
|
479 |
audioEqualizer.SetBandLevelL(i+1, 0); |
|
480 |
} |
|
481 |
||
482 |
iItemArray->UpdateSortedArrayL(); |
|
483 |
//Update AudioEqualizerUtility object, setting the level of all |
|
484 |
// bands to 0 |
|
485 |
iAudEqUtility->ModifyPresetL(GetEngineIndexL(presetName), |
|
486 |
presetName, audioEqualizer); |
|
487 |
||
488 |
//Set the focus to the new preset |
|
489 |
iListBox->HandleItemAdditionL(); |
|
490 |
iListBox->SetCurrentItemIndex(SearchPresetL(presetName)); |
|
491 |
iListBox->DrawNow(); |
|
492 |
||
493 |
aPreset = presetName; |
|
494 |
aIndex = iItemArray->MdcaCount()-1; |
|
495 |
} |
|
496 |
} |
|
497 |
CleanupStack::PopAndDestroy(); |
|
498 |
} |
|
499 |
||
500 |
// --------------------------------------------------------------------------- |
|
501 |
//void CEqualizerPresetsDialog::DeleteEqrPresetL(const TInt aIndex, |
|
502 |
//const TDesC& aPreset) const |
|
503 |
// |
|
504 |
//This function is used for the deletion of a preset |
|
505 |
// --------------------------------------------------------------------------- |
|
506 |
// |
|
507 |
void CEqualizerPresetsDialog::DeleteEqrPresetL(const TInt aIndex, |
|
508 |
const TDesC& aPreset) |
|
509 |
{ |
|
510 |
//Check if this is an active preset |
|
511 |
TPresetName activePresetName = CurrentPreset(); |
|
512 |
if (aPreset.Compare(activePresetName) == 0) |
|
513 |
{ |
|
514 |
//Display error note |
|
515 |
HBufC* renameText = |
|
516 |
StringLoader::LoadLC(R_QTN_EQ_NOTE_ERR_PRESET_IN_USE); |
|
517 |
CAknErrorNote* dialog = new(ELeave)CAknErrorNote(); |
|
518 |
dialog->ExecuteLD(*renameText); |
|
519 |
CleanupStack::PopAndDestroy(renameText); |
|
520 |
} |
|
521 |
else |
|
522 |
{ |
|
523 |
//Delete?\n%U" §qtn.query.common.conf.delete? |
|
524 |
HBufC* text = |
|
525 |
StringLoader::LoadLC( R_QTN_QUERY_COMMON_CONF_DELETE, |
|
526 |
aPreset); |
|
527 |
||
528 |
// Show confirmation note |
|
529 |
CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
530 |
TInt result( |
|
531 |
dlg->ExecuteLD( R_EQUALIZER_CONFIRMATION_QUERY, *text ) ); |
|
532 |
CleanupStack::PopAndDestroy(text); // text |
|
533 |
||
534 |
if ( result ) |
|
535 |
{ |
|
536 |
//Update Engine |
|
537 |
iAudEqUtility->DeletePresetL(GetEngineIndexL(aPreset)); |
|
538 |
//Remove from listbox |
|
539 |
iItemArray->UpdateSortedArrayL(); |
|
540 |
iListBox->HandleItemRemovalL(); |
|
541 |
// This is to avoid the gap observed when the last entry present |
|
542 |
// in the Preset List is deleted |
|
543 |
iListBox->SetCurrentItemIndexAndDraw(0); |
|
544 |
//If we are at the last preset set focus to the next preset |
|
545 |
// else the previous preset |
|
546 |
if (aIndex == iItemArray->MdcaCount()) |
|
547 |
{ |
|
548 |
iListBox->SetCurrentItemIndexAndDraw(aIndex - 1); |
|
549 |
} |
|
550 |
else |
|
551 |
{ |
|
552 |
iListBox->SetCurrentItemIndexAndDraw(aIndex); |
|
553 |
} |
|
554 |
iListBox->DrawNow(); |
|
555 |
} |
|
556 |
} |
|
557 |
} |
|
558 |
||
559 |
// ------------------------------------------------------------------- |
|
560 |
// TInt CEqualizerPresetsDialog::GetEngineIndexL |
|
561 |
// (const TPresetName& aPresetName) |
|
562 |
// |
|
563 |
// This function is called to find the index of a preset in the list of |
|
564 |
// presets returned by CAudioEqualizerUtility::Presets() |
|
565 |
// -------------------------------------------------------------------- |
|
566 |
// |
|
567 |
TInt CEqualizerPresetsDialog::GetEngineIndexL(const TPresetName& aPresetName) const |
|
568 |
{ |
|
569 |
TInt engineIndex = KErrNotFound; |
|
570 |
TInt count; |
|
571 |
||
572 |
TArray<TEfAudioEqualizerUtilityPreset> presets = iAudEqUtility->Presets(); |
|
573 |
TInt numPredefinedPresets = iAudEqUtility->NumberOfPreDefinedPresets(); |
|
574 |
TInt numPresets = presets.Count(); |
|
575 |
for (count = 0; count < numPresets; count++) |
|
576 |
{ |
|
577 |
TPresetName selectedItem = iItemArray->MdcaPoint(count+1); |
|
578 |
TPresetName presetName = selectedItem.Right( |
|
579 |
selectedItem.Length() - iItemArray->GetPrefixLength()); |
|
580 |
||
581 |
||
582 |
if (((count < numPredefinedPresets) && (presetName == aPresetName)) |
|
583 |
|| (presets[count].iPresetName == aPresetName)) |
|
584 |
{ |
|
585 |
engineIndex = count; |
|
586 |
} |
|
587 |
} |
|
588 |
if (engineIndex == KErrNotFound) |
|
589 |
{ |
|
590 |
// Leave if this function is called for preset "None" or a preset |
|
591 |
// which is there in the ListBox but not in the Engine. |
|
592 |
User::Leave(KErrArgument); |
|
593 |
} |
|
594 |
||
595 |
return engineIndex; |
|
596 |
} |
|
597 |
||
598 |
// ----------------------------------------------------------------------- |
|
599 |
// CEqualizerPresetsDialog::DisplaySettingsL |
|
600 |
// (CAudioEqualizerUtility *aAudEqUtility, TInt aIndex, |
|
601 |
// const TBool aIsActivePreset)) const |
|
602 |
// |
|
603 |
// This function is used to display the current equalizer settings |
|
604 |
// by creating a new dialog. The dialog can also be used for editing, etc. |
|
605 |
// of the settings. |
|
606 |
// ------------------------------------------------------------------------ |
|
607 |
// |
|
608 |
void CEqualizerPresetsDialog::DisplaySettingsL(CAudioEqualizerUtility* |
|
609 |
aAudEqUtility, const TInt aIndex, const TBool aIsActivePreset) |
|
610 |
{ |
|
611 |
TRect rect = Rect(); |
|
612 |
||
613 |
TInt item; |
|
614 |
TPresetName preset = GetHighlightedPresetInListBox(); |
|
615 |
iItemArray->GetPresetKeyFromLocalisedName(item, preset); |
|
616 |
iEditingDialog = CEqualizerEditingDialog::NewL(aAudEqUtility, |
|
617 |
aIndex, rect, aIsActivePreset,iEqrPresetActObserver, item); |
|
618 |
iEditingDialog->ExecuteLD(); |
|
619 |
iEditingDialog = NULL; |
|
620 |
} |
|
621 |
||
622 |
// -------------------------------------------------------------- |
|
623 |
// CEqualizerPresetsDialog::CurrentPreset() |
|
624 |
// This function is used to read the currently active preset from |
|
625 |
// the central repository |
|
626 |
// -------------------------------------------------------------- |
|
627 |
// |
|
628 |
TPresetName CEqualizerPresetsDialog::CurrentPreset() const |
|
629 |
{ |
|
630 |
TInt res = 0; |
|
631 |
TPresetName preset; |
|
632 |
User::LeaveIfError(iRepository->Get(KMPlayerEqPresetId, res)); |
|
633 |
iItemArray->GetLocalisedPresetNameFromKey(res,preset ); |
|
634 |
return preset; |
|
635 |
} |
|
636 |
||
637 |
// ---------------------------------------------------------------- |
|
638 |
// CEqualizerPresetsDialog::SetCurrentPreset(const TPtrC& aPreset) |
|
639 |
// This function is used to store the currently active preset into |
|
640 |
// the central repository |
|
641 |
// ---------------------------------------------------------------- |
|
642 |
// |
|
643 |
void CEqualizerPresetsDialog::SetCurrentPreset(const TPresetName& aPreset) |
|
644 |
{ |
|
645 |
TInt activePresetKey; |
|
646 |
iActivePreset = aPreset; |
|
647 |
iItemArray->GetPresetKeyFromLocalisedName(activePresetKey, aPreset); |
|
648 |
iEqrPresetActObserver.HandlePresetActivation(activePresetKey); |
|
649 |
} |
|
650 |
||
651 |
// ---------------------------------------------------------------------------- |
|
652 |
// CEqualizerPresetsDialog::SearchPresetL(const TPresetName& aPreset) const |
|
653 |
// This function is used to search for a preset name in the ListBox. |
|
654 |
// It return the index of the preset, if found and KErrNotFound if not found. |
|
655 |
// ---------------------------------------------------------------------------- |
|
656 |
// |
|
657 |
TInt CEqualizerPresetsDialog::SearchPresetL(const TPresetName& aPreset) const |
|
658 |
{ |
|
659 |
TInt ret = KErrNotFound; |
|
660 |
iItemArray->UpdateSortedArrayL(); |
|
661 |
||
662 |
for (TInt i=0; i<iItemArray->MdcaCount(); i++) |
|
663 |
{ |
|
664 |
TPresetName selectedItem = iItemArray->MdcaPoint(i); |
|
665 |
TPresetName presetName = selectedItem.Right(selectedItem.Length() - iItemArray->GetPrefixLength()); |
|
666 |
||
667 |
if (aPreset == presetName) |
|
668 |
{ |
|
669 |
ret = i; |
|
670 |
break; |
|
671 |
} |
|
672 |
} |
|
673 |
return ret; |
|
674 |
} |
|
675 |
||
676 |
// ---------------------------------------------------------------------------- |
|
677 |
// CEqualizerPresetsDialog::SetAudioEqualizerL(CAudioEqualizerUtility* |
|
678 |
// aAudEqUtility) |
|
679 |
// This function is used to set a new CAudioEqualizerUtility* |
|
680 |
// ---------------------------------------------------------------------------- |
|
681 |
// |
|
682 |
EXPORT_C void CEqualizerPresetsDialog::SetAudioEqualizerL( |
|
683 |
CAudioEqualizerUtility* aAudEqUtility) |
|
684 |
{ |
|
685 |
iAudEqUtility=aAudEqUtility; |
|
686 |
if (iItemArray) |
|
687 |
{ |
|
688 |
iItemArray->SetAudioEqualizer(iAudEqUtility); |
|
689 |
} |
|
690 |
||
691 |
if (iEditingDialog) |
|
692 |
{ |
|
693 |
iEditingDialog->SetAudioEqualizerL(iAudEqUtility); |
|
694 |
} |
|
695 |
||
696 |
||
697 |
if (iAudEqUtility) |
|
698 |
{ |
|
699 |
iIgnoreKeyEvents = EFalse; |
|
700 |
} |
|
701 |
else |
|
702 |
{ |
|
703 |
iIgnoreKeyEvents = ETrue; |
|
704 |
} |
|
705 |
} |
|
706 |
||
707 |
// ---------------------------------------------------------------------- |
|
708 |
// CEqualizerPresets::GetListBoxIconsL() |
|
709 |
// This function is used to load the lisitbox icons into an array |
|
710 |
// ---------------------------------------------------------------------- |
|
711 |
// |
|
712 |
CArrayPtr<CGulIcon>* CEqualizerPresetsDialog::GetListBoxIconsL() const |
|
713 |
{ |
|
714 |
// Get the icon array and deleted if already exists. Memory leak error. |
|
715 |
CArrayPtr<CGulIcon>* previcons = iListBox->ItemDrawer()->ColumnData()->IconArray(); |
|
716 |
if( previcons ) |
|
717 |
{ |
|
718 |
previcons->ResetAndDestroy(); |
|
719 |
delete previcons; |
|
720 |
previcons = NULL; |
|
721 |
} |
|
722 |
||
723 |
// CGulIcon class packages two bitmaps: icon image and its mask |
|
724 |
// CAknIconArray inherits from CArrayPtrFlat |
|
725 |
CArrayPtr<CGulIcon>* iconList = new (ELeave) |
|
726 |
CAknIconArray(KEqualizerArrayGranularity); |
|
727 |
CleanupStack::PushL(iconList); |
|
728 |
||
729 |
// Find which drive this DLL is installed. |
|
730 |
TFileName fileName; |
|
731 |
// Get the full resource file |
|
732 |
TParse fp; |
|
733 |
// Add the resource dir |
|
734 |
fp.Set( KIconsFilename, &KDC_APP_BITMAP_DIR, NULL); |
|
735 |
||
736 |
// Get the filename with full path |
|
737 |
fileName = fp.FullName(); |
|
738 |
||
739 |
MAknsSkinInstance* skinInstance; |
|
740 |
CFbsBitmap* newIconBmp = NULL; |
|
741 |
CFbsBitmap* newIconBmpMask = NULL; |
|
742 |
CGulIcon* newIcon = NULL; |
|
743 |
||
744 |
skinInstance = AknsUtils::SkinInstance(); |
|
745 |
||
746 |
//creating blank icon |
|
747 |
AknsUtils::CreateIconLC(skinInstance,KAknsIIDQgnPropEmpty, |
|
748 |
newIconBmp,newIconBmpMask,fileName, |
|
749 |
EMbmEqualizerEmpty13x13, |
|
750 |
EMbmEqualizerEmpty13x13_mask); |
|
751 |
||
752 |
newIcon = CGulIcon::NewL(newIconBmp,newIconBmpMask); |
|
753 |
||
754 |
CleanupStack::Pop(2); |
|
755 |
CleanupStack::PushL(newIcon); |
|
756 |
iconList->AppendL(newIcon); |
|
757 |
||
758 |
CleanupStack::Pop(); |
|
759 |
||
760 |
//creating TICK mark icon |
|
761 |
AknsUtils::CreateIconLC(skinInstance,KAknsIIDQgnPropPslnActive, |
|
762 |
newIconBmp,newIconBmpMask,fileName, |
|
763 |
EMbmEqualizerQgn_prop_psln_active, |
|
764 |
EMbmEqualizerQgn_prop_psln_active_mask); |
|
765 |
||
766 |
||
767 |
newIcon = CGulIcon::NewL(newIconBmp,newIconBmpMask); |
|
768 |
||
769 |
CleanupStack::Pop(2); |
|
770 |
CleanupStack::PushL(newIcon); |
|
771 |
iconList->AppendL(newIcon); |
|
772 |
||
773 |
CleanupStack::Pop(); |
|
774 |
||
775 |
CleanupStack::Pop(iconList); |
|
776 |
||
777 |
newIconBmp = NULL; |
|
778 |
newIconBmpMask = NULL; |
|
779 |
newIcon = NULL; |
|
780 |
||
781 |
return iconList; |
|
782 |
} |
|
783 |
||
784 |
// ------------------------------------------------------------------- |
|
785 |
// CEqualizerPresetsDialog::ExecuteLD() |
|
786 |
// |
|
787 |
// This function is called to create a dialog |
|
788 |
// to display the preset list view of the equalizer |
|
789 |
// -------------------------------------------------------------------- |
|
790 |
// |
|
791 |
EXPORT_C TInt CEqualizerPresetsDialog::ExecuteLD() |
|
792 |
{ |
|
793 |
TInt ret = CAknDialog::ExecuteLD(R_EQUALIZER_DIALOG); |
|
794 |
return ret; |
|
795 |
} |
|
796 |
||
797 |
// --------------------------------------------------------------------------- |
|
798 |
// void CEqualizerPresetsDialog::PreLayoutDynInitL(void) |
|
799 |
// This function is called just before the dialog is displayed |
|
800 |
// --------------------------------------------------------------------------- |
|
801 |
// |
|
802 |
void CEqualizerPresetsDialog::PreLayoutDynInitL(void) |
|
803 |
{ |
|
804 |
||
805 |
CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane(); |
|
806 |
CAknTitlePane* tp=(CAknTitlePane*)sp->ControlL(TUid::Uid( |
|
807 |
EEikStatusPaneUidTitle)); |
|
808 |
// Store the Application's title text |
|
809 |
iAppTitleText = tp->Text()->AllocL(); |
|
810 |
||
811 |
// Set preset name in the title pane |
|
812 |
tp->SetTextL(*iTitleText); |
|
813 |
||
814 |
iPreviousStatusPaneLayout = sp->CurrentLayoutResId(); |
|
815 |
||
816 |
if ( sp ) |
|
817 |
{ |
|
818 |
if ( R_AVKON_STATUS_PANE_LAYOUT_USUAL != iPreviousStatusPaneLayout ) |
|
819 |
{ |
|
820 |
sp->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL ); |
|
821 |
} |
|
822 |
} |
|
823 |
iListBox= (CAknSingleGraphicStyleListBox*)Control(ESelectionListControl); |
|
824 |
iListBox->ItemDrawer()->ColumnData()->SetIconArray(GetListBoxIconsL()); |
|
825 |
||
826 |
// Set item array to listbox model |
|
827 |
iListBox->Model()->SetItemTextArray(iItemArray); |
|
828 |
// Item array is not owned by ListBox so it has to be freed. |
|
829 |
iListBox->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray); |
|
830 |
||
831 |
// |
|
832 |
// Create a scrollbar that will be displayed automatically |
|
833 |
// if all the items cannot be displayed on screen |
|
834 |
// |
|
835 |
iListBox->CreateScrollBarFrameL(ETrue); |
|
836 |
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
837 |
CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto); |
|
838 |
// Set focus to the currently active preset |
|
839 |
||
840 |
#ifdef RD_SCALABLE_UI_V2 |
|
841 |
iListBox->SetListBoxObserver(this); |
|
842 |
#endif //RD_SCALABLE_UI_V2 |
|
843 |
TPresetName currentPreset = CurrentPreset(); |
|
844 |
||
845 |
TInt cur = SearchPresetL(currentPreset); |
|
846 |
if (cur == KErrNotFound) //Some preset should always be active |
|
847 |
{ |
|
848 |
User::Leave(KErrNotSupported); |
|
849 |
} |
|
850 |
iListBox->SetCurrentItemIndexAndDraw(cur); |
|
851 |
||
852 |
} |
|
853 |
||
854 |
// ------------------------------------------------------------------- |
|
855 |
// CEqualizerPresetsDialog::OkToExitL(TInt aButtonId) |
|
856 |
// |
|
857 |
// This function is called when the user presses the selection key |
|
858 |
// for displaying context sesitive menu |
|
859 |
// -------------------------------------------------------------------- |
|
860 |
// |
|
861 |
TBool CEqualizerPresetsDialog::OkToExitL(TInt aButtonId) |
|
862 |
{ |
|
863 |
TBool ret = EFalse; |
|
864 |
if (aButtonId == EEikBidOk) |
|
865 |
{ |
|
866 |
iContextSensitiveMenu = ETrue; |
|
867 |
DisplayMenuL(); |
|
868 |
} |
|
869 |
else if (aButtonId == EAknSoftkeyBack) |
|
870 |
{ |
|
871 |
CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane(); |
|
872 |
CAknTitlePane* tp=(CAknTitlePane*)sp->ControlL(TUid::Uid( |
|
873 |
EEikStatusPaneUidTitle)); |
|
874 |
||
875 |
if (iAppTitleText) |
|
876 |
{ |
|
877 |
//set application name in the title pane |
|
878 |
tp->SetTextL(*iAppTitleText); |
|
879 |
} |
|
880 |
ret = CAknDialog::OkToExitL( aButtonId ); |
|
881 |
} |
|
882 |
else if (aButtonId == EAknSoftkeySelect) |
|
883 |
{ |
|
884 |
const TInt index = iListBox->CurrentItemIndex(); |
|
885 |
TPresetName preset = GetHighlightedPresetInListBox(); |
|
886 |
ActivateEqrPresetL(index, preset); |
|
887 |
} |
|
888 |
else |
|
889 |
{ |
|
890 |
ret = CAknDialog::OkToExitL( aButtonId ); |
|
891 |
} |
|
892 |
||
893 |
if ( ret ) |
|
894 |
{ |
|
895 |
// Restore landscape layout |
|
896 |
CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane(); |
|
897 |
if( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
898 |
{ |
|
899 |
if ( sp && KErrNone != iPreviousStatusPaneLayout ) |
|
900 |
{ |
|
901 |
if ( sp->CurrentLayoutResId() != R_AVKON_STATUS_PANE_LAYOUT_USUAL ) |
|
902 |
{ |
|
903 |
sp->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL ); |
|
904 |
} |
|
905 |
} |
|
906 |
} |
|
907 |
else |
|
908 |
{ |
|
909 |
CAknLocalScreenClearer* clearer = CAknLocalScreenClearer::NewLC( ETrue ); |
|
910 |
sp->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL_FLAT ); |
|
911 |
CleanupStack::PopAndDestroy( clearer ); |
|
912 |
} |
|
913 |
} |
|
914 |
return ret; |
|
915 |
} |
|
916 |
||
917 |
// ------------------------------------------------------------------- |
|
918 |
// void CEqualizerPresetsDialog::SizeChanged() |
|
919 |
// |
|
920 |
// This function is called by the framework whenever there is a change |
|
921 |
// in the size of the control |
|
922 |
// ------------------------------------------------------------------- |
|
923 |
// |
|
924 |
void CEqualizerPresetsDialog::SizeChanged() |
|
925 |
{ |
|
926 |
TRect rect = Rect(); |
|
927 |
//Getting the layout for the list box |
|
928 |
AknLayoutUtils::LayoutControl(iListBox, rect, AknLayout::list_gen_pane(1)); |
|
929 |
CAknDialog::SizeChanged(); |
|
930 |
} |
|
931 |
||
932 |
// ------------------------------------------------------------------- |
|
933 |
// void CEqualizerPresetsDialog::HandleForegroundEventL( TBool aForeground) |
|
934 |
// |
|
935 |
// Handles changes to the application |
|
936 |
// when it switches to or from the foreground. |
|
937 |
// ------------------------------------------------------------------- |
|
938 |
// |
|
939 |
void CEqualizerPresetsDialog::HandleForegroundEventL( TBool aForeground) |
|
940 |
{ |
|
941 |
if (aForeground) |
|
942 |
{ |
|
943 |
CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane(); |
|
944 |
CAknTitlePane* tp=(CAknTitlePane*)sp->ControlL(TUid::Uid( |
|
945 |
EEikStatusPaneUidTitle)); |
|
946 |
tp->SetTextL(*iTitleText); |
|
947 |
} |
|
948 |
} |
|
949 |
||
950 |
// ------------------------------------------------------------------- |
|
951 |
// void CEqualizerPresetsDialog::FocusChanged(TDrawNow aDrawNow) |
|
952 |
// |
|
953 |
// Responds to a change in focus. |
|
954 |
// This is called whenever the control gains or loses focus |
|
955 |
// ------------------------------------------------------------------- |
|
956 |
// |
|
957 |
void CEqualizerPresetsDialog::FocusChanged(TDrawNow /*aDrawNow*/) |
|
958 |
{ |
|
959 |
iItemArray->UpdateSortedArrayL(); |
|
960 |
TPresetName currentPreset = CurrentPreset(); |
|
961 |
iItemArray->SetCurrentActivePreset(currentPreset); |
|
962 |
||
963 |
if(iListBox) |
|
964 |
{ |
|
965 |
iListBox->HandleItemAdditionL(); |
|
966 |
} |
|
967 |
} |
|
968 |
||
969 |
// ------------------------------------------------------------------- |
|
970 |
// void CEqualizerFreqBand::HandleResourceChangeL(TInt aType) |
|
971 |
// |
|
972 |
// This function is called by the framework whenever there is a |
|
973 |
// change in skin or layout |
|
974 |
// ------------------------------------------------------------------- |
|
975 |
// |
|
976 |
void CEqualizerPresetsDialog::HandleResourceChangeL(TInt aType) |
|
977 |
{ |
|
978 |
if (aType == KAknsMessageSkinChange) |
|
979 |
{ |
|
980 |
//Creating the icons for the new Skin |
|
981 |
iListBox->ItemDrawer()->ColumnData()->SetIconArray(GetListBoxIconsL()); |
|
982 |
iListBox->HandleResourceChange(aType); |
|
983 |
} |
|
984 |
||
985 |
else if (aType == KEikDynamicLayoutVariantSwitch) |
|
986 |
{ |
|
987 |
TRect rect; |
|
988 |
AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect); |
|
989 |
SetRect(rect); |
|
990 |
} |
|
991 |
||
992 |
} |
|
993 |
||
994 |
void CEqualizerPresetsDialog::HandleResourceChange(TInt aType) |
|
995 |
{ |
|
996 |
CAknDialog::HandleResourceChange( aType ); |
|
997 |
HandleResourceChangeL(aType); |
|
998 |
} |
|
999 |
||
1000 |
// --------------------------------------------------------- |
|
1001 |
// CEqualizerPresetsDialog::OfferKeyEventL( |
|
1002 |
// const TKeyEvent& aKeyEvent,TEventCode aType) |
|
1003 |
// This function is used to handle key events |
|
1004 |
// --------------------------------------------------------- |
|
1005 |
// |
|
1006 |
TKeyResponse CEqualizerPresetsDialog::OfferKeyEventL( |
|
1007 |
const TKeyEvent& aKeyEvent, |
|
1008 |
TEventCode aType ) |
|
1009 |
{ |
|
1010 |
if (iIgnoreKeyEvents) |
|
1011 |
{ |
|
1012 |
return EKeyWasNotConsumed; |
|
1013 |
} |
|
1014 |
if (aType == EEventKey) |
|
1015 |
{ |
|
1016 |
if (aKeyEvent.iCode == EKeyBackspace) |
|
1017 |
{ |
|
1018 |
// Find the preset highlighted |
|
1019 |
const TInt listBoxIndex = iListBox->CurrentItemIndex(); |
|
1020 |
||
1021 |
// pre-defined presets cannot be deleted. |
|
1022 |
// preset "None" is not stored in engine. |
|
1023 |
if (listBoxIndex > (TInt) |
|
1024 |
(iAudEqUtility->NumberOfPreDefinedPresets())) |
|
1025 |
{ |
|
1026 |
TPresetName preset = GetHighlightedPresetInListBox(); |
|
1027 |
DeleteEqrPresetL(listBoxIndex, preset); |
|
1028 |
} |
|
1029 |
return EKeyWasConsumed; |
|
1030 |
} |
|
54
53984cc2f70a
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
46
diff
changeset
|
1031 |
else if ( aKeyEvent.iCode == EKeyEnter || |
53984cc2f70a
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
46
diff
changeset
|
1032 |
aKeyEvent.iCode == EKeyDevice3 ) //Rocker Key pressed |
46 | 1033 |
{ |
1034 |
const TInt index = iListBox->CurrentItemIndex(); |
|
1035 |
TPresetName preset = GetHighlightedPresetInListBox(); |
|
1036 |
ActivateEqrPresetL(index, preset); |
|
1037 |
return EKeyWasConsumed; |
|
1038 |
} |
|
1039 |
} |
|
1040 |
return CAknDialog::OfferKeyEventL( aKeyEvent, aType ); |
|
1041 |
} |
|
1042 |
||
1043 |
// --------------------------------------------------------------------------- |
|
1044 |
// CEqualizerPresetsDialog::DynInitMenuPaneL( |
|
1045 |
// TInt aResourceId,CEikMenuPane* aMenuPane) |
|
1046 |
// This function is called by the EIKON framework just before it displays |
|
1047 |
// a menu pane. Its default implementation is empty, and by overriding it, |
|
1048 |
// the application can set the state of menu items dynamically according |
|
1049 |
// to the state of application data. |
|
1050 |
// --------------------------------------------------------------------------- |
|
1051 |
// |
|
1052 |
void CEqualizerPresetsDialog::DynInitMenuPaneL( |
|
1053 |
TInt aResourceId, CEikMenuPane* aMenuPane) |
|
1054 |
{ |
|
1055 |
TPresetName selectedItem = GetHighlightedPresetInListBox(); |
|
1056 |
||
1057 |
TInt selectedIndex = iListBox->CurrentItemIndex(); |
|
1058 |
TInt numberOfPreDefinedPresets = |
|
1059 |
iAudEqUtility->NumberOfPreDefinedPresets(); |
|
1060 |
||
1061 |
if ( aResourceId == R_EQUALIZER_CONTAINER_MENU) |
|
1062 |
{ |
|
1063 |
//Is the menubar invoked from Options menu or selection key? |
|
1064 |
if (iContextSensitiveMenu == EFalse) |
|
1065 |
{ |
|
1066 |
// The menubar is invoked from Options menu |
|
1067 |
iMenuBar->SetMenuType(CEikMenuBar::EMenuOptions); |
|
1068 |
// The selected preset is "None" |
|
1069 |
if (selectedItem.Compare(*iPresetNoneText) == 0) |
|
1070 |
{ |
|
1071 |
aMenuPane->SetItemDimmed(EEqualizerCmdRename, ETrue); |
|
1072 |
aMenuPane->SetItemDimmed(EEqualizerCmdDelete, ETrue); |
|
1073 |
aMenuPane->SetItemDimmed(EEqualizerCmdEdit, ETrue); |
|
1074 |
} |
|
1075 |
// The selected preset is a pre defined preset other than "None" |
|
1076 |
if (selectedIndex <= numberOfPreDefinedPresets) |
|
1077 |
{ |
|
1078 |
aMenuPane->SetItemDimmed(EEqualizerCmdRename, ETrue); |
|
1079 |
aMenuPane->SetItemDimmed(EEqualizerCmdDelete, ETrue); |
|
1080 |
} |
|
1081 |
// Help should be displayed only if the feature is supported |
|
1082 |
// according to Feature Manager |
|
1083 |
if (!FeatureManager::FeatureSupported(KFeatureIdHelp)) |
|
1084 |
{ |
|
1085 |
aMenuPane->SetItemDimmed(EEqualizerCmdHelp, ETrue); |
|
1086 |
} |
|
1087 |
} |
|
1088 |
else |
|
1089 |
{ |
|
1090 |
// The menubar is invoked from selection key |
|
1091 |
iMenuBar->SetMenuType(CEikMenuBar::EMenuContext); |
|
1092 |
// These Options are always hidden |
|
1093 |
aMenuPane->SetItemDimmed(EEqualizerCmdDelete, ETrue); |
|
1094 |
aMenuPane->SetItemDimmed(EEqualizerCmdRename, ETrue); |
|
1095 |
aMenuPane->SetItemDimmed(EEqualizerCmdCreateNew, ETrue); |
|
1096 |
aMenuPane->SetItemDimmed(EEqualizerCmdHelp, ETrue); |
|
1097 |
aMenuPane->SetItemDimmed(EAknCmdExit, ETrue); |
|
1098 |
||
1099 |
// The selected preset is "None" |
|
1100 |
if (selectedItem.Compare(*iPresetNoneText) == 0) |
|
1101 |
{ |
|
1102 |
aMenuPane->SetItemDimmed(EEqualizerCmdEdit, ETrue); |
|
1103 |
} |
|
1104 |
iContextSensitiveMenu = EFalse; |
|
1105 |
} |
|
1106 |
aMenuPane->SetItemDimmed(EEqualizerCmdCreateNew, ETrue ); |
|
1107 |
aMenuPane->SetItemDimmed(EEqualizerCmdEdit, ETrue); |
|
1108 |
} |
|
1109 |
} |
|
1110 |
||
1111 |
// ------------------------------------------------------------------- |
|
1112 |
// CEqualizerPresetsDialog::ProcessCommandL(TInt aCommandId ) |
|
1113 |
// |
|
1114 |
// This function is called to process the menubar command in a dialog |
|
1115 |
// -------------------------------------------------------------------- |
|
1116 |
// |
|
1117 |
void CEqualizerPresetsDialog::ProcessCommandL(TInt aCommandId ) |
|
1118 |
{ |
|
1119 |
// Need to do this in all cases or menu does not disappear after |
|
1120 |
// a selection is made |
|
1121 |
CAknDialog::ProcessCommandL(aCommandId); |
|
1122 |
||
1123 |
// Find the preset highlighted |
|
1124 |
const TInt index = iListBox->CurrentItemIndex(); |
|
1125 |
TPresetName preset = GetHighlightedPresetInListBox(); |
|
1126 |
||
1127 |
switch(aCommandId) |
|
1128 |
{ |
|
1129 |
case EAknCmdExit : |
|
1130 |
case EEikCmdExit : |
|
1131 |
{ |
|
1132 |
iAvkonAppUi->HandleCommandL( aCommandId ); |
|
1133 |
break; |
|
1134 |
} |
|
1135 |
case EEqualizerCmdEdit: |
|
1136 |
{ |
|
1137 |
EditEqrPresetL(index, preset); |
|
1138 |
break; |
|
1139 |
} |
|
1140 |
case EEqualizerCmdActivate: |
|
1141 |
{ |
|
1142 |
ActivateEqrPresetL(index, preset); |
|
1143 |
break; |
|
1144 |
} |
|
1145 |
case EEqualizerCmdCreateNew: |
|
1146 |
{ |
|
1147 |
TInt presetIndex = -1; |
|
1148 |
TPresetName presetName; |
|
1149 |
||
1150 |
CreateNewEqrPresetL(presetIndex, presetName); |
|
1151 |
||
1152 |
if (presetIndex != -1) |
|
1153 |
{ |
|
1154 |
// A valid preset name has been entered |
|
1155 |
EditEqrPresetL(presetIndex, presetName); |
|
1156 |
} |
|
1157 |
break; |
|
1158 |
} |
|
1159 |
||
1160 |
case EEqualizerCmdDelete: |
|
1161 |
{ |
|
1162 |
DeleteEqrPresetL(index, preset); |
|
1163 |
break; |
|
1164 |
} |
|
1165 |
||
1166 |
case EEqualizerCmdRename: |
|
1167 |
{ |
|
1168 |
RenameEqrPresetL(index, preset); |
|
1169 |
break; |
|
1170 |
} |
|
1171 |
||
1172 |
case EEqualizerCmdHelp: |
|
1173 |
{ |
|
1174 |
HlpLauncher::LaunchHelpApplicationL |
|
1175 |
( iEikonEnv->WsSession(), |
|
1176 |
CEikonEnv::Static()->AppUi()->AppHelpContextL() ); |
|
1177 |
break; |
|
1178 |
} |
|
1179 |
||
1180 |
default: |
|
1181 |
{ |
|
1182 |
break; |
|
1183 |
} |
|
1184 |
} |
|
1185 |
} |
|
1186 |
||
1187 |
// ------------------------------------------------------------------- |
|
1188 |
// void CEqualizerPresetsDialog::GetHelpContext( |
|
1189 |
// TCoeHelpContext& aContext ) const |
|
1190 |
// Get help context for the control |
|
1191 |
// -------------------------------------------------------------------- |
|
1192 |
// |
|
1193 |
void CEqualizerPresetsDialog::GetHelpContext( |
|
1194 |
TCoeHelpContext& aContext ) const |
|
1195 |
{ |
|
1196 |
aContext.iMajor = KUidEqualizer; |
|
1197 |
aContext.iContext = KEQ_HLP_LIST_VIEW; |
|
1198 |
} |
|
1199 |
||
1200 |
// ------------------------------------------------------------------- |
|
1201 |
// void CEqualizerPresetsDialog::ShowDiskFullNoteL() |
|
1202 |
// This function is used to display a note to the user if |
|
1203 |
// memory is below critical level when creating a new preset. |
|
1204 |
// -------------------------------------------------------------------- |
|
1205 |
// |
|
1206 |
void CEqualizerPresetsDialog::ShowDiskFullNoteL() const |
|
1207 |
{ |
|
1208 |
HBufC* message = NULL; |
|
1209 |
message = StringLoader::LoadLC(R_QTN_MEMLO_NOT_ENOUGH_MEMORY); |
|
1210 |
||
1211 |
CAknGlobalNote* note = CAknGlobalNote::NewLC(); |
|
1212 |
note->SetSoftkeys(R_AVKON_SOFTKEYS_OK_EMPTY); |
|
1213 |
note->ShowNoteL(/*status,*/ EAknGlobalErrorNote, *message); |
|
1214 |
||
1215 |
CleanupStack::PopAndDestroy(note); // note, message |
|
1216 |
CleanupStack::PopAndDestroy(message); // note, message |
|
1217 |
} |
|
1218 |
||
1219 |
#ifdef RD_SCALABLE_UI_V2 |
|
1220 |
// ------------------------------------------------------------------- |
|
1221 |
// void CEqualizerPresetsDialog::HandleListBoxEventL |
|
1222 |
// This function callback from MEikListBoxObserver when a listbox item |
|
1223 |
// is double clicked using a pen input . |
|
1224 |
// -------------------------------------------------------------------- |
|
1225 |
// |
|
1226 |
void CEqualizerPresetsDialog::HandleListBoxEventL( |
|
1227 |
CEikListBox* /*aListBox*/, |
|
1228 |
TListBoxEvent aEventType ) |
|
1229 |
{ |
|
1230 |
switch ( aEventType ) |
|
1231 |
{ |
|
1232 |
#ifdef SINGLE_CLICK_INCLUDED |
|
1233 |
case EEventItemSingleClicked: |
|
1234 |
#endif |
|
1235 |
case EEventItemDoubleClicked: |
|
1236 |
{ |
|
1237 |
const TInt index = iListBox->CurrentItemIndex(); |
|
1238 |
TPresetName preset = GetHighlightedPresetInListBox(); |
|
1239 |
ActivateEqrPresetL(index, preset); |
|
1240 |
break; |
|
1241 |
} |
|
1242 |
default: |
|
1243 |
break; |
|
1244 |
} |
|
1245 |
} |
|
1246 |
#endif //RD_SCALABLE_UI_V2 |
|
1247 |
// End of File |
|
1248 |