1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "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 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * Navipane control for SVE. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #include <aknnavide.h> |
|
22 #include <Eikspane.h> |
|
23 #include <stringloader.h> |
|
24 #include <AknVolumePopup.h> |
|
25 |
|
26 #include "veinavipanecontrol.h" |
|
27 #include "VeiTimeLabelNavi.h" |
|
28 #include "mveinavipanecontrolobserver.h" |
|
29 #include <VedSimpleCutVideo.rsg> |
|
30 |
|
31 |
|
32 // ======== MEMBER FUNCTIONS ======== |
|
33 |
|
34 // --------------------------------------------------------------------------- |
|
35 // CVeiNaviPaneControl |
|
36 // --------------------------------------------------------------------------- |
|
37 // |
|
38 CVeiNaviPaneControl::CVeiNaviPaneControl( CEikStatusPane* aStatusPane ) : |
|
39 iStatusPane( aStatusPane ) |
|
40 { |
|
41 } |
|
42 |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // ConstructL |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 void CVeiNaviPaneControl::ConstructL() |
|
49 { |
|
50 if( iStatusPane ) |
|
51 { |
|
52 iNaviPane = (CAknNavigationControlContainer*) iStatusPane->ControlL( |
|
53 TUid::Uid(EEikStatusPaneUidNavi) ); |
|
54 iTimeNavi = CreateTimeLabelNaviL(); |
|
55 iVolumeNavi = iNaviPane->CreateVolumeIndicatorL( |
|
56 R_AVKON_NAVI_PANE_VOLUME_INDICATOR ); |
|
57 iVolumeNavi->SetObserver( this ); |
|
58 iVolumeHider = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
59 } |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // NewL |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 CVeiNaviPaneControl* CVeiNaviPaneControl::NewL( CEikStatusPane* aStatusPane ) |
|
67 { |
|
68 CVeiNaviPaneControl* self = |
|
69 new( ELeave ) CVeiNaviPaneControl( aStatusPane ); |
|
70 CleanupStack::PushL( self ); |
|
71 self->ConstructL(); |
|
72 CleanupStack::Pop( self ); |
|
73 return self; |
|
74 } |
|
75 |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // ~CVeiNaviPaneControl |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 CVeiNaviPaneControl::~CVeiNaviPaneControl() |
|
82 { |
|
83 iObserver = NULL; |
|
84 delete iTimeNavi; |
|
85 delete iVolumeNavi; |
|
86 delete iVolumeHider; |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // DrawTimeNaviL |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 void CVeiNaviPaneControl::DrawTimeNaviL( TTime aElapsed, TTime aTotal ) |
|
94 { |
|
95 // check if time is over 59min:59s, then use 00h:00m:00s |
|
96 TBool useLong( aTotal.DateTime().Hour() ); |
|
97 |
|
98 HBufC* dateFormatString = CCoeEnv::Static()->AllocReadResourceLC( |
|
99 useLong ? R_QTN_TIME_DURAT_LONG_WITH_ZERO : |
|
100 R_QTN_TIME_DURAT_MIN_SEC_WITH_ZERO ); |
|
101 |
|
102 const TInt bufLength(16); |
|
103 TBuf<bufLength> elapsedBuf; |
|
104 aElapsed.FormatL(elapsedBuf, *dateFormatString); |
|
105 TBuf<bufLength> totalBuf; |
|
106 aTotal.FormatL(totalBuf, *dateFormatString); |
|
107 CleanupStack::PopAndDestroy(dateFormatString); |
|
108 |
|
109 CDesCArrayFlat* strings = new (ELeave) CDesCArrayFlat(2); |
|
110 CleanupStack::PushL(strings); |
|
111 strings->AppendL(elapsedBuf); |
|
112 strings->AppendL(totalBuf); |
|
113 HBufC* stringholder = StringLoader::LoadL(R_VEI_NAVI_TIME, *strings); |
|
114 CleanupStack::PopAndDestroy(strings); |
|
115 |
|
116 |
|
117 CleanupStack::PushL(stringholder); |
|
118 |
|
119 GetTimeLabelControl()->SetLabelL(*stringholder); |
|
120 |
|
121 CleanupStack::PopAndDestroy(stringholder); |
|
122 |
|
123 |
|
124 |
|
125 if( iNaviPane->Top() != iVolumeNavi ) |
|
126 { |
|
127 iNaviPane->PushL( *iTimeNavi ); |
|
128 } |
|
129 |
|
130 /* Prevent the screen light dimming. */ |
|
131 if (aElapsed.DateTime().Second() == 0 || |
|
132 aElapsed.DateTime().Second() == 15 || |
|
133 aElapsed.DateTime().Second() == 30 || |
|
134 aElapsed.DateTime().Second() == 45) |
|
135 { |
|
136 User::ResetInactivityTime(); |
|
137 } |
|
138 } |
|
139 |
|
140 // --------------------------------------------------------------------------- |
|
141 // SetPauseIconVisibilityL |
|
142 // --------------------------------------------------------------------------- |
|
143 // |
|
144 void CVeiNaviPaneControl::SetPauseIconVisibilityL( TBool aVisible ) |
|
145 { |
|
146 GetTimeLabelControl()->SetPauseIconVisibilityL( aVisible ); |
|
147 if( iNaviPane->Top() != iVolumeNavi ) |
|
148 { |
|
149 iNaviPane->PushL( *iTimeNavi ); |
|
150 } |
|
151 } |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // SetVolumeIconVisibilityL |
|
155 // --------------------------------------------------------------------------- |
|
156 // |
|
157 void CVeiNaviPaneControl::SetVolumeIconVisibilityL( TBool aVisible ) |
|
158 { |
|
159 GetTimeLabelControl()->SetVolumeIconVisibilityL( aVisible ); |
|
160 if( iNaviPane->Top() != iVolumeNavi ) |
|
161 { |
|
162 iNaviPane->PushL( *iTimeNavi ); |
|
163 } |
|
164 } |
|
165 // --------------------------------------------------------------------------- |
|
166 // ShowVolumeLabelL |
|
167 // --------------------------------------------------------------------------- |
|
168 // |
|
169 void CVeiNaviPaneControl::ShowVolumeLabelL( TInt aVolume ) |
|
170 { |
|
171 GetTimeLabelControl()->SetVolumeIconVisibilityL( ETrue ); |
|
172 |
|
173 // Remove volume slider from navi control after 2 sec |
|
174 iVolumeHider->Cancel(); |
|
175 const TInt twoSeconds(1900000); |
|
176 iVolumeHider->Start(twoSeconds, twoSeconds, |
|
177 TCallBack( CVeiNaviPaneControl::HideVolumeCallbackL, this) ); |
|
178 |
|
179 if (aVolume == 0) |
|
180 { |
|
181 // Hide volume icon when volume is set to 0 |
|
182 GetTimeLabelControl()->SetVolumeIconVisibilityL( EFalse ); |
|
183 } |
|
184 if(GetVolumeControl()->Value()!= aVolume) |
|
185 { |
|
186 //this is in case we change volume with other control than the popup |
|
187 GetVolumeControl()->SetValue(aVolume); |
|
188 } |
|
189 CAknVolumePopup* popup = static_cast<CAknVolumePopup*> ( GetVolumeControl()->Parent() ); |
|
190 TRAP_IGNORE( popup->ShowVolumePopupL() ); |
|
191 |
|
192 } |
|
193 |
|
194 // --------------------------------------------------------------------------- |
|
195 // HandleResourceChange |
|
196 // --------------------------------------------------------------------------- |
|
197 // |
|
198 void CVeiNaviPaneControl::HandleResourceChange( TInt aType ) |
|
199 { |
|
200 if( iTimeNavi && iVolumeNavi ) |
|
201 { |
|
202 iTimeNavi->DecoratedControl()->HandleResourceChange( aType ); |
|
203 iVolumeNavi->DecoratedControl()->HandleResourceChange( aType ); |
|
204 } |
|
205 } |
|
206 |
|
207 |
|
208 // --------------------------------------------------------------------------- |
|
209 // HandleResourceChange from MCoeControlObserver |
|
210 // --------------------------------------------------------------------------- |
|
211 // |
|
212 void CVeiNaviPaneControl::HandleControlEventL( |
|
213 CCoeControl* /* aControl */,TCoeEvent /* aEventType */ ) |
|
214 { |
|
215 CAknNavigationDecorator* cntr = iNaviPane->Top( ); |
|
216 if ( iVolumeNavi && cntr == iVolumeNavi ) |
|
217 { |
|
218 if( iObserver ) |
|
219 { |
|
220 iObserver->SetVolumeLevelL( GetVolumeControl()->Value() ); |
|
221 } |
|
222 } |
|
223 |
|
224 } |
|
225 |
|
226 // --------------------------------------------------------------------------- |
|
227 // HandleNaviEventL from MTimeLabelNaviObserver |
|
228 // --------------------------------------------------------------------------- |
|
229 // |
|
230 void CVeiNaviPaneControl::HandleNaviEventL() |
|
231 { |
|
232 // Open Volume slider |
|
233 // First push then set value |
|
234 iNaviPane->PushL(*iVolumeNavi); |
|
235 TInt currenValue( GetVolumeControl()->Value() ); |
|
236 ShowVolumeLabelL( currenValue ); |
|
237 |
|
238 } |
|
239 |
|
240 // --------------------------------------------------------------------------- |
|
241 // CreateTimeLabelNaviL |
|
242 // --------------------------------------------------------------------------- |
|
243 // |
|
244 CAknNavigationDecorator* CVeiNaviPaneControl::CreateTimeLabelNaviL() |
|
245 { |
|
246 ASSERT( iNaviPane ); |
|
247 |
|
248 CVeiTimeLabelNavi* timelabelnavi = CVeiTimeLabelNavi::NewLC(); |
|
249 timelabelnavi->SetNaviObserver( this ); |
|
250 CAknNavigationDecorator* decoratedFolder = CAknNavigationDecorator::NewL( |
|
251 iNaviPane, timelabelnavi, CAknNavigationDecorator::ENotSpecified); |
|
252 CleanupStack::Pop(timelabelnavi); |
|
253 |
|
254 CleanupStack::PushL(decoratedFolder); |
|
255 decoratedFolder->SetContainerWindowL(*iNaviPane); |
|
256 CleanupStack::Pop(decoratedFolder); |
|
257 decoratedFolder->MakeScrollButtonVisible(EFalse); |
|
258 |
|
259 return decoratedFolder; |
|
260 } |
|
261 |
|
262 // --------------------------------------------------------------------------- |
|
263 // GetTimeLabelControl |
|
264 // --------------------------------------------------------------------------- |
|
265 // |
|
266 CVeiTimeLabelNavi* CVeiNaviPaneControl::GetTimeLabelControl() |
|
267 { |
|
268 ASSERT( iTimeNavi ); |
|
269 return static_cast<CVeiTimeLabelNavi*> ( iTimeNavi->DecoratedControl() ); |
|
270 } |
|
271 |
|
272 // --------------------------------------------------------------------------- |
|
273 // GetVolumeControl |
|
274 // --------------------------------------------------------------------------- |
|
275 // |
|
276 CAknVolumeControl* CVeiNaviPaneControl::GetVolumeControl() |
|
277 { |
|
278 ASSERT( iVolumeNavi ); |
|
279 return static_cast<CAknVolumeControl*> ( iVolumeNavi->DecoratedControl() ); |
|
280 } |
|
281 |
|
282 // --------------------------------------------------------------------------- |
|
283 // HideVolumeCallbackL |
|
284 // --------------------------------------------------------------------------- |
|
285 // |
|
286 TInt CVeiNaviPaneControl::HideVolumeCallbackL(TAny* aPtr) |
|
287 { |
|
288 CVeiNaviPaneControl* view = (CVeiNaviPaneControl*)aPtr; |
|
289 view->HideVolume(); |
|
290 return 0; |
|
291 } |
|
292 |
|
293 // --------------------------------------------------------------------------- |
|
294 // HideVolume |
|
295 // --------------------------------------------------------------------------- |
|
296 // |
|
297 void CVeiNaviPaneControl::HideVolume() |
|
298 { |
|
299 ASSERT( iVolumeNavi ); |
|
300 iNaviPane->Pop( iVolumeNavi ); |
|
301 } |
|
302 |
|