|
1 /* |
|
2 * Copyright (c) 2005-2008 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 CGSAccTvoutView class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32cmn.h> // For accessoriescrkeys.h |
|
20 #include <accessoriescrkeys.h> |
|
21 #include <AknQueryDialog.h> |
|
22 #include <avkon.hrh> |
|
23 #include <gsaccessoryplugin.rsg> |
|
24 #include <gscommon.hrh> |
|
25 #include <GSServerEngine.h> |
|
26 #include <StringLoader.h> |
|
27 |
|
28 #include "acclocalviewids.h" |
|
29 #include "gsaccessoryplugin.hrh" |
|
30 #include "gsaccessorypluginmodel.h" |
|
31 #include "gsacctvoutcontainer.h" |
|
32 #include "gsacctvoutview.h" |
|
33 #include "trace.h" |
|
34 |
|
35 // ========================= MEMBER FUNCTIONS ================================ |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // CGSAccTvoutView::NewLC() |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 CGSAccTvoutView* CGSAccTvoutView::NewLC( CGSAccessoryPluginModel& aModel ) |
|
42 { |
|
43 CGSAccTvoutView* self = new ( ELeave ) CGSAccTvoutView( aModel ); |
|
44 CleanupStack::PushL( self ); |
|
45 self->ConstructL(); |
|
46 return self; |
|
47 } |
|
48 |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // CGSAccTvoutView::~CGSAccTvoutView() |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 CGSAccTvoutView::~CGSAccTvoutView() |
|
55 { |
|
56 FUNC_LOG; |
|
57 |
|
58 delete iServerEngine; |
|
59 } |
|
60 |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // TUid CGSAccTvoutView::Id() |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 TUid CGSAccTvoutView::Id() const |
|
67 { |
|
68 return KAccTvoutViewId; |
|
69 } |
|
70 |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // CGSAccTvoutView::HandleCommandL() |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 void CGSAccTvoutView::HandleCommandL( TInt aCommand ) |
|
77 { |
|
78 FUNC_LOG; |
|
79 |
|
80 switch ( aCommand ) |
|
81 { |
|
82 case EGSCmdAppChange: |
|
83 { |
|
84 const TInt currentFeatureId = iContainer->CurrentFeatureId(); |
|
85 if ( currentFeatureId == EGSSettIdTvAspectRatio ) |
|
86 { |
|
87 // Change aspect ratio setting through selection dialog |
|
88 ChangeAspectRatioSettingL( ETrue ); |
|
89 } |
|
90 else if ( currentFeatureId == EGSSettIdTvFlickerFilter ) |
|
91 { |
|
92 // Change flicker filter setting through selection dialog |
|
93 ChangeFlickerFilterSettingL( ETrue ); |
|
94 } |
|
95 else |
|
96 { |
|
97 // Act as user had pressed the selection key |
|
98 HandleListBoxSelectionL( currentFeatureId ); |
|
99 } |
|
100 } |
|
101 break; |
|
102 case EAknSoftkeyBack: // Fall through |
|
103 case EAknCmdExit: |
|
104 if ( iSettingChanged ) |
|
105 { |
|
106 DisplaySettingsChangeNoteL(); |
|
107 } // Fall through |
|
108 default: |
|
109 CGSAccBaseView::HandleCommandL( aCommand ); |
|
110 break; |
|
111 } |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // CGSAccTvoutView::NewContainerL() |
|
116 // --------------------------------------------------------------------------- |
|
117 // |
|
118 void CGSAccTvoutView::NewContainerL() |
|
119 { |
|
120 iContainer = new ( ELeave ) CGSAccTvoutContainer( iModel, *iServerEngine ); |
|
121 } |
|
122 |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // CGSAccTvoutView::HandleListBoxSelectionL() |
|
126 // --------------------------------------------------------------------------- |
|
127 // |
|
128 void CGSAccTvoutView::HandleListBoxSelectionL( TInt aSelectedItem ) |
|
129 { |
|
130 FUNC_LOG; |
|
131 |
|
132 // User has pressed selection key. If the selected item has just two |
|
133 // possible values, flip the value to the other option. If the item has |
|
134 // more possible values, show a selection dialog. |
|
135 switch ( aSelectedItem ) |
|
136 { |
|
137 case EGSSettIdTvoutDP: |
|
138 // Show selection dialog for the accessory default profile |
|
139 ChangeDefaultProfileL( |
|
140 KSettingsTvOutDefaultProfile, EGSSettIdTvoutDP ); |
|
141 break; |
|
142 case EGSSettIdTvAspectRatio: |
|
143 // Change aspect ratio setting without selection dialog |
|
144 ChangeAspectRatioSettingL( EFalse ); |
|
145 break; |
|
146 case EGSSettIdTvSystem: |
|
147 // Show selection dialog for the TV system |
|
148 ChangeTvSystemSettingL(); |
|
149 break; |
|
150 case EGSSettIdTvFlickerFilter: |
|
151 // Change flicker filter setting without selection dialog |
|
152 ChangeFlickerFilterSettingL( EFalse ); |
|
153 break; |
|
154 default: |
|
155 break; |
|
156 } |
|
157 } |
|
158 |
|
159 |
|
160 // --------------------------------------------------------------------------- |
|
161 // CGSAccTvoutView::CGSAccTvoutView() |
|
162 // --------------------------------------------------------------------------- |
|
163 // |
|
164 CGSAccTvoutView::CGSAccTvoutView( CGSAccessoryPluginModel& aModel ) |
|
165 : CGSAccBaseView( aModel ), |
|
166 iSettingChanged( EFalse ) |
|
167 { |
|
168 FUNC_LOG; |
|
169 } |
|
170 |
|
171 |
|
172 // --------------------------------------------------------------------------- |
|
173 // CGSAccTvoutView::ConstructL() |
|
174 // --------------------------------------------------------------------------- |
|
175 // |
|
176 void CGSAccTvoutView::ConstructL() |
|
177 { |
|
178 FUNC_LOG; |
|
179 |
|
180 BaseConstructL( R_ACC_TVOUT_VIEW ); |
|
181 |
|
182 iServerEngine = CGSServerEngine::NewL(); |
|
183 } |
|
184 |
|
185 |
|
186 // --------------------------------------------------------------------------- |
|
187 // CGSAccTvoutView::ChangeAspectRatioSettingL() |
|
188 // --------------------------------------------------------------------------- |
|
189 // |
|
190 void CGSAccTvoutView::ChangeAspectRatioSettingL( TBool aSettingPage ) |
|
191 { |
|
192 FUNC_LOG; |
|
193 |
|
194 TInt currentValue = iServerEngine->AspectRatioL(); |
|
195 TBool updateValue( EFalse ); |
|
196 |
|
197 if ( aSettingPage ) |
|
198 { |
|
199 updateValue = ShowRadioButtonSettingsPageL( |
|
200 R_ACC_ASPECT_RATIO_SETTING_PAGE, |
|
201 R_ACC_ASPECT_RATIO_SETTING_PAGE_LBX, |
|
202 currentValue ); |
|
203 } |
|
204 else |
|
205 { |
|
206 // User pressed selection key instead of opening setting page. |
|
207 // Do not ask user input from dialog - just flip the value: |
|
208 // 0 -> 1, 1 -> 0. |
|
209 iModel.FlipValue( currentValue ); |
|
210 updateValue = ETrue; |
|
211 } |
|
212 |
|
213 if ( updateValue ) // If value was changed, store it. |
|
214 { |
|
215 iServerEngine->SetAspectRatioL( currentValue ); |
|
216 UpdateListBoxL( EGSSettIdTvAspectRatio ); |
|
217 iSettingChanged = ETrue; |
|
218 } |
|
219 } |
|
220 |
|
221 |
|
222 // --------------------------------------------------------------------------- |
|
223 // CGSAccTvoutView::ChangeFlickerFilterSettingL() |
|
224 // --------------------------------------------------------------------------- |
|
225 // |
|
226 void CGSAccTvoutView::ChangeFlickerFilterSettingL( TBool aSettingPage ) |
|
227 { |
|
228 FUNC_LOG; |
|
229 |
|
230 TInt currentValue = iServerEngine->FlickerFilterL(); |
|
231 TBool updateValue( EFalse ); |
|
232 |
|
233 if ( aSettingPage ) |
|
234 { |
|
235 updateValue = ShowRadioButtonSettingsPageL( |
|
236 R_ACC_FLICKER_FILTER_SETTING_PAGE, |
|
237 R_ACC_FLICKER_FILTER_SETTING_PAGE_LBX, |
|
238 currentValue ); |
|
239 } |
|
240 else |
|
241 { |
|
242 // User pressed selection key instead of opening setting page. |
|
243 // Do not ask user input from dialog - just flip the value: |
|
244 // 0 -> 1, 1 -> 0. |
|
245 iModel.FlipValue( currentValue ); |
|
246 updateValue = ETrue; |
|
247 } |
|
248 |
|
249 if ( updateValue ) // If value was changed, store it. |
|
250 { |
|
251 iServerEngine->SetFlickerFilterL( currentValue ); |
|
252 UpdateListBoxL( EGSSettIdTvFlickerFilter ); |
|
253 iSettingChanged = ETrue; |
|
254 } |
|
255 } |
|
256 |
|
257 |
|
258 // --------------------------------------------------------------------------- |
|
259 // CGSAccTvoutView::ChangeTvSystemSettingL() |
|
260 // --------------------------------------------------------------------------- |
|
261 // |
|
262 void CGSAccTvoutView::ChangeTvSystemSettingL() |
|
263 { |
|
264 FUNC_LOG; |
|
265 |
|
266 TInt currentValue = iServerEngine->TvSystemL(); |
|
267 |
|
268 // If PALM is not supported, index correction |
|
269 if( !iModel.PalmSupport() && currentValue ) |
|
270 { |
|
271 currentValue--; |
|
272 } |
|
273 |
|
274 if ( ShowRadioButtonSettingsPageL( |
|
275 R_ACC_TV_SYSTEM_SETTING_PAGE, |
|
276 iModel.PalmSupport() ? |
|
277 R_ACC_TV_SYSTEM_SETTING_PAGE_LBX : |
|
278 R_ACC_TV_SYSTEM_SETTING_PAGE_NO_PALM_LBX, |
|
279 currentValue ) ) |
|
280 { |
|
281 if( !iModel.PalmSupport() && currentValue ) |
|
282 { |
|
283 //In case PALM support is missing fix the NTSC value index |
|
284 currentValue++; |
|
285 } |
|
286 |
|
287 iServerEngine->SetTvSystemL( currentValue ); |
|
288 UpdateListBoxL( EGSSettIdTvSystem ); |
|
289 iSettingChanged = ETrue; |
|
290 } |
|
291 } |
|
292 |
|
293 |
|
294 // --------------------------------------------------------------------------- |
|
295 // CGSAccTvoutView::DisplaySettingsChangeNoteL |
|
296 // --------------------------------------------------------------------------- |
|
297 // |
|
298 void CGSAccTvoutView::DisplaySettingsChangeNoteL() |
|
299 { |
|
300 FUNC_LOG; |
|
301 |
|
302 HBufC* buf = StringLoader::LoadLC( R_ACC_TV_SETTINGS_CHANGE_STR, iCoeEnv ); |
|
303 |
|
304 CAknQueryDialog* query = |
|
305 new( ELeave ) CAknQueryDialog( CAknQueryDialog::ENoTone ); |
|
306 query->PrepareLC( R_ACC_TV_SETTINGS_CHANGE_QUERY ); |
|
307 query->SetPromptL( *buf ); |
|
308 |
|
309 query->RunLD(); |
|
310 |
|
311 // No need to display note until setting is changed again |
|
312 iSettingChanged = EFalse; |
|
313 |
|
314 CleanupStack::PopAndDestroy( buf ); |
|
315 } |
|
316 |