|
1 /* |
|
2 * Copyright (c) 2009 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 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "FBSettingViewDlg.h" |
|
21 #include "FBModel.h" |
|
22 #include "FB.hrh" |
|
23 #include "FBStd.h" |
|
24 #include <filebrowser.rsg> |
|
25 |
|
26 #include <aknsettingitemlist.h> |
|
27 #include <CAknMemorySelectionSettingItem.h> |
|
28 #include <aknlists.h> |
|
29 #include <akntitle.h> |
|
30 #include <aknnavi.h> |
|
31 #include <aknnavide.h> |
|
32 #include <StringLoader.h> |
|
33 #include <aknnotewrappers.h> |
|
34 |
|
35 // ===================================== MEMBER FUNCTIONS ===================================== |
|
36 |
|
37 CFileBrowserSettingViewDlg* CFileBrowserSettingViewDlg::NewL(TFileBrowserSettings& aSettings) |
|
38 { |
|
39 CFileBrowserSettingViewDlg* self = new(ELeave) CFileBrowserSettingViewDlg(aSettings); |
|
40 CleanupStack::PushL(self); |
|
41 self->ConstructL(); |
|
42 CleanupStack::Pop(self); |
|
43 return self; |
|
44 } |
|
45 |
|
46 // -------------------------------------------------------------------------------------------- |
|
47 |
|
48 CFileBrowserSettingViewDlg::~CFileBrowserSettingViewDlg() |
|
49 { |
|
50 // restore default navi pane |
|
51 if (iNaviContainer) |
|
52 iNaviContainer->Pop(); |
|
53 |
|
54 if (iSettingItemArray) |
|
55 { |
|
56 iSettingItemArray->ResetAndDestroy(); |
|
57 delete iSettingItemArray; |
|
58 } |
|
59 |
|
60 if (iDecoratedTabGroup) |
|
61 delete iDecoratedTabGroup; |
|
62 } |
|
63 |
|
64 // -------------------------------------------------------------------------------------------- |
|
65 |
|
66 CFileBrowserSettingViewDlg::CFileBrowserSettingViewDlg(TFileBrowserSettings& aSettings) : iSettings(aSettings) |
|
67 { |
|
68 } |
|
69 |
|
70 // -------------------------------------------------------------------------------------------- |
|
71 |
|
72 void CFileBrowserSettingViewDlg::ConstructL() |
|
73 { |
|
74 // construct a menu bar |
|
75 CAknDialog::ConstructL(R_FILEBROWSER_SETTINGS_MENUBAR); |
|
76 |
|
77 CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane(); |
|
78 |
|
79 // set empty navi pane label |
|
80 iNaviContainer = static_cast<CAknNavigationControlContainer*>(sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi))); |
|
81 iNaviContainer->PushDefaultL(); |
|
82 |
|
83 // set title text |
|
84 CAknTitlePane* tp = static_cast<CAknTitlePane*>( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
85 tp->SetTextL( _L("Settings") ); |
|
86 |
|
87 // create a tab group |
|
88 iDecoratedTabGroup = iNaviContainer->CreateTabGroupL(this); |
|
89 iTabGroup = static_cast<CAknTabGroup*>(iDecoratedTabGroup->DecoratedControl()); |
|
90 iTabGroup->SetTabFixedWidthL(KTabWidthWithTwoLongTabs); |
|
91 |
|
92 // add tabs |
|
93 iTabGroup->AddTabL(ETabGeneral, _L("General")); |
|
94 iTabGroup->AddTabL(ETabFileOps, _L("Operations")); |
|
95 iTabGroup->SetActiveTabByIndex(ETabGeneral); |
|
96 |
|
97 iNaviContainer->PushL( *iDecoratedTabGroup ); |
|
98 } |
|
99 |
|
100 // -------------------------------------------------------------------------------------------- |
|
101 |
|
102 void CFileBrowserSettingViewDlg::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType) |
|
103 { |
|
104 switch (aEventType) |
|
105 { |
|
106 case EEventEnterKeyPressed: |
|
107 case EEventItemDoubleClicked: |
|
108 ShowSettingPageL(EFalse); |
|
109 break; |
|
110 default: |
|
111 break; |
|
112 } |
|
113 } |
|
114 |
|
115 // -------------------------------------------------------------------------------------------- |
|
116 |
|
117 void CFileBrowserSettingViewDlg::TabChangedL(TInt /*aIndex*/) |
|
118 { |
|
119 iListBox->SetCurrentItemIndex(0); |
|
120 |
|
121 SetVisibilitiesOfSettingItemsL(); |
|
122 } |
|
123 |
|
124 // -------------------------------------------------------------------------------------------- |
|
125 |
|
126 void CFileBrowserSettingViewDlg::ProcessCommandL(TInt aCommandId) |
|
127 { |
|
128 CAknDialog::ProcessCommandL(aCommandId); |
|
129 |
|
130 switch (aCommandId) |
|
131 { |
|
132 case EFileBrowserCmdSettingsChange: |
|
133 ShowSettingPageL(ETrue); |
|
134 break; |
|
135 case EFileBrowserCmdSettingsExit: |
|
136 TryExitL(EAknCmdExit); |
|
137 break; |
|
138 default: |
|
139 break; |
|
140 } |
|
141 } |
|
142 |
|
143 // -------------------------------------------------------------------------------------------- |
|
144 |
|
145 TKeyResponse CFileBrowserSettingViewDlg::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) |
|
146 { |
|
147 if (iTabGroup == NULL) |
|
148 { |
|
149 return EKeyWasNotConsumed; |
|
150 } |
|
151 |
|
152 TInt active = iTabGroup->ActiveTabIndex(); |
|
153 TInt count = iTabGroup->TabCount(); |
|
154 |
|
155 switch ( aKeyEvent.iCode ) |
|
156 { |
|
157 case EKeyLeftArrow: |
|
158 if (active > 0) |
|
159 { |
|
160 active--; |
|
161 iTabGroup->SetActiveTabByIndex(active); |
|
162 TabChangedL(active); |
|
163 } |
|
164 break; |
|
165 |
|
166 case EKeyRightArrow: |
|
167 if((active + 1) < count) |
|
168 { |
|
169 active++; |
|
170 iTabGroup->SetActiveTabByIndex(active); |
|
171 TabChangedL(active); |
|
172 } |
|
173 break; |
|
174 } |
|
175 |
|
176 return CAknDialog::OfferKeyEventL(aKeyEvent, aType); |
|
177 } |
|
178 |
|
179 // -------------------------------------------------------------------------------------------- |
|
180 |
|
181 void CFileBrowserSettingViewDlg::PreLayoutDynInitL() |
|
182 { |
|
183 iListBox = static_cast<CAknSettingStyleListBox*>( Control(EFileBrowserSettingItemList) ); |
|
184 iListBox->SetMopParent(this); |
|
185 iListBox->CreateScrollBarFrameL(ETrue); |
|
186 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); |
|
187 iListBox->SetListBoxObserver(this); |
|
188 |
|
189 iSettingItemArray = new(ELeave) CAknSettingItemArray(16, EFalse, 0); |
|
190 |
|
191 CTextListBoxModel* model = iListBox->Model(); |
|
192 model->SetItemTextArray(iSettingItemArray); |
|
193 model->SetOwnershipType(ELbmDoesNotOwnItemArray); |
|
194 |
|
195 UpdateListBoxL(); |
|
196 } |
|
197 |
|
198 // -------------------------------------------------------------------------------------------- |
|
199 |
|
200 TBool CFileBrowserSettingViewDlg::OkToExitL(TInt aButtonId) |
|
201 { |
|
202 return CAknDialog::OkToExitL(aButtonId); |
|
203 } |
|
204 |
|
205 // -------------------------------------------------------------------------------------------- |
|
206 |
|
207 void CFileBrowserSettingViewDlg::ShowSettingPageL(TInt aCalledFromMenu) |
|
208 { |
|
209 TInt listIndex = iListBox->CurrentItemIndex(); |
|
210 TInt realIndex = iSettingItemArray->ItemIndexFromVisibleIndex(listIndex); |
|
211 CAknSettingItem* item = iSettingItemArray->At(realIndex); |
|
212 item->EditItemL(aCalledFromMenu); |
|
213 item->StoreL(); |
|
214 SetVisibilitiesOfSettingItemsL(); |
|
215 DrawNow(); |
|
216 |
|
217 if (realIndex == ESettingListBypassPlatformSecuritySelection && iSettings.iBypassPlatformSecurity) |
|
218 { |
|
219 _LIT(KMessage, "Gives TCB rights to file operations, use at your own risk"); |
|
220 CAknInformationNote* note = new(ELeave) CAknInformationNote; |
|
221 note->ExecuteLD(KMessage); |
|
222 } |
|
223 } |
|
224 |
|
225 // -------------------------------------------------------------------------------------------- |
|
226 |
|
227 void CFileBrowserSettingViewDlg::SetVisibilitiesOfSettingItemsL() |
|
228 { |
|
229 if (iSettingItemArray->Count() > 0) |
|
230 { |
|
231 switch (iTabGroup->ActiveTabIndex()) |
|
232 { |
|
233 case ETabGeneral: |
|
234 { |
|
235 ((*iSettingItemArray)[ESettingListDisplayModeSelection])->SetHidden(EFalse); |
|
236 ((*iSettingItemArray)[ESettingListFileViewModeSelection])->SetHidden(EFalse); |
|
237 ((*iSettingItemArray)[ESettingListShowSubdirectoryInfoSelection])->SetHidden(EFalse); |
|
238 ((*iSettingItemArray)[ESettingListShowAssociatedIconsSelection])->SetHidden(EFalse); |
|
239 ((*iSettingItemArray)[ESettingListRememberLastPathSelection])->SetHidden(EFalse); |
|
240 ((*iSettingItemArray)[ESettingListRememberFolderSelection])->SetHidden(EFalse); |
|
241 ((*iSettingItemArray)[ESettingListEnableToolbar])->SetHidden(EFalse); |
|
242 |
|
243 ((*iSettingItemArray)[ESettingListSupportNetworkDrivesSelection])->SetHidden(ETrue); |
|
244 ((*iSettingItemArray)[ESettingListBypassPlatformSecuritySelection])->SetHidden(ETrue); |
|
245 ((*iSettingItemArray)[ESettingListRemoveFileLocksSelection])->SetHidden(ETrue); |
|
246 ((*iSettingItemArray)[ESettingListIgnoreProtectionsAttsSelection])->SetHidden(ETrue); |
|
247 ((*iSettingItemArray)[ESettingListRemoveROMWriteProtectionSelection])->SetHidden(ETrue); |
|
248 } |
|
249 break; |
|
250 |
|
251 case ETabFileOps: |
|
252 { |
|
253 ((*iSettingItemArray)[ESettingListDisplayModeSelection])->SetHidden(ETrue); |
|
254 ((*iSettingItemArray)[ESettingListFileViewModeSelection])->SetHidden(ETrue); |
|
255 ((*iSettingItemArray)[ESettingListShowSubdirectoryInfoSelection])->SetHidden(ETrue); |
|
256 ((*iSettingItemArray)[ESettingListShowAssociatedIconsSelection])->SetHidden(ETrue); |
|
257 ((*iSettingItemArray)[ESettingListRememberLastPathSelection])->SetHidden(ETrue); |
|
258 ((*iSettingItemArray)[ESettingListRememberFolderSelection])->SetHidden(ETrue); |
|
259 ((*iSettingItemArray)[ESettingListEnableToolbar])->SetHidden(ETrue); |
|
260 |
|
261 ((*iSettingItemArray)[ESettingListSupportNetworkDrivesSelection])->SetHidden(EFalse); |
|
262 ((*iSettingItemArray)[ESettingListBypassPlatformSecuritySelection])->SetHidden(EFalse); |
|
263 ((*iSettingItemArray)[ESettingListRemoveFileLocksSelection])->SetHidden(EFalse); |
|
264 ((*iSettingItemArray)[ESettingListIgnoreProtectionsAttsSelection])->SetHidden(EFalse); |
|
265 ((*iSettingItemArray)[ESettingListRemoveROMWriteProtectionSelection])->SetHidden(EFalse); |
|
266 } |
|
267 break; |
|
268 |
|
269 default: |
|
270 User::Panic(_L("TabIOOB"), 50); |
|
271 break; |
|
272 } |
|
273 |
|
274 #ifdef FILEBROWSER_LITE |
|
275 ((*iSettingItemArray)[ESettingListBypassPlatformSecuritySelection])->SetHidden(ETrue); |
|
276 #endif |
|
277 |
|
278 #if(defined __SERIES60_30__ || defined __SERIES60_31__ || defined __S60_32__) |
|
279 ((*iSettingItemArray)[ESettingListEnableToolbar])->SetHidden(ETrue); |
|
280 #else |
|
281 if ( !AknLayoutUtils::PenEnabled() ) |
|
282 { |
|
283 ((*iSettingItemArray)[ESettingListEnableToolbar])->SetHidden(ETrue); |
|
284 } |
|
285 #endif |
|
286 |
|
287 iSettingItemArray->RecalculateVisibleIndicesL(); |
|
288 iListBox->HandleItemAdditionL(); |
|
289 iListBox->UpdateScrollBarsL(); |
|
290 } |
|
291 } |
|
292 |
|
293 // -------------------------------------------------------------------------------------------- |
|
294 |
|
295 void CFileBrowserSettingViewDlg::UpdateListBoxL() |
|
296 { |
|
297 iSettingItemArray->ResetAndDestroy(); |
|
298 |
|
299 // create items |
|
300 TInt ordinal(0); |
|
301 |
|
302 AddSettingItemL(ESettingListDisplayModeSelection, |
|
303 R_DISPLAYMODESELECTION_SETTING_TITLE, |
|
304 R_DISPLAYMODESELECTION_SETTING_PAGE, |
|
305 R_DISPLAYMODESELECTION_SETTING_TEXTS, |
|
306 ordinal++); |
|
307 |
|
308 AddSettingItemL(ESettingListFileViewModeSelection, |
|
309 R_FILEVIEWMODESELECTION_SETTING_TITLE, |
|
310 R_FILEVIEWMODESELECTION_SETTING_PAGE, |
|
311 R_FILEVIEWMODESELECTION_SETTING_TEXTS, |
|
312 ordinal++); |
|
313 |
|
314 AddSettingItemL(ESettingListShowSubdirectoryInfoSelection, |
|
315 R_SHOWSUBDIRECTORYINFOSELECTION_SETTING_TITLE, |
|
316 R_BINARY_SETTING_PAGE, |
|
317 R_YESNO_BINARYSELECTION_TEXTS, |
|
318 ordinal++); |
|
319 |
|
320 AddSettingItemL(ESettingListShowAssociatedIconsSelection, |
|
321 R_SHOWASSOCIATEDICONSSELECTION_SETTING_TITLE, |
|
322 R_BINARY_SETTING_PAGE, |
|
323 R_YESNO_BINARYSELECTION_TEXTS, |
|
324 ordinal++); |
|
325 |
|
326 AddSettingItemL(ESettingListRememberLastPathSelection, |
|
327 R_REMEMBERLASTPATHSELECTION_SETTING_TITLE, |
|
328 R_BINARY_SETTING_PAGE, |
|
329 R_YESNO_BINARYSELECTION_TEXTS, |
|
330 ordinal++); |
|
331 |
|
332 AddSettingItemL(ESettingListRememberFolderSelection, |
|
333 R_REMEMBERFOLDERSELECTION_SETTING_TITLE, |
|
334 R_BINARY_SETTING_PAGE, |
|
335 R_YESNO_BINARYSELECTION_TEXTS, |
|
336 ordinal++); |
|
337 |
|
338 AddSettingItemL(ESettingListEnableToolbar, |
|
339 R_ENABLETOOLBAR_SETTING_TITLE, |
|
340 R_BINARY_SETTING_PAGE, |
|
341 R_YESNO_BINARYSELECTION_TEXTS, |
|
342 ordinal++); |
|
343 |
|
344 AddSettingItemL(ESettingListSupportNetworkDrivesSelection, |
|
345 R_SUPPORTNETWORKDRIVESSELECTION_SETTING_TITLE, |
|
346 R_BINARY_SETTING_PAGE, |
|
347 R_YESNO_BINARYSELECTION_TEXTS, |
|
348 ordinal++); |
|
349 |
|
350 AddSettingItemL(ESettingListBypassPlatformSecuritySelection, |
|
351 R_BYPASSPLATFORMSECURITYSELECTION_SETTING_TITLE, |
|
352 R_BINARY_SETTING_PAGE, |
|
353 R_YESNO_BINARYSELECTION_TEXTS, |
|
354 ordinal++); |
|
355 |
|
356 AddSettingItemL(ESettingListRemoveFileLocksSelection, |
|
357 R_REMOVEFILELOCKSSELECTION_SETTING_TITLE, |
|
358 R_BINARY_SETTING_PAGE, |
|
359 R_YESNO_BINARYSELECTION_TEXTS, |
|
360 ordinal++); |
|
361 |
|
362 AddSettingItemL(ESettingListIgnoreProtectionsAttsSelection, |
|
363 R_IGNOREPROTECTIONATTSSELECTION_SETTING_TITLE, |
|
364 R_BINARY_SETTING_PAGE, |
|
365 R_YESNO_BINARYSELECTION_TEXTS, |
|
366 ordinal++); |
|
367 |
|
368 AddSettingItemL(ESettingListRemoveROMWriteProtectionSelection, |
|
369 R_REMOVEROMWRITEPROTECTIONSELECTION_SETTING_TITLE, |
|
370 R_BINARY_SETTING_PAGE, |
|
371 R_YESNO_BINARYSELECTION_TEXTS, |
|
372 ordinal++); |
|
373 |
|
374 SetVisibilitiesOfSettingItemsL(); |
|
375 } |
|
376 |
|
377 // -------------------------------------------------------------------------------------------- |
|
378 |
|
379 void CFileBrowserSettingViewDlg::AddSettingItemL(TInt aId, |
|
380 TInt aTitleResource, |
|
381 TInt aSettingPageResource, |
|
382 TInt aAssociatedResource, |
|
383 TInt aOrdinal) |
|
384 { |
|
385 // create a setting item |
|
386 CAknSettingItem* settingItem = NULL; |
|
387 |
|
388 switch (aId) |
|
389 { |
|
390 case ESettingListDisplayModeSelection: |
|
391 settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iDisplayMode); |
|
392 break; |
|
393 |
|
394 case ESettingListFileViewModeSelection: |
|
395 settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iSettings.iFileViewMode); |
|
396 break; |
|
397 |
|
398 case ESettingListShowSubdirectoryInfoSelection: |
|
399 settingItem = new(ELeave) CAknBinaryPopupSettingItem(aId, iSettings.iShowSubDirectoryInfo); |
|
400 break; |
|
401 |
|
402 case ESettingListShowAssociatedIconsSelection: |
|
403 settingItem = new(ELeave) CAknBinaryPopupSettingItem(aId, iSettings.iShowAssociatedIcons); |
|
404 break; |
|
405 |
|
406 case ESettingListRememberLastPathSelection: |
|
407 settingItem = new(ELeave) CAknBinaryPopupSettingItem(aId, iSettings.iRememberLastPath); |
|
408 break; |
|
409 |
|
410 case ESettingListRememberFolderSelection: |
|
411 settingItem = new(ELeave) CAknBinaryPopupSettingItem(aId, iSettings.iRememberFolderSelection); |
|
412 break; |
|
413 |
|
414 case ESettingListEnableToolbar: |
|
415 settingItem = new(ELeave) CAknBinaryPopupSettingItem(aId, iSettings.iEnableToolbar); |
|
416 break; |
|
417 |
|
418 case ESettingListSupportNetworkDrivesSelection: |
|
419 settingItem = new(ELeave) CAknBinaryPopupSettingItem(aId, iSettings.iSupportNetworkDrives); |
|
420 break; |
|
421 |
|
422 case ESettingListBypassPlatformSecuritySelection: |
|
423 settingItem = new(ELeave) CAknBinaryPopupSettingItem(aId, iSettings.iBypassPlatformSecurity); |
|
424 break; |
|
425 |
|
426 case ESettingListRemoveFileLocksSelection: |
|
427 settingItem = new(ELeave) CAknBinaryPopupSettingItem(aId, iSettings.iRemoveFileLocks); |
|
428 break; |
|
429 |
|
430 case ESettingListIgnoreProtectionsAttsSelection: |
|
431 settingItem = new(ELeave) CAknBinaryPopupSettingItem(aId, iSettings.iIgnoreProtectionsAtts); |
|
432 break; |
|
433 |
|
434 case ESettingListRemoveROMWriteProtectionSelection: |
|
435 settingItem = new(ELeave) CAknBinaryPopupSettingItem(aId, iSettings.iRemoveROMWriteProrection); |
|
436 break; |
|
437 |
|
438 |
|
439 default: |
|
440 User::Panic(_L("NotSetItem"), 50); |
|
441 break; |
|
442 } |
|
443 |
|
444 CleanupStack::PushL(settingItem); |
|
445 |
|
446 // get title text |
|
447 HBufC* itemTitle = StringLoader::LoadLC(aTitleResource); |
|
448 |
|
449 // construct the setting item |
|
450 settingItem->ConstructL(EFalse, aOrdinal, *itemTitle, NULL, aSettingPageResource, |
|
451 EAknCtPopupSettingList, NULL, aAssociatedResource); |
|
452 |
|
453 // append the setting item to settingitem array |
|
454 iSettingItemArray->InsertL(aOrdinal, settingItem); |
|
455 |
|
456 CleanupStack::PopAndDestroy(); //itemTitle |
|
457 CleanupStack::Pop(); //settingItem |
|
458 } |
|
459 |
|
460 // -------------------------------------------------------------------------------------------- |
|
461 |
|
462 // End of File |
|
463 |