author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:34:59 +0300 | |
branch | RCL_3 |
changeset 29 | c9b63fff5abf |
parent 25 | c6bafb5162d8 |
permissions | -rw-r--r-- |
25 | 1 |
/* |
2 |
* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: |
|
15 |
* This class defines a settings dialog for the Voice Recorder application. |
|
16 |
* |
|
17 |
*/ |
|
18 |
||
19 |
#include <bldvariant.hrh> |
|
20 |
||
21 |
#include <aknlists.h> |
|
22 |
#include <featmgr.h> |
|
23 |
#include "CVRSettingsDialogMMCSupported.h" |
|
24 |
#include "voicerecorder.hrh" |
|
25 |
#include <voicerecorder.rsg> |
|
26 |
#include "VRConsts.h" |
|
27 |
#include "VRUtils.h" |
|
28 |
#include <hlplch.h> |
|
29 |
||
30 |
#include <CAknMemorySelectionSettingItem.h> |
|
31 |
#include <aknnotewrappers.h> |
|
32 |
#include <StringLoader.h> |
|
33 |
#include <AknCommonDialogsDynMem.h> |
|
34 |
||
35 |
#ifdef RD_MULTIPLE_DRIVE |
|
36 |
#include <AknCommonDialogsDynMem.h> |
|
37 |
#include <driveinfo.h> |
|
38 |
#include <CAknMemorySelectionDialogMultiDrive.h> |
|
39 |
#endif |
|
40 |
||
41 |
// --------------------------------------------------------------------------- |
|
42 |
// CVRSettingsDialog::~CVRSettingsDialog |
|
43 |
// |
|
44 |
// --------------------------------------------------------------------------- |
|
45 |
// |
|
46 |
CVRSettingsDialog::~CVRSettingsDialog() |
|
47 |
{ |
|
48 |
iSettingItemArray.ResetAndDestroy(); |
|
49 |
} |
|
50 |
||
51 |
// --------------------------------------------------------------------------- |
|
52 |
// CVRSettingsDialog::CVRSettingsDialog |
|
53 |
// |
|
54 |
// --------------------------------------------------------------------------- |
|
55 |
// |
|
56 |
CVRSettingsDialog* CVRSettingsDialog::NewL() |
|
57 |
{ |
|
58 |
CVRSettingsDialog* self = new( ELeave ) CVRSettingsDialog; |
|
59 |
CleanupStack::PushL( self ); |
|
60 |
self->ConstructL( R_VR_SETTINGS_MENUBAR ); |
|
61 |
CleanupStack::Pop(); |
|
62 |
return self; |
|
63 |
} |
|
64 |
||
65 |
// --------------------------------------------------------------------------- |
|
66 |
// CVRSettingsDialog::OkToExitL |
|
67 |
// |
|
68 |
// --------------------------------------------------------------------------- |
|
69 |
// |
|
70 |
TBool CVRSettingsDialog::OkToExitL( TInt aButtonId ) |
|
71 |
{ |
|
72 |
if ( aButtonId == EAknSoftkeyOptions ) |
|
73 |
{ |
|
74 |
DisplayMenuL(); |
|
75 |
return EFalse; |
|
76 |
} |
|
77 |
||
78 |
// If want to exit settings afterwards |
|
79 |
TBool exitAfter( ETrue ); |
|
80 |
||
81 |
// MSK button pressed in settings view |
|
82 |
if ( aButtonId == ECmdMSK ) |
|
83 |
{ |
|
84 |
// A new key event is simulated |
|
85 |
TKeyEvent key; |
|
86 |
key.iRepeats = 0; |
|
87 |
key.iCode = EKeyEnter; |
|
88 |
key.iModifiers = 0; |
|
89 |
CEikonEnv::Static()->SimulateKeyEventL( key, EEventKey ); |
|
90 |
||
91 |
||
92 |
exitAfter = EFalse; // No Exit |
|
93 |
} |
|
94 |
// Do not store settings anymore when exit |
|
95 |
return exitAfter; |
|
96 |
} |
|
97 |
||
98 |
||
99 |
||
100 |
// --------------------------------------------------------------------------- |
|
101 |
// CVRSettingsDialog::PreLayoutDynInitL |
|
102 |
// Intialize layout |
|
103 |
// --------------------------------------------------------------------------- |
|
104 |
// |
|
105 |
void CVRSettingsDialog::PreLayoutDynInitL() |
|
106 |
{ |
|
107 |
if ( VRUtils::FeatureEnabled( EVRFeatureShowQualitySetting ) ) |
|
108 |
{ |
|
109 |
iQuality = VRUtils::QualityL(); |
|
110 |
} |
|
111 |
// Convert the internal memory enumeration to CFD enumeration |
|
112 |
#ifndef RD_MULTIPLE_DRIVE |
|
113 |
if ( VRUtils::MemoStoreL() == EMemoStorePhoneMemory ) |
|
114 |
{ |
|
115 |
iMemoStore = CAknMemorySelectionSettingPage::EPhoneMemory; |
|
116 |
} |
|
117 |
else |
|
118 |
{ |
|
119 |
iMemoStore = CAknMemorySelectionSettingPage::EMemoryCard; |
|
120 |
} |
|
121 |
||
122 |
// for multiple drives |
|
123 |
#else |
|
124 |
iDrive = (TDriveNumber)VRUtils::MemoDriveL(); |
|
125 |
||
126 |
#endif |
|
127 |
||
128 |
CAknSettingStyleListBox* listBox = static_cast< CAknSettingStyleListBox* > |
|
129 |
( Control( EVRSettingsListboxId ) ); |
|
130 |
User::LeaveIfNull( listBox ); |
|
131 |
CAknSettingItem* settingItem; |
|
132 |
||
133 |
HBufC* itemTitle; |
|
29
c9b63fff5abf
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
134 |
TInt id( 0 ); |
25 | 135 |
if ( VRUtils::FeatureEnabled( EVRFeatureShowQualitySetting ) ) |
136 |
{ |
|
137 |
// Add quality setting |
|
138 |
#ifdef __AAC_ENCODER_PLUGIN |
|
139 |
settingItem = new( ELeave ) CAknEnumeratedTextPopupSettingItem ( 0, ( TInt& ) iQuality ); |
|
140 |
||
141 |
#else |
|
142 |
settingItem = new( ELeave ) CAknBinaryPopupSettingItem ( 0, ( TInt& ) iQuality ); |
|
143 |
#endif |
|
144 |
||
145 |
CleanupStack::PushL( settingItem ); |
|
146 |
||
147 |
itemTitle = iCoeEnv->AllocReadResourceLC( R_QTN_VOREC_SET_QUALITY ); |
|
29
c9b63fff5abf
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
148 |
settingItem->ConstructL( EFalse, id, *itemTitle, NULL, |
25 | 149 |
R_VR_SETTINGS_DEFAULT_SPEAKER_PAGE, EAknCtPopupField, NULL, |
150 |
R_VR_SETTINGS_QUALITY_TEXTS ); |
|
151 |
CleanupStack::PopAndDestroy(); // itemTitle |
|
152 |
||
153 |
// Add quality item to the settings array |
|
154 |
iSettingItemArray.AppendL( settingItem ); |
|
155 |
CleanupStack::Pop(); // settingItem |
|
29
c9b63fff5abf
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
156 |
id++; |
25 | 157 |
} |
158 |
||
159 |
if ( VRUtils::MultipleMassStorageAvailable() ) |
|
160 |
{ |
|
161 |
// Create the memo store item |
|
162 |
// Set memo store item's title |
|
163 |
||
164 |
itemTitle = iCoeEnv->AllocReadResourceLC( R_QTN_VOREC_SET_STORE ); |
|
165 |
#ifndef RD_MULTIPLE_DRIVE |
|
166 |
settingItem = new( ELeave ) CAknMemorySelectionSettingItem( 0, iMemoStore ); |
|
167 |
CleanupStack::PushL( settingItem ); |
|
168 |
settingItem->ConstructL( EFalse, id, *itemTitle, NULL, |
|
169 |
R_VOREC_MEMORY_SELECTION_DIALOG, EAknCtPopupSettingList ); |
|
170 |
// Add memo store item to the settings array |
|
171 |
iSettingItemArray.AppendL( settingItem ); |
|
172 |
id++; |
|
173 |
CleanupStack::Pop(); // settingItem |
|
174 |
||
175 |
#else //multiple drives |
|
29
c9b63fff5abf
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
176 |
|
c9b63fff5abf
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
177 |
CAknMemorySelectionDialogMultiDrive* dlg = CAknMemorySelectionDialogMultiDrive::NewL( |
c9b63fff5abf
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
178 |
ECFDDialogTypeNormal, |
c9b63fff5abf
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
179 |
R_VOREC_MEMORY_SELECTION_DIALOG, // Default resource Id |
c9b63fff5abf
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
180 |
EFalse, |
c9b63fff5abf
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
181 |
AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage | |
c9b63fff5abf
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
182 |
AknCommonDialogsDynMem::EMemoryTypeMMCExternal); |
c9b63fff5abf
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
183 |
|
c9b63fff5abf
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
184 |
CleanupStack::PushL( dlg ); |
c9b63fff5abf
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
185 |
TBool value = dlg->ExecuteL( iDrive ); |
c9b63fff5abf
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
186 |
CleanupStack::PopAndDestroy( dlg ); |
c9b63fff5abf
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
187 |
if (value) |
c9b63fff5abf
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
188 |
{ |
c9b63fff5abf
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
189 |
VRUtils::SetMemoDriveL( iDrive ); |
c9b63fff5abf
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
190 |
} |
25 | 191 |
|
192 |
#endif |
|
193 |
||
194 |
CleanupStack::PopAndDestroy(); // itemTitle |
|
195 |
} |
|
196 |
CTextListBoxModel* model = listBox->Model(); |
|
197 |
model->SetItemTextArray( &iSettingItemArray ); |
|
198 |
// Ownership retained by us |
|
199 |
model->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
200 |
||
201 |
iSettingItemArray.RecalculateVisibleIndicesL(); |
|
202 |
listBox->CreateScrollBarFrameL( ETrue ); |
|
203 |
listBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
204 |
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); |
|
205 |
listBox->HandleItemAdditionL(); |
|
206 |
listBox->SetListBoxObserver( this ); |
|
207 |
listBox->UpdateScrollBarsL(); |
|
208 |
||
209 |
} |
|
210 |
||
211 |
// --------------------------------------------------------------------------- |
|
212 |
// CVRSettingsDialog::HandleListBoxEventL |
|
213 |
// |
|
214 |
// --------------------------------------------------------------------------- |
|
215 |
// |
|
216 |
void CVRSettingsDialog::HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType) |
|
217 |
{ |
|
218 |
||
219 |
switch ( aEventType ) |
|
220 |
{ |
|
221 |
#ifdef SINGLE_CLICK_INCLUDED |
|
222 |
case EEventItemSingleClicked: |
|
223 |
#endif |
|
224 |
case EEventItemDoubleClicked: // Pointer events (highlighted item before pressing) |
|
225 |
case EEventEnterKeyPressed: // Normal button presses |
|
226 |
case EEventEditingStarted: // From ProcessCommand->ECmdChange |
|
227 |
{ |
|
228 |
TInt index( aListBox->CurrentItemIndex() ); |
|
229 |
if ( index >=0 ) // index is -1 if there are no items in the list |
|
230 |
{ |
|
231 |
iSettingItemArray.At( index )->EditItemL( |
|
232 |
aEventType == EEventEditingStarted ); |
|
233 |
aListBox->DrawItem( index ); |
|
234 |
} |
|
235 |
StoreAllSettingsL(); |
|
236 |
break; |
|
237 |
} |
|
238 |
default: |
|
239 |
{ |
|
240 |
break; |
|
241 |
} |
|
242 |
} |
|
243 |
||
244 |
} |
|
245 |
||
246 |
// --------------------------------------------------------------------------- |
|
247 |
// CVRSettingsDialog::ProcessCommandL |
|
248 |
// |
|
249 |
// --------------------------------------------------------------------------- |
|
250 |
// |
|
251 |
void CVRSettingsDialog::ProcessCommandL( TInt aCommandId ) |
|
252 |
{ |
|
253 |
HideMenu(); |
|
254 |
switch ( aCommandId ) |
|
255 |
{ |
|
256 |
case ECmdChange: |
|
257 |
{ |
|
258 |
CEikListBox* listBox = static_cast< CEikListBox* >( Control( EVRSettingsListboxId ) ); |
|
259 |
HandleListBoxEventL( listBox, EEventEditingStarted ); |
|
260 |
StoreAllSettingsL(); |
|
261 |
break; |
|
262 |
} |
|
263 |
case EEikCmdExit: |
|
264 |
{ |
|
265 |
TryExitL( EEikCmdExit ); |
|
266 |
CEikonEnv::Static()->EikAppUi()->HandleCommandL( aCommandId ); |
|
267 |
break; |
|
268 |
} |
|
269 |
default: |
|
270 |
{ |
|
271 |
CEikonEnv::Static()->EikAppUi()->HandleCommandL( aCommandId ); |
|
272 |
break; |
|
273 |
} |
|
274 |
} |
|
275 |
} |
|
276 |
||
277 |
// --------------------------------------------------------------------------- |
|
278 |
// CVRSettingsDialog::StoreAllSettingsL |
|
279 |
// Stores values in settings list to permanent storage |
|
280 |
// --------------------------------------------------------------------------- |
|
281 |
// |
|
282 |
void CVRSettingsDialog::StoreAllSettingsL() |
|
283 |
{ |
|
284 |
||
285 |
TInt settingItemCount( iSettingItemArray.Count() ); |
|
286 |
||
287 |
for ( TInt i( 0 ); i < settingItemCount; i++ ) |
|
288 |
{ |
|
289 |
iSettingItemArray.At( i )->StoreL(); |
|
290 |
} |
|
291 |
||
292 |
#ifndef RD_MULTIPLE_DRIVE |
|
293 |
if ( iMemoStore == CAknMemorySelectionSettingPage::EPhoneMemory ) |
|
294 |
{ |
|
295 |
VRUtils::SetMemoStoreL( EMemoStorePhoneMemory ); |
|
296 |
} |
|
297 |
else |
|
298 |
{ |
|
299 |
// check if MMC is read-only |
|
300 |
TVRDriveInfo mmcInfo; |
|
301 |
VRUtils::GetMMCInfo( mmcInfo ); |
|
302 |
||
303 |
if ( mmcInfo.iDriveReadOnly ) |
|
304 |
{ |
|
305 |
HBufC* noteText = iCoeEnv->AllocReadResourceLC( |
|
306 |
R_QTN_MEMC_READONLY ); |
|
307 |
CAknInformationNote* infoNote = |
|
308 |
new( ELeave ) CAknInformationNote( ETrue ); |
|
309 |
infoNote->ExecuteLD( *noteText ); |
|
310 |
CleanupStack::PopAndDestroy(); // noteText |
|
311 |
VRUtils::SetMemoStoreL( EMemoStorePhoneMemory ); |
|
312 |
} |
|
313 |
else |
|
314 |
{ |
|
315 |
VRUtils::SetMemoStoreL( EMemoStoreMMC ); |
|
316 |
} |
|
317 |
} |
|
318 |
||
319 |
// for multiple drives |
|
320 |
#else |
|
321 |
TUint status( 0 ); |
|
322 |
TInt defaultDrive = VRUtils::DefaultMemoDriveL(); |
|
323 |
if (VRUtils::MemoDriveL() != defaultDrive) |
|
324 |
{ |
|
325 |
VRUtils::GetDriveInfo(iDrive, status); |
|
326 |
// check if drive status is ok |
|
327 |
if ( status & DriveInfo::EDriveReadOnly ) |
|
328 |
{ |
|
329 |
HBufC* noteText = iCoeEnv->AllocReadResourceLC(R_QTN_MEMC_READONLY ); |
|
330 |
CAknInformationNote* infoNote = new( ELeave ) CAknInformationNote( ETrue ); |
|
331 |
infoNote->ExecuteLD( *noteText ); |
|
332 |
CleanupStack::PopAndDestroy(); // noteText |
|
333 |
||
334 |
// use default device drive to save files |
|
335 |
iDrive = (TDriveNumber)defaultDrive; |
|
336 |
} |
|
337 |
} |
|
338 |
VRUtils::SetMemoDriveL( iDrive ); |
|
339 |
#endif |
|
340 |
||
341 |
if ( VRUtils::FeatureEnabled( EVRFeatureShowQualitySetting ) ) |
|
342 |
{ |
|
343 |
// Save the quality setting |
|
344 |
VRUtils::SetQualityL( iQuality ); |
|
345 |
} |
|
346 |
} |
|
347 |
||
348 |
// --------------------------------------------------------------------------- |
|
349 |
// CVRSettingsDialog::DynInitMenuPaneL |
|
350 |
// |
|
351 |
// --------------------------------------------------------------------------- |
|
352 |
// |
|
353 |
void CVRSettingsDialog::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane ) |
|
354 |
{ |
|
355 |
||
356 |
switch ( aResourceId ) |
|
357 |
{ |
|
358 |
case R_VR_SETTINGS_MENUPANE: |
|
359 |
{ |
|
360 |
// Check if HELP is enabled in FeatureManager, if not, disable the Help menu item |
|
361 |
if (!FeatureManager::FeatureSupported(KFeatureIdHelp)) |
|
362 |
{ |
|
363 |
aMenuPane->SetItemDimmed(ECmdHelp, ETrue); |
|
364 |
} |
|
365 |
break; |
|
366 |
} |
|
367 |
default: |
|
368 |
{ |
|
369 |
break; |
|
370 |
} |
|
371 |
} |
|
372 |
} |
|
373 |
||
374 |
||
375 |
// End of file |