1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Setting page for CAknEnumeratedItems.* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <AknSettingItemList.h> |
|
21 #include "CamContextAwareSettingPage.h" |
|
22 #include "CamAppController.h" |
|
23 #include "CamAppUiBase.h" |
|
24 #include "camlogging.h" |
|
25 |
|
26 // CONSTANTS |
|
27 |
|
28 |
|
29 // ============================ MEMBER FUNCTIONS =============================== |
|
30 // --------------------------------------------------------------------------- |
|
31 // CCamContextAwareSettingPage::CCamContextAwareSettingPage |
|
32 // C++ constructor |
|
33 // --------------------------------------------------------------------------- |
|
34 // |
|
35 CCamContextAwareSettingPage::CCamContextAwareSettingPage( |
|
36 const TDesC* aSettingText, |
|
37 TInt aSettingNumber, |
|
38 TInt aControlType, |
|
39 TInt aEditorResourceId, |
|
40 TInt aSettingPageResourceId, |
|
41 MAknQueryValue& aQueryValue, |
|
42 CAknEnumeratedTextPopupSettingItem& aParent, |
|
43 CCamAppController& aController ) |
|
44 : CAknPopupSettingPage( aSettingText, aSettingNumber, aControlType, |
|
45 aEditorResourceId, aSettingPageResourceId, aQueryValue ), |
|
46 iParent( aParent ), iController( aController ) |
|
47 { |
|
48 } |
|
49 |
|
50 /** |
|
51 * Destructor |
|
52 */ |
|
53 CCamContextAwareSettingPage::~CCamContextAwareSettingPage() |
|
54 { |
|
55 PRINT( _L("Camera => ~CCamContextAwareSettingPage") ); |
|
56 if ( iTimer ) |
|
57 { |
|
58 iTimer->Cancel(); |
|
59 delete iTimer; |
|
60 } |
|
61 |
|
62 TRAP_IGNORE( iController.CancelPreviewChangesL() ); |
|
63 PRINT( _L("Camera <= ~CCamContextAwareSettingPage") ); |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // CCamContextAwareSettingPage::ConstructL |
|
68 // Construct the setting page |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 void CCamContextAwareSettingPage::ConstructL() |
|
72 { |
|
73 CAknPopupSettingPage::ConstructL(); |
|
74 // create the timer used for callbacks |
|
75 iTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CCamContextAwareSettingPage::PostDisplayCheckL |
|
80 // Pushes the navicounter onto the navipane, and then calls the base class |
|
81 // PostDisplayCheckL() |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 TBool CCamContextAwareSettingPage::PostDisplayCheckL() |
|
85 { |
|
86 // This appears to be the best place to push the navicounter, |
|
87 // so that it overwrites the navipane created by the |
|
88 // CAknSettinPage::ExecuteLD() |
|
89 CCamAppUiBase* appUi = (CCamAppUiBase*)iEikonEnv->EikAppUi(); |
|
90 appUi->PushNaviPaneCounterL(); |
|
91 |
|
92 return CAknPopupSettingPage::PostDisplayCheckL(); |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // CCamContextAwareSettingPage::UpdateSettingL |
|
97 // Called when the state of the list box changes. |
|
98 // --------------------------------------------------------------------------- |
|
99 // |
|
100 void CCamContextAwareSettingPage::UpdateSettingL() |
|
101 { |
|
102 // Determine whether the currently highlighted list item |
|
103 // is enabled or not, and update the cba. |
|
104 // ...Get the current list item index. |
|
105 TInt currentIndex = ListBoxControl()->View()->CurrentItemIndex(); |
|
106 // ...Dertemine the settings model id associated with the current |
|
107 // ...list item. |
|
108 iCurrentVal = iParent.EnumeratedTextArray()-> |
|
109 At( currentIndex )->EnumerationValue(); |
|
110 // ...Determine whether the settings model value is enabled or disabled. |
|
111 TBool settingValueEnabled = |
|
112 iController.SettingValueEnabled( iParent.Identifier(), iCurrentVal ); |
|
113 // ...Inform the base setting page class, and update the cba |
|
114 SetDataValidity( settingValueEnabled ); |
|
115 UpdateCbaL(); |
|
116 |
|
117 // If the list item is enabled update the navi-pane to |
|
118 // let the user know how this item would affect the available photo |
|
119 // counter. |
|
120 if ( settingValueEnabled ) |
|
121 { |
|
122 if ( iTimer->IsActive() ) |
|
123 { |
|
124 iTimer->Cancel(); |
|
125 } |
|
126 iTimer->Start( 0, 0, TCallBack( PreviewSettingChange, this ) ); |
|
127 } |
|
128 } |
|
129 |
|
130 // --------------------------------------------------------------------------- |
|
131 // CCamContextAwareSettingPage::ProcessCommandL |
|
132 // Processes events from the softkeys. |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 void CCamContextAwareSettingPage::ProcessCommandL(TInt aCommandId) |
|
136 { |
|
137 HideMenu(); |
|
138 |
|
139 // Respond to softkey events |
|
140 switch (aCommandId) |
|
141 { |
|
142 case EAknSoftkeyOk: |
|
143 case EAknSoftkeySelect: |
|
144 SelectCurrentItemL(); // has non-trivial implementations in listbox type |
|
145 // controls to put the selection on the current item |
|
146 AttemptExitL( ETrue ); |
|
147 iController.CommitPreviewChanges(); |
|
148 break; |
|
149 case EAknSoftkeyCancel: |
|
150 AttemptExitL( EFalse ); |
|
151 iController.CancelPreviewChangesL(); |
|
152 break; |
|
153 default: |
|
154 break; |
|
155 } |
|
156 } |
|
157 |
|
158 // --------------------------------------------------------------------------- |
|
159 // CCamContextAwareSettingPage::PreviewSettingChangeL |
|
160 // Previews the setting value |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 TInt CCamContextAwareSettingPage::PreviewSettingChange( TAny* aAny ) |
|
164 { |
|
165 CCamContextAwareSettingPage* settingPage = |
|
166 static_cast<CCamContextAwareSettingPage*>( aAny ); |
|
167 |
|
168 // preview the setting value - will |
|
169 // update the engine and the navi couner |
|
170 TRAPD( ignore, settingPage->iController.PreviewSettingChangeL( |
|
171 settingPage->iParent.Identifier(), settingPage->iCurrentVal ) ); |
|
172 |
|
173 if(ignore) |
|
174 { |
|
175 // Lint error removal |
|
176 } |
|
177 |
|
178 // cancel the timer |
|
179 settingPage->iTimer->Cancel(); |
|
180 |
|
181 return KErrNone; |
|
182 } |
|