|
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 Image/Video quality.* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <gscamerapluginrsc.rsg> |
|
21 #include <aknsettingitemlist.h> |
|
22 #include <barsread.h> |
|
23 #include "GSCamQualitySettingPage.h" |
|
24 #include "GSCamQualitySettingContainer.h" |
|
25 #include "CamUtility.h" |
|
26 #include "MCamAppController.h" |
|
27 #include "CamAppUiBase.h" |
|
28 #include <aknlayoutscalable_apps.cdl.h> |
|
29 |
|
30 |
|
31 // ============================ MEMBER FUNCTIONS =============================== |
|
32 // --------------------------------------------------------------------------- |
|
33 // CGSCamQualitySettingPage::CGSCamQualitySettingPage |
|
34 // C++ constructor |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 CGSCamQualitySettingPage::CGSCamQualitySettingPage( |
|
38 TCamCameraMode aMode, |
|
39 TDesC& aSettingTitleText, |
|
40 TInt aSettingNumber, |
|
41 TInt aControlType, |
|
42 TInt aEditorResourceId, |
|
43 TInt aSettingPageResourceId, |
|
44 MAknQueryValue& aQueryValue ) |
|
45 : CAknSettingPage( &aSettingTitleText, |
|
46 aSettingNumber, |
|
47 aControlType, |
|
48 aEditorResourceId, |
|
49 aSettingPageResourceId ), |
|
50 iQueryValue( aQueryValue ), |
|
51 iController( static_cast<CCamAppUiBase*>( CCoeEnv::Static()->AppUi() )->AppController() ), |
|
52 iMode( aMode ) |
|
53 { |
|
54 } |
|
55 // --------------------------------------------------------------------------- |
|
56 // CGSCamQualitySettingPage::~CGSCamQualitySettingPage |
|
57 // C++ destructor |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 CGSCamQualitySettingPage::~CGSCamQualitySettingPage() |
|
61 { |
|
62 PRINT( _L("Camera => ~CGSCamQualitySettingPage") ); |
|
63 delete iQualityContainer; |
|
64 |
|
65 if ( iTimer && iTimer->IsActive() ) |
|
66 { |
|
67 iTimer->Cancel(); |
|
68 } |
|
69 delete iTimer; |
|
70 |
|
71 TRAP_IGNORE( iController.CancelPreviewChangesL() ); |
|
72 PRINT( _L("Camera <= ~CGSCamQualitySettingPage") ); |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------------------------- |
|
76 // CGSCamQualitySettingPage::ConstructL |
|
77 // Construct the setting page |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 void CGSCamQualitySettingPage::ConstructL() |
|
81 { |
|
82 // create the timer used for callbacks |
|
83 iTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
84 // this needs to be created before BaseConstructL as it sets the |
|
85 // size of the setting page which will result in SizeChanged being called |
|
86 iQualityContainer = CGSCamQualitySettingContainer::NewL( iController, |
|
87 iMode, |
|
88 this ); |
|
89 BaseConstructL(); |
|
90 |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // CGSCamQualitySettingPage::UpdateSettingL |
|
95 // Called when the state of quality control changes |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 void CGSCamQualitySettingPage::UpdateSettingL() |
|
99 { |
|
100 TBool settingValueEnabled = ETrue; |
|
101 iCurrentVal = iQualityContainer->SelectedQuality(); |
|
102 |
|
103 if ( ECamControllerVideo == iMode ) |
|
104 { |
|
105 iSettingItemId = ECamSettingItemVideoQuality; |
|
106 } |
|
107 else |
|
108 { |
|
109 iSettingItemId = ECamSettingItemPhotoQuality; |
|
110 } |
|
111 |
|
112 // Inform the base setting page class |
|
113 SetDataValidity( settingValueEnabled ); |
|
114 UpdateCbaL(); |
|
115 |
|
116 // If the list item is enabled update the image/video count to |
|
117 // let the user know how this item would affect the remaining images/videos |
|
118 if ( settingValueEnabled ) |
|
119 { |
|
120 if ( iTimer->IsActive() ) |
|
121 { |
|
122 iTimer->Cancel(); |
|
123 } |
|
124 iTimer->Start( 10*1000, |
|
125 10*1000, |
|
126 TCallBack( PreviewSettingChange, this ) ); |
|
127 } |
|
128 } |
|
129 |
|
130 // --------------------------------------------------------------------------- |
|
131 // CGSCamQualitySettingPage::ProcessCommandL |
|
132 // Processes events from the softkeys. |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 void CGSCamQualitySettingPage::ProcessCommandL( TInt aCommandId ) |
|
136 { |
|
137 HideMenu(); |
|
138 |
|
139 // Respond to softkey events |
|
140 switch ( aCommandId ) |
|
141 { |
|
142 case EAknSoftkeyOk: |
|
143 case EAknSoftkeySelect: |
|
144 SelectCurrentItemL(); |
|
145 AttemptExitL( ETrue ); |
|
146 iCurrentVal = iQualityContainer->SelectedQuality(); |
|
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 // CGSCamQualitySettingPage::PostDisplayCheckL |
|
160 // Customises some of the functionality so that the custom quality control |
|
161 // is used instead of the base classes editor control |
|
162 // --------------------------------------------------------------------------- |
|
163 // |
|
164 TBool CGSCamQualitySettingPage::PostDisplayCheckL() |
|
165 { |
|
166 // don't use the editor control in the base class |
|
167 // use the quality control instead. |
|
168 iQualityContainer->SetObserver( this ); |
|
169 return CAknSettingPage::PostDisplayCheckL(); |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------------------------- |
|
173 // CGSCamQualitySettingPage::SelectCurrentItemL |
|
174 // Uses the query value to inform the setting item that |
|
175 // a new quality has been selected |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 void CGSCamQualitySettingPage::SelectCurrentItemL() |
|
179 { |
|
180 iQueryValue.SetCurrentValueIndex( iQualityContainer->SelectedQuality() ); |
|
181 } |
|
182 |
|
183 // --------------------------------------------------------------------------- |
|
184 // CGSCamQualitySettingPage::ConstructFromResourceL |
|
185 // Constructs the quality container from the resource file |
|
186 // --------------------------------------------------------------------------- |
|
187 // |
|
188 void CGSCamQualitySettingPage::ConstructFromResourceL( TResourceReader& aReader ) |
|
189 { |
|
190 // setting page window is created in the base class |
|
191 CAknSettingPage::ConstructFromResourceL( aReader ); |
|
192 |
|
193 TInt resourceId = ( ECamControllerVideo == iMode ) |
|
194 ? R_CAM_SETTING_VIDEO_QUALITY_SLIDER |
|
195 : R_CAM_SETTING_PHOTO_QUALITY_SLIDER; |
|
196 |
|
197 TResourceReader reader; |
|
198 iCoeEnv->CreateResourceReaderLC( reader, resourceId ); |
|
199 iQualityContainer->ConstructFromResourceL( reader ); |
|
200 CleanupStack::PopAndDestroy(); //reader |
|
201 } |
|
202 |
|
203 // --------------------------------------------------------------------------- |
|
204 // CGSCamQualitySettingPage::CountComponentControls |
|
205 // Returns the number of component controls |
|
206 // --------------------------------------------------------------------------- |
|
207 // |
|
208 TInt CGSCamQualitySettingPage::CountComponentControls() const |
|
209 { |
|
210 return 1; // the quality container |
|
211 } |
|
212 |
|
213 // --------------------------------------------------------------------------- |
|
214 // CGSCamQualitySettingPage::ComponentControl |
|
215 // Returns the control at the given index |
|
216 // --------------------------------------------------------------------------- |
|
217 // |
|
218 CCoeControl* CGSCamQualitySettingPage::ComponentControl( TInt /*aIndex*/ ) const |
|
219 { |
|
220 return iQualityContainer; |
|
221 } |
|
222 |
|
223 // --------------------------------------------------------------------------- |
|
224 // CGSCamQualitySettingPage::Draw |
|
225 // Draws the setting page |
|
226 // --------------------------------------------------------------------------- |
|
227 // |
|
228 void CGSCamQualitySettingPage::Draw( const TRect& /*aRect*/ ) const |
|
229 { |
|
230 CWindowGc& gc = SystemGc(); |
|
231 gc.SetPenStyle( CGraphicsContext::ENullPen ); |
|
232 gc.SetBrushColor( KRgbWhite ); |
|
233 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
234 gc.DrawRect( Rect() ); |
|
235 } |
|
236 |
|
237 // --------------------------------------------------------------------------- |
|
238 // CGSCamQualitySettingPage::SizeChanged |
|
239 // Handles a change in the size of the page |
|
240 // --------------------------------------------------------------------------- |
|
241 // |
|
242 void CGSCamQualitySettingPage::SizeChanged() |
|
243 { |
|
244 CAknSettingPage::SizeChanged(); |
|
245 |
|
246 AknLayoutUtils::LayoutControl( iQualityContainer, Rect(), AknLayoutScalable_Apps::main_cam_set_pane_g1( 6 ) ); |
|
247 |
|
248 } |
|
249 |
|
250 // --------------------------------------------------------------------------- |
|
251 // CGSCamQualitySettingPage::OfferKeyEventL |
|
252 // Handles the key event |
|
253 // --------------------------------------------------------------------------- |
|
254 // |
|
255 TKeyResponse |
|
256 CGSCamQualitySettingPage::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
257 TEventCode aType ) |
|
258 { |
|
259 // Always react to Escape key by cancelling the setting page |
|
260 if ( aType == EEventKey && aKeyEvent.iCode == EKeyEscape) |
|
261 { |
|
262 ProcessCommandL( EAknSoftkeyCancel ); |
|
263 return EKeyWasConsumed; |
|
264 } |
|
265 |
|
266 // Only handle other key events if we're focused |
|
267 if ( IsFocused() ) |
|
268 { |
|
269 // Abstraction of key events: Escape is handled like Cancel |
|
270 // OK key is handled like the Select softkey by default |
|
271 if ( aType == EEventKey && aKeyEvent.iCode == EKeyOK ) |
|
272 { |
|
273 if ( aKeyEvent.iRepeats != 0 ) |
|
274 { |
|
275 return EKeyWasConsumed; |
|
276 } |
|
277 if ( DataValidity() ) |
|
278 { |
|
279 ProcessCommandL( EAknSoftkeySelect ); |
|
280 } |
|
281 return EKeyWasConsumed; |
|
282 } |
|
283 } |
|
284 |
|
285 // offer the key to the quality container class |
|
286 // if not handled by the setting page |
|
287 return iQualityContainer->OfferKeyEventL( aKeyEvent, aType ); |
|
288 } |
|
289 |
|
290 // --------------------------------------------------------------------------- |
|
291 // CGSCamQualitySettingPage::PreviewSettingChangeL |
|
292 // Previews the setting value |
|
293 // --------------------------------------------------------------------------- |
|
294 // |
|
295 TInt CGSCamQualitySettingPage::PreviewSettingChange( TAny* aAny ) |
|
296 { |
|
297 CGSCamQualitySettingPage* settingPage = |
|
298 static_cast<CGSCamQualitySettingPage*>( aAny ); |
|
299 // preview the setting value - will |
|
300 // update the engine and the navi couner |
|
301 TRAP_IGNORE( settingPage->iController.PreviewSettingChangeL( |
|
302 settingPage->iSettingItemId, |
|
303 settingPage->iCurrentVal ) ); |
|
304 |
|
305 // cancel the timer |
|
306 settingPage->iTimer->Cancel(); |
|
307 |
|
308 return KErrNone; |
|
309 } |