|
1 /* |
|
2 * Copyright (c) 2002-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: Implementation of CCbsUiSettingsView class. |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDES |
|
21 #include <AknsUtils.h> // CreateIconL |
|
22 #include <AknsConstants.h> // KAknsIIDQgnMenuCbCxt, KAknsIIDQgnMenuCb2Cxt |
|
23 #include <bldvariant.hrh> // for feature flags |
|
24 #include <featmgr.h> // for feature manager |
|
25 #include <aknViewAppUi.h> |
|
26 #include <avkon.hrh> |
|
27 #include <aknnavide.h> |
|
28 #include <hlplch.h> |
|
29 #include <cbsuiApp.rsg> |
|
30 #include <akntitle.h> |
|
31 #include <cbsuiapp.mbg> |
|
32 #include <barsread.h> |
|
33 #include "CCbsUiSettingsView.h" |
|
34 #include "ccbsuisettingsviewcontainer.h" |
|
35 #include "Cbsuiapp.hrh" |
|
36 #include "CCbsUiappApplication.h" |
|
37 #include "CbsUiId.h" |
|
38 #include "CbsUiUtility.h" |
|
39 #include "CbsUiPanic.h" |
|
40 #include "CCbsUiSettingsMonitor.h" |
|
41 #include "CbsUiConstants.h" |
|
42 #include "MCbs.h" |
|
43 |
|
44 |
|
45 |
|
46 // CONSTANTS |
|
47 static const TUid KUidCbsUiappApp = { KUidCbsUiappDef }; |
|
48 |
|
49 |
|
50 |
|
51 // ================= MEMBER FUNCTIONS ======================= |
|
52 |
|
53 // C++ constructor |
|
54 CCbsUiSettingsView::CCbsUiSettingsView( MCbs& aServer ) |
|
55 : iServer(aServer) |
|
56 { |
|
57 } |
|
58 |
|
59 // Symbian OS default constructor can leave. |
|
60 void CCbsUiSettingsView::ConstructL() |
|
61 { |
|
62 BaseConstructL(R_CBSUI_SETTINGSVIEW); |
|
63 iImageLibrary = iCoeEnv->AllocReadResourceL(R_CBS_IMAGE_LIBRARY); |
|
64 iSettingsMonitor = CCbsUiSettingsMonitor::NewL(iServer, *this); |
|
65 } |
|
66 |
|
67 // Two-phased constructor. |
|
68 CCbsUiSettingsView* CCbsUiSettingsView::NewL( MCbs& aServer ) |
|
69 { |
|
70 CCbsUiSettingsView* self = new (ELeave) CCbsUiSettingsView( aServer ); |
|
71 CleanupStack::PushL( self ); |
|
72 self->ConstructL(); |
|
73 CleanupStack::Pop(); |
|
74 return self; |
|
75 } |
|
76 |
|
77 // Destructor |
|
78 CCbsUiSettingsView::~CCbsUiSettingsView() |
|
79 { |
|
80 if (iContainer) |
|
81 { |
|
82 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
83 |
|
84 // Destroy the control container |
|
85 delete iContainer; |
|
86 } |
|
87 |
|
88 delete iDecoratedLabel; |
|
89 delete iImageLibrary; |
|
90 delete iSettingsMonitor; |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------- |
|
94 // CCbsUiSettingsView::Id |
|
95 // |
|
96 // |
|
97 // --------------------------------------------------------- |
|
98 // |
|
99 TUid CCbsUiSettingsView::Id() const |
|
100 { |
|
101 return TUid::Uid( ECbsUiSettingsViewId ); |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------- |
|
105 // CCbsUiSettingsView::HandleCommandL |
|
106 // |
|
107 // |
|
108 // --------------------------------------------------------- |
|
109 // |
|
110 void CCbsUiSettingsView::HandleCommandL( TInt aCommand ) |
|
111 { |
|
112 switch ( aCommand ) |
|
113 { |
|
114 case EAknSoftkeyBack: |
|
115 { |
|
116 // if it has been CBS then do this |
|
117 if ( !iFromOtherApplication ) |
|
118 { |
|
119 ActivateTopicListViewL(); |
|
120 } |
|
121 else |
|
122 { |
|
123 AppUi()->ProcessCommandL( EAknCmdExit ); |
|
124 } |
|
125 break; |
|
126 } |
|
127 case EAknSoftkeyChange: |
|
128 { |
|
129 iContainer->HandleListViewActionL( EFalse ); |
|
130 break; |
|
131 } |
|
132 case ECbsUiappSettingsViewCmdChange: |
|
133 { |
|
134 iContainer->HandleListViewActionL( ETrue ); |
|
135 break; |
|
136 } |
|
137 case EAknCmdHelp: |
|
138 AppUi()->HandleCommandL( aCommand ); |
|
139 break; |
|
140 case EAknCmdExit: |
|
141 { |
|
142 AppUi()->ProcessCommandL( EAknCmdExit ); |
|
143 break; |
|
144 } |
|
145 default: |
|
146 break; |
|
147 } |
|
148 } |
|
149 |
|
150 // --------------------------------------------------------- |
|
151 // CCbsUiSettingsView::DoActivateL |
|
152 // |
|
153 // Creates container, and calls updatenavipaneL() |
|
154 // --------------------------------------------------------- |
|
155 // |
|
156 void CCbsUiSettingsView::DoActivateL( const TVwsViewId& aPrevViewId, |
|
157 TUid /*aCustomMessageId*/, |
|
158 const TDesC8& /*aCustomMessage*/ ) |
|
159 { |
|
160 __ASSERT_DEBUG( &aPrevViewId, CbsUiPanic(EErrNullPointer) ); |
|
161 iPrevViewId = aPrevViewId; |
|
162 |
|
163 if ( iPrevViewId.iAppUid != KUidCbsUiappApp ) |
|
164 { |
|
165 iFromOtherApplication = ETrue; |
|
166 } |
|
167 else |
|
168 { |
|
169 iFromOtherApplication = EFalse; |
|
170 } |
|
171 |
|
172 if ( !iContainer ) |
|
173 { |
|
174 iContainer = CCbsUiSettingsViewContainer::NewL( |
|
175 *this, |
|
176 ClientRect(), |
|
177 iServer ); |
|
178 AppUi()->AddToViewStackL( *this, iContainer ); |
|
179 } |
|
180 else |
|
181 { |
|
182 iContainer->SetFocusToFirstItem(); |
|
183 } |
|
184 |
|
185 iContainer->ActivateL(); |
|
186 |
|
187 UpdateNaviPaneL(); |
|
188 UpdateTitlePaneL(); |
|
189 |
|
190 } |
|
191 |
|
192 // --------------------------------------------------------- |
|
193 // CCbsUiSettingsView::DoDeactivate |
|
194 // |
|
195 // Deletes container and decorated labels |
|
196 // --------------------------------------------------------- |
|
197 // |
|
198 void CCbsUiSettingsView::DoDeactivate() |
|
199 { |
|
200 if ( iContainer ) |
|
201 { |
|
202 // Remove view and its control from the view stack |
|
203 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
204 // Destroy the container control |
|
205 delete iContainer; |
|
206 iContainer = NULL; |
|
207 } |
|
208 |
|
209 delete iDecoratedLabel; |
|
210 iDecoratedLabel = NULL; |
|
211 } |
|
212 |
|
213 // --------------------------------------------------------- |
|
214 // CCbsUiSettingsView::UpdateNaviPaneL |
|
215 // |
|
216 // Must be implemented |
|
217 // --------------------------------------------------------- |
|
218 // |
|
219 void CCbsUiSettingsView::UpdateNaviPaneL() |
|
220 { |
|
221 __ASSERT_DEBUG( !iDecoratedLabel, CbsUiPanic(EErrAllreadyExists) ); |
|
222 |
|
223 delete iDecoratedLabel; |
|
224 iDecoratedLabel = NULL; |
|
225 |
|
226 iDecoratedLabel = CbsUiUtility::CreateEmptyNavigationPaneL(); |
|
227 } |
|
228 |
|
229 // --------------------------------------------------------- |
|
230 // CCbsUiSettingsView::UpdateSettingsL |
|
231 // |
|
232 // |
|
233 // --------------------------------------------------------- |
|
234 // |
|
235 void CCbsUiSettingsView::UpdateSettingsL() |
|
236 { |
|
237 if ( iContainer ) |
|
238 { |
|
239 iContainer->UpdateSettingsL(); |
|
240 } |
|
241 } |
|
242 |
|
243 // --------------------------------------------------------- |
|
244 // CCbsUiSettingsView::UpdateContextPaneL |
|
245 // |
|
246 // |
|
247 // --------------------------------------------------------- |
|
248 // |
|
249 void CCbsUiSettingsView::UpdateContextPaneL() |
|
250 { |
|
251 __ASSERT_DEBUG( iImageLibrary, CbsUiPanic(EErrNullPointer) ); |
|
252 |
|
253 CEikStatusPane* sp = StatusPane(); |
|
254 |
|
255 __ASSERT_DEBUG( sp, CbsUiPanic( EStatusPaneError ) ); |
|
256 |
|
257 TBool reception; |
|
258 iServer.GetReceptionStatus( reception ); |
|
259 |
|
260 CAknTitlePane* title = STATIC_CAST(CAknTitlePane*, sp-> |
|
261 ControlL( TUid::Uid(EEikStatusPaneUidTitle) )); |
|
262 |
|
263 __ASSERT_DEBUG( title, CbsUiPanic(EErrNullPointer) ); |
|
264 |
|
265 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
266 |
|
267 if (reception) |
|
268 { |
|
269 CFbsBitmap* bmp = NULL; |
|
270 CFbsBitmap* maskbmp = NULL; |
|
271 #ifdef __SCALABLE_ICONS |
|
272 AknsUtils::CreateIconL( skin, KAknsIIDQgnMenuCbCxt, bmp, |
|
273 maskbmp, *iImageLibrary, EMbmCbsuiappQgn_menu_cb, |
|
274 EMbmCbsuiappQgn_menu_cb_mask ); |
|
275 #else |
|
276 AknsUtils::CreateIconL( skin, KAknsIIDQgnMenuCbCxt, bmp, |
|
277 maskbmp, *iImageLibrary, EMbmCbsuiappQgn_menu_cb_cxt, |
|
278 EMbmCbsuiappQgn_menu_cb_cxt_mask ); |
|
279 #endif //__SCALABLE_ICONS |
|
280 title->SetSmallPicture(bmp, maskbmp, ETrue); |
|
281 } |
|
282 else |
|
283 { |
|
284 CFbsBitmap* bmp = NULL; |
|
285 CFbsBitmap* maskbmp = NULL; |
|
286 #ifdef __SCALABLE_ICONS |
|
287 AknsUtils::CreateIconL( skin, KAknsIIDQgnMenuCb2Cxt, bmp, |
|
288 maskbmp, *iImageLibrary, EMbmCbsuiappQgn_menu_cb_2, |
|
289 EMbmCbsuiappQgn_menu_cb_2_mask); |
|
290 #else |
|
291 AknsUtils::CreateIconL( skin, KAknsIIDQgnMenuCb2Cxt, bmp, |
|
292 maskbmp, *iImageLibrary, EMbmCbsuiappQgn_menu_cb_2_cxt, |
|
293 EMbmCbsuiappQgn_menu_cb_2_cxt_mask); |
|
294 #endif //__SCALABLE_ICONS |
|
295 title->SetSmallPicture(bmp, maskbmp, ETrue); |
|
296 } |
|
297 |
|
298 } |
|
299 |
|
300 // --------------------------------------------------------- |
|
301 // CCbsUiSettingsView::SettingsChangedL |
|
302 // |
|
303 // |
|
304 // --------------------------------------------------------- |
|
305 // |
|
306 void CCbsUiSettingsView::SettingsChangedL( TCbsSettingsEvent aEvent ) |
|
307 { |
|
308 if ( aEvent == ECbsModifiedLanguages ) |
|
309 { |
|
310 UpdateSettingsL(); |
|
311 } |
|
312 UpdateContextPaneL(); |
|
313 } |
|
314 |
|
315 |
|
316 // --------------------------------------------------------- |
|
317 // CCbsUiSettingsView::HandleRectChangeInContainer |
|
318 // |
|
319 // |
|
320 // --------------------------------------------------------- |
|
321 // |
|
322 void CCbsUiSettingsView::HandleRectChangeInContainer() |
|
323 { |
|
324 if ( iContainer ) |
|
325 { |
|
326 iContainer->SetRect( ClientRect() ); |
|
327 } |
|
328 } |
|
329 |
|
330 |
|
331 // --------------------------------------------------------- |
|
332 // CCbsUiSettingsView::DynInitMenuPaneL |
|
333 // |
|
334 // Delete help menu item if help is not in use |
|
335 // |
|
336 // --------------------------------------------------------- |
|
337 // |
|
338 void CCbsUiSettingsView::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane ) |
|
339 { |
|
340 switch ( aResourceId ) |
|
341 { |
|
342 case R_CBSUI_SETTINGSVIEW_FILE_MENU: |
|
343 { |
|
344 if( !FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
345 { |
|
346 aMenuPane->DeleteMenuItem( EAknCmdHelp ); |
|
347 } |
|
348 break; |
|
349 } |
|
350 default: |
|
351 break; |
|
352 } |
|
353 } |
|
354 |
|
355 |
|
356 // --------------------------------------------------------- |
|
357 // CCbsUiSettingsView::ActivateTopicListViewL |
|
358 // |
|
359 // |
|
360 // --------------------------------------------------------- |
|
361 // |
|
362 void CCbsUiSettingsView::ActivateTopicListViewL() const |
|
363 { |
|
364 TPckgBuf<TCbsTopicNumber> pckgDummy(KCbsInvalidTopicNumber); |
|
365 |
|
366 AppUi()->ActivateLocalViewL( |
|
367 TUid::Uid(ECbsUiTopicListViewId), |
|
368 KSetFocusToCurrentId, |
|
369 pckgDummy); |
|
370 } |
|
371 |
|
372 |
|
373 // --------------------------------------------------------- |
|
374 // CCbsUiTopicListView::UpdateTitlePaneL |
|
375 // |
|
376 // --------------------------------------------------------- |
|
377 // |
|
378 void CCbsUiSettingsView::UpdateTitlePaneL() const |
|
379 { |
|
380 CEikStatusPane *sp = StatusPane(); |
|
381 CAknTitlePane *title = STATIC_CAST( CAknTitlePane*, sp-> |
|
382 ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
383 |
|
384 __ASSERT_DEBUG( sp && title, CbsUiPanic( EStatusOrTitlePaneError ) ); |
|
385 |
|
386 TResourceReader titleReader; |
|
387 iCoeEnv->CreateResourceReaderLC( titleReader, R_QTN_CB_TITLE_CBS ); |
|
388 title->SetFromResourceL( titleReader ); |
|
389 CleanupStack::PopAndDestroy(); // titleReader |
|
390 } |
|
391 |
|
392 |
|
393 // End of File |