|
1 /* |
|
2 * Copyright (c) 2010 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 VideoPlaybackToolBar |
|
15 * |
|
16 */ |
|
17 |
|
18 // Version : %version: 10 % |
|
19 |
|
20 |
|
21 |
|
22 #include <QTimer> |
|
23 #include <QGraphicsLayout> |
|
24 |
|
25 #include <hbaction.h> |
|
26 #include <hbtoolbar.h> |
|
27 #include <hbinstance.h> |
|
28 #include <hbtoolbutton.h> |
|
29 #include <w32std.h> |
|
30 |
|
31 #include "mpxvideo_debug.h" |
|
32 #include "videobaseplaybackview.h" |
|
33 #include "videoplaybacktoolbar.h" |
|
34 #include "mpxcommonvideoplaybackview.hrh" |
|
35 #include "videoplaybackdocumentloader.h" |
|
36 #include "videoplaybackviewfiledetails.h" |
|
37 #include "videoplaybackcontrolscontroller.h" |
|
38 |
|
39 const int KSeekStartTimeOut = 700; |
|
40 const int KRetrieveButtonTimeOut = 1000; |
|
41 |
|
42 // ------------------------------------------------------------------------------------------------- |
|
43 // VideoPlaybackToolBar::VideoPlaybackToolBar() |
|
44 // ------------------------------------------------------------------------------------------------- |
|
45 // |
|
46 VideoPlaybackToolBar::VideoPlaybackToolBar( |
|
47 VideoPlaybackControlsController* controller ) |
|
48 : mController( controller ) |
|
49 , mSeekStartTimer( NULL ) |
|
50 , mRetrieveButtonTimer( NULL ) |
|
51 , mSeekingState( ENotSeeking ) |
|
52 , mInitialized( false ) |
|
53 , mPosition( 0 ) |
|
54 , mDuration( 0 ) |
|
55 , mAspectRatio( EMPXPbvCmdNaturalAspectRatio ) |
|
56 { |
|
57 MPX_ENTER_EXIT(_L("VideoPlaybackToolBar::VideoPlaybackToolBar")); |
|
58 |
|
59 mToolBar = mController->view()->toolBar(); |
|
60 mToolBar->setOrientation( Qt::Horizontal ); |
|
61 |
|
62 mController->view()->hideItems( Hb::ToolBarItem ); |
|
63 |
|
64 initialize(); |
|
65 } |
|
66 |
|
67 // ------------------------------------------------------------------------------------------------- |
|
68 // VideoPlaybackToolBar::~VideoPlaybackToolBar() |
|
69 // ------------------------------------------------------------------------------------------------- |
|
70 // |
|
71 VideoPlaybackToolBar::~VideoPlaybackToolBar() |
|
72 { |
|
73 MPX_DEBUG(_L("VideoPlaybackToolBar::~VideoPlaybackToolBar()")); |
|
74 |
|
75 mToolBar->clearActions(); |
|
76 |
|
77 for ( int i = 0 ; i < mButtonIcons.count() ; i++ ) |
|
78 { |
|
79 if ( mButtonIcons[i] ) |
|
80 { |
|
81 delete mButtonIcons[i]; |
|
82 } |
|
83 } |
|
84 mButtonIcons.clear(); |
|
85 |
|
86 if ( mSeekStartTimer ) |
|
87 { |
|
88 if ( mSeekStartTimer->isActive() ) |
|
89 { |
|
90 mSeekStartTimer->stop(); |
|
91 } |
|
92 |
|
93 delete mSeekStartTimer; |
|
94 mSeekStartTimer = NULL; |
|
95 } |
|
96 |
|
97 if ( mRetrieveButtonTimer ) |
|
98 { |
|
99 if ( mRetrieveButtonTimer->isActive() ) |
|
100 { |
|
101 mRetrieveButtonTimer->stop(); |
|
102 } |
|
103 |
|
104 delete mRetrieveButtonTimer; |
|
105 mRetrieveButtonTimer = NULL; |
|
106 } |
|
107 } |
|
108 |
|
109 // ------------------------------------------------------------------------------------------------- |
|
110 // VideoPlaybackToolBar::initialize() |
|
111 // ------------------------------------------------------------------------------------------------- |
|
112 // |
|
113 void VideoPlaybackToolBar::initialize() |
|
114 { |
|
115 MPX_ENTER_EXIT(_L("VideoPlaybackToolBar::initialize()")); |
|
116 |
|
117 // |
|
118 // Don't need to initialize buttons once it gets initialized |
|
119 // |
|
120 if ( ! mInitialized ) |
|
121 { |
|
122 mInitialized = true; |
|
123 |
|
124 QActionGroup *actionsGroup = new QActionGroup( mToolBar ); |
|
125 |
|
126 for ( int i = 0 ; i < EButtonCount ; i++ ) |
|
127 { |
|
128 mButtonActions.append( new HbAction( actionsGroup ) ); |
|
129 } |
|
130 |
|
131 for ( int i = 0 ; i < EIconCount ; i++ ) |
|
132 { |
|
133 mButtonIcons.append( new HbIcon() ); |
|
134 } |
|
135 |
|
136 // |
|
137 // RW button |
|
138 // |
|
139 mButtonIcons[ERWIcon]->setIconName( "qtg_mono_previous" ); |
|
140 mButtonActions[E2ndButton]->setIcon( *mButtonIcons[ERWIcon] ); |
|
141 |
|
142 // |
|
143 // Play/Pause button |
|
144 // |
|
145 mButtonIcons[EPlayIcon]->setIconName( "qtg_mono_play" ); |
|
146 mButtonIcons[EPauseIcon]->setIconName( "qtg_mono_pause" ); |
|
147 mButtonActions[E3rdButton]->setIcon( *mButtonIcons[EPlayIcon] ); |
|
148 |
|
149 // |
|
150 // FF button |
|
151 // |
|
152 mButtonIcons[EFFIcon]->setIconName( "qtg_mono_next" ); |
|
153 mButtonActions[E4thButton]->setIcon( *mButtonIcons[EFFIcon] ); |
|
154 |
|
155 // |
|
156 // Details button |
|
157 // |
|
158 mButtonIcons[EDetailsIcon]->setIconName( "qtg_mono_info" ); |
|
159 mButtonActions[E5thButton]->setIcon( *mButtonIcons[EDetailsIcon] ); |
|
160 |
|
161 // |
|
162 // Aspect ratio buttons |
|
163 // |
|
164 mButtonIcons[ENaturalIcon]->setIconName( "qtg_mono_aspect_ratio_natural" ); |
|
165 mButtonIcons[EStretchIcon]->setIconName( "qtg_mono_aspect_ratio_stretched" ); |
|
166 mButtonIcons[EZoomIcon]->setIconName( "qtg_mono_aspect_ratio_zoom" ); |
|
167 mButtonActions[E1stButton]->setIcon( *mButtonIcons[ENaturalIcon] ); |
|
168 |
|
169 // |
|
170 // Attach/Share button |
|
171 // |
|
172 mButtonIcons[EAttachIcon]->setIconName( "qtg_mono_attach" ); |
|
173 mButtonIcons[EShareIcon]->setIconName( "qtg_mono_share" ); |
|
174 |
|
175 for ( int i = 0 ; i < EButtonCount ; i++ ) |
|
176 { |
|
177 mButtonActions[i]->setCheckable( false ); |
|
178 mToolBar->addAction( mButtonActions[i] ); |
|
179 } |
|
180 |
|
181 mDuration = (qreal)mController->fileDetails()->mDuration / (qreal)KPbMilliMultiplier; |
|
182 |
|
183 // |
|
184 // Create a timer for seeking. |
|
185 // We will issue SetPosition every KSeekingTimeOut msec to show the current frame to user |
|
186 // |
|
187 mSeekStartTimer = new QTimer(); |
|
188 mSeekStartTimer->setSingleShot( true ); |
|
189 mSeekStartTimer->setInterval( KSeekStartTimeOut ); |
|
190 |
|
191 // |
|
192 // get window size |
|
193 // |
|
194 RWindow *window = mController->view()->getWindow(); |
|
195 TRect displayRect = TRect( TPoint( window->Position() ), TSize( window->Size() ) ); |
|
196 |
|
197 // |
|
198 // get window aspect ratio |
|
199 // if device is in portrait mode, width > height |
|
200 // if device is in landscape mode, width < height |
|
201 // |
|
202 TReal32 width = (TReal32) displayRect.Width(); |
|
203 TReal32 height = (TReal32) displayRect.Height(); |
|
204 mDisplayAspectRatio = (width > height)? (width / height) : (height / width); |
|
205 } |
|
206 } |
|
207 |
|
208 // ------------------------------------------------------------------------------------------------- |
|
209 // VideoPlaybackToolBar::playPause() |
|
210 // ------------------------------------------------------------------------------------------------- |
|
211 // |
|
212 void VideoPlaybackToolBar::playPause() |
|
213 { |
|
214 MPX_DEBUG(_L("VideoPlaybackToolBar::playPause()")); |
|
215 |
|
216 mController->resetDisappearingTimers( ETimerReset ); |
|
217 mController->handleCommand( EMPXPbvCmdPlayPause ); |
|
218 } |
|
219 |
|
220 // ------------------------------------------------------------------------------------------------- |
|
221 // VideoPlaybackToolBar::ffPressing() |
|
222 // ------------------------------------------------------------------------------------------------- |
|
223 // |
|
224 void VideoPlaybackToolBar::ffPressing() |
|
225 { |
|
226 MPX_ENTER_EXIT(_L("VideoPlaybackToolBar::ffPressing()"), |
|
227 _L("mSeekingState = %d"), mSeekingState ); |
|
228 |
|
229 if ( mSeekingState == ENotSeeking ) |
|
230 { |
|
231 mSeekingState = EFastForwarding; |
|
232 |
|
233 mController->handleCommand( EMPXPbvCmdSeekForward ); |
|
234 } |
|
235 } |
|
236 |
|
237 // ------------------------------------------------------------------------------------------------- |
|
238 // VideoPlaybackToolBar::rwPressing() |
|
239 // ------------------------------------------------------------------------------------------------- |
|
240 // |
|
241 void VideoPlaybackToolBar::rwPressing() |
|
242 { |
|
243 MPX_ENTER_EXIT(_L("VideoPlaybackToolBar::rwPressing()"), |
|
244 _L("mSeekingState = %d"), mSeekingState ); |
|
245 |
|
246 if ( mSeekingState == ENotSeeking ) |
|
247 { |
|
248 mSeekingState = ERewinding; |
|
249 |
|
250 mController->handleCommand( EMPXPbvCmdSeekBackward ); |
|
251 } |
|
252 } |
|
253 |
|
254 // ------------------------------------------------------------------------------------------------- |
|
255 // VideoPlaybackToolBar::ffReleased() |
|
256 // ------------------------------------------------------------------------------------------------- |
|
257 // |
|
258 void VideoPlaybackToolBar::ffReleased() |
|
259 { |
|
260 MPX_ENTER_EXIT(_L("VideoPlaybackToolBar::ffReleased()"), |
|
261 _L("mSeekingState = %d"), mSeekingState ); |
|
262 |
|
263 disconnect( mSeekStartTimer, SIGNAL( timeout() ), this, SLOT( ffPressing() ) ); |
|
264 |
|
265 if ( mSeekStartTimer->isActive() ) |
|
266 { |
|
267 mSeekStartTimer->stop(); |
|
268 } |
|
269 |
|
270 if ( mSeekingState == EFastForwarding ) |
|
271 { |
|
272 mController->handleCommand( EMPXPbvCmdEndSeek ); |
|
273 } |
|
274 else |
|
275 { |
|
276 int temp = mPosition + KMPXFastForward; |
|
277 MPX_DEBUG(_L("VideoPlaybackToolBar::ffReleased() temp position = %d"), temp); |
|
278 |
|
279 // |
|
280 // If it has the playing time which is less than KMPXFastForward, ignore |
|
281 // |
|
282 if ( temp < mDuration ) |
|
283 { |
|
284 mController->handleCommand( EMPXPbvCmdSetPosition, temp ); |
|
285 } |
|
286 } |
|
287 |
|
288 mSeekingState = ENotSeeking; |
|
289 mController->resetDisappearingTimers( ETimerReset ); |
|
290 } |
|
291 |
|
292 // ------------------------------------------------------------------------------------------------- |
|
293 // VideoPlaybackToolBar::rwReleased() |
|
294 // ------------------------------------------------------------------------------------------------- |
|
295 // |
|
296 void VideoPlaybackToolBar::rwReleased() |
|
297 { |
|
298 MPX_ENTER_EXIT(_L("VideoPlaybackToolBar::rwReleased()"), |
|
299 _L("mSeekingState = %d"), mSeekingState ); |
|
300 |
|
301 disconnect( mSeekStartTimer, SIGNAL( timeout() ), this, SLOT( rwPressing() ) ); |
|
302 |
|
303 if ( mSeekStartTimer->isActive() ) |
|
304 { |
|
305 mSeekStartTimer->stop(); |
|
306 } |
|
307 |
|
308 if ( mSeekingState == ERewinding ) |
|
309 { |
|
310 mController->handleCommand( EMPXPbvCmdEndSeek ); |
|
311 } |
|
312 else |
|
313 { |
|
314 int temp = mPosition + KMPXRewind; |
|
315 MPX_DEBUG(_L("VideoPlaybackToolBar::rwReleased() temp position = %d"), temp); |
|
316 |
|
317 // |
|
318 // If it played less than KMPXRewind, jump to 0 |
|
319 // |
|
320 if ( temp < 0 ) |
|
321 { |
|
322 temp = 0; |
|
323 } |
|
324 |
|
325 mController->handleCommand( EMPXPbvCmdSetPosition, temp ); |
|
326 } |
|
327 |
|
328 mSeekingState = ENotSeeking; |
|
329 mController->resetDisappearingTimers( ETimerReset ); |
|
330 } |
|
331 |
|
332 // ------------------------------------------------------------------------------------------------- |
|
333 // VideoPlaybackToolBar::changeAspectRatio() |
|
334 // ------------------------------------------------------------------------------------------------- |
|
335 // |
|
336 void VideoPlaybackToolBar::changeAspectRatio() |
|
337 { |
|
338 MPX_DEBUG(_L("VideoPlaybackToolBar::changeAspectRatio()")); |
|
339 |
|
340 mController->resetDisappearingTimers( ETimerReset ); |
|
341 |
|
342 TMPXVideoPlaybackViewCommandIds cmd = EMPXPbvCmdStretchAspectRatio; |
|
343 |
|
344 switch( mAspectRatio ) |
|
345 { |
|
346 case EMMFZoom: |
|
347 { |
|
348 cmd = EMPXPbvCmdNaturalAspectRatio; |
|
349 break; |
|
350 } |
|
351 case EMMFStretch: |
|
352 { |
|
353 cmd = EMPXPbvCmdZoomAspectRatio; |
|
354 break; |
|
355 } |
|
356 } |
|
357 |
|
358 mController->handleCommand( cmd ); |
|
359 } |
|
360 |
|
361 // ------------------------------------------------------------------------------------------------- |
|
362 // VideoPlaybackToolBar::updateState() |
|
363 // ------------------------------------------------------------------------------------------------- |
|
364 // |
|
365 void VideoPlaybackToolBar::updateState( TMPXPlaybackState state ) |
|
366 { |
|
367 MPX_DEBUG(_L("VideoPlaybackToolBar::updateState() state = %d"), state ); |
|
368 |
|
369 switch ( state ) |
|
370 { |
|
371 case EPbStatePlaying: |
|
372 { |
|
373 mToolBar->setEnabled( true ); |
|
374 |
|
375 mButtonActions[E3rdButton]->setIcon( *mButtonIcons[EPauseIcon] ); |
|
376 |
|
377 if ( ! mController->fileDetails()->mPausableStream ) |
|
378 { |
|
379 // |
|
380 // non-pausable stream, disable 'E3rdButton' action (for 'Pause' button) |
|
381 // |
|
382 mButtonActions[E3rdButton]->setEnabled( false ); |
|
383 } |
|
384 |
|
385 break; |
|
386 } |
|
387 case EPbStatePaused: |
|
388 { |
|
389 mToolBar->setEnabled( true ); |
|
390 |
|
391 mButtonActions[E3rdButton]->setIcon( *mButtonIcons[EPlayIcon] ); |
|
392 |
|
393 if ( ! mButtonActions[E3rdButton]->isEnabled() ) |
|
394 { |
|
395 // |
|
396 // enable 'E3rdButton' action (for 'Play' button) in 'Paused' state |
|
397 // |
|
398 mButtonActions[E3rdButton]->setEnabled( true ); |
|
399 } |
|
400 |
|
401 break; |
|
402 } |
|
403 default: |
|
404 { |
|
405 mToolBar->setEnabled( false ); |
|
406 |
|
407 break; |
|
408 } |
|
409 } |
|
410 } |
|
411 |
|
412 // ------------------------------------------------------------------------------------------------- |
|
413 // VideoPlaybackToolBar::aspectRatioChanged() |
|
414 // ------------------------------------------------------------------------------------------------- |
|
415 // |
|
416 void VideoPlaybackToolBar::aspectRatioChanged( int aspectRatio ) |
|
417 { |
|
418 MPX_DEBUG(_L("VideoPlaybackToolBar::aspectRatioChanged() aspectRatio = %d"), aspectRatio ); |
|
419 |
|
420 mAspectRatio = aspectRatio; |
|
421 |
|
422 // |
|
423 // If we are in attach service or audio only view, then don't update the icon. |
|
424 // Aspect ratio icon slots are shared with attach and share icon. |
|
425 // Just update the mAspectRatio |
|
426 // and once we go back to full screen, we will show the correct aspect ratio icon |
|
427 // |
|
428 if ( ! mController->isAttachOperation() && mController->viewMode() == EFullScreenView ) |
|
429 { |
|
430 switch( mAspectRatio ) |
|
431 { |
|
432 case EMMFNatural: |
|
433 { |
|
434 mButtonActions[E1stButton]->setIcon( *mButtonIcons[EStretchIcon] ); |
|
435 break; |
|
436 } |
|
437 case EMMFStretch: |
|
438 { |
|
439 mButtonActions[E1stButton]->setIcon( *mButtonIcons[EZoomIcon] ); |
|
440 break; |
|
441 } |
|
442 default: |
|
443 { |
|
444 mButtonActions[E1stButton]->setIcon( *mButtonIcons[ENaturalIcon] ); |
|
445 break; |
|
446 } |
|
447 } |
|
448 } |
|
449 } |
|
450 |
|
451 // ------------------------------------------------------------------------------------------------- |
|
452 // VideoPlaybackToolBar::handleButtonPressed() |
|
453 // ------------------------------------------------------------------------------------------------- |
|
454 // |
|
455 void VideoPlaybackToolBar::handleButtonPressed() |
|
456 { |
|
457 MPX_DEBUG(_L("VideoPlaybackToolBar::handleButtonPressed()")); |
|
458 |
|
459 mController->resetDisappearingTimers( ETimerCancel ); |
|
460 } |
|
461 |
|
462 // ------------------------------------------------------------------------------------------------- |
|
463 // VideoPlaybackToolBar::handleRWButtonPressed() |
|
464 // ------------------------------------------------------------------------------------------------- |
|
465 // |
|
466 void VideoPlaybackToolBar::handleRWButtonPressed() |
|
467 { |
|
468 MPX_DEBUG(_L("VideoPlaybackToolBar::handleRWButtonPressed()")); |
|
469 |
|
470 mController->resetDisappearingTimers( ETimerCancel ); |
|
471 |
|
472 connect( mSeekStartTimer, SIGNAL( timeout() ), this, SLOT( rwPressing() ) ); |
|
473 |
|
474 if ( mSeekStartTimer->isActive() ) |
|
475 { |
|
476 mSeekStartTimer->stop(); |
|
477 } |
|
478 |
|
479 mSeekStartTimer->start(); |
|
480 } |
|
481 |
|
482 // ------------------------------------------------------------------------------------------------- |
|
483 // VideoPlaybackToolBar::handleFFButtonPressed() |
|
484 // ------------------------------------------------------------------------------------------------- |
|
485 // |
|
486 void VideoPlaybackToolBar::handleFFButtonPressed() |
|
487 { |
|
488 MPX_DEBUG(_L("VideoPlaybackToolBar::handleButtonPressed()")); |
|
489 |
|
490 mController->resetDisappearingTimers( ETimerCancel ); |
|
491 |
|
492 connect( mSeekStartTimer, SIGNAL( timeout() ), this, SLOT( ffPressing() ) ); |
|
493 |
|
494 if ( mSeekStartTimer->isActive() ) |
|
495 { |
|
496 mSeekStartTimer->stop(); |
|
497 } |
|
498 |
|
499 mSeekStartTimer->start(); |
|
500 } |
|
501 |
|
502 // ------------------------------------------------------------------------------------------------- |
|
503 // VideoPlaybackToolBar::updateWithFileDetails() |
|
504 // ------------------------------------------------------------------------------------------------- |
|
505 // |
|
506 void VideoPlaybackToolBar::updateWithFileDetails( |
|
507 VideoPlaybackViewFileDetails* details ) |
|
508 { |
|
509 MPX_DEBUG(_L("VideoPlaybackToolBar::updateWithFileDetails()")); |
|
510 |
|
511 if ( mController->isAttachOperation() ) |
|
512 { |
|
513 // |
|
514 // Show attach button |
|
515 // |
|
516 mButtonActions[E1stButton]->setIcon( *mButtonIcons[EAttachIcon] ); |
|
517 |
|
518 if ( mButtons.count() ) |
|
519 { |
|
520 disconnect( mButtons[E1stButton], SIGNAL( released() ), 0, 0 ); |
|
521 connect( mButtons[E1stButton], SIGNAL( released() ), |
|
522 mController, SLOT( attachVideo() ) ); |
|
523 } |
|
524 } |
|
525 else |
|
526 { |
|
527 if ( mController->viewMode() == EFullScreenView ) |
|
528 { |
|
529 // |
|
530 // Show aspect ratio button |
|
531 // |
|
532 aspectRatioChanged( mAspectRatio ); |
|
533 |
|
534 if ( ! details->mVideoEnabled || |
|
535 details->mVideoHeight <= 0 || |
|
536 details->mVideoWidth <= 0 || |
|
537 details->mTvOutConnected ) |
|
538 { |
|
539 // |
|
540 // dim 'aspect ratio' buttons |
|
541 // |
|
542 mButtonActions[E1stButton]->setEnabled( false ); |
|
543 } |
|
544 else |
|
545 { |
|
546 // |
|
547 // check if video clip has same aspect ratio as display window |
|
548 // |
|
549 TReal32 videoAspectRatio = (TReal32) details->mVideoWidth / (TReal32) details->mVideoHeight; |
|
550 bool enabled = ( mDisplayAspectRatio == videoAspectRatio )? false : true; |
|
551 |
|
552 // |
|
553 // enable or dim 'aspect ratio' buttons accordingly |
|
554 // |
|
555 mButtonActions[E1stButton]->setEnabled( enabled ); |
|
556 |
|
557 if ( mButtons.count() ) |
|
558 { |
|
559 disconnect( mButtons[E1stButton], SIGNAL( released() ), 0, 0 ); |
|
560 connect( mButtons[E1stButton], SIGNAL( released() ), |
|
561 this, SLOT( changeAspectRatio() ) ); |
|
562 } |
|
563 } |
|
564 } |
|
565 else if ( mController->viewMode() == EAudioOnlyView ) |
|
566 { |
|
567 // |
|
568 // Show share button |
|
569 // |
|
570 mButtonActions[E1stButton]->setIcon( *mButtonIcons[EShareIcon] ); |
|
571 |
|
572 if ( mController->fileDetails()->mPlaybackMode == EMPXVideoStreaming || |
|
573 mController->fileDetails()->mPlaybackMode == EMPXVideoLiveStreaming ) |
|
574 { |
|
575 // |
|
576 // dim 'share' button for streaming |
|
577 // |
|
578 mButtonActions[E1stButton]->setEnabled( false ); |
|
579 } |
|
580 else |
|
581 { |
|
582 // |
|
583 // enable 'share' button |
|
584 // |
|
585 mButtonActions[E1stButton]->setEnabled( true ); |
|
586 |
|
587 if ( mButtons.count() ) |
|
588 { |
|
589 disconnect( mButtons[E1stButton], SIGNAL( released() ), 0, 0 ); |
|
590 connect( mButtons[E1stButton], SIGNAL( released() ), |
|
591 mController, SLOT( sendVideo() ) ); |
|
592 } |
|
593 } |
|
594 } |
|
595 } |
|
596 |
|
597 // |
|
598 // for audio-only clips and tv-out, default view is audionOnlyView |
|
599 // therefore, dim details button |
|
600 // |
|
601 if ( ! details->mVideoEnabled || details->mTvOutConnected ) |
|
602 { |
|
603 mButtonActions[E5thButton]->setEnabled( false ); |
|
604 } |
|
605 else |
|
606 { |
|
607 mButtonActions[E5thButton]->setEnabled( true ); |
|
608 } |
|
609 |
|
610 if ( details->mSeekable && details->mPausableStream ) |
|
611 { |
|
612 mButtonActions[E2ndButton]->setEnabled( true ); |
|
613 mButtonActions[E4thButton]->setEnabled( true ); |
|
614 } |
|
615 else |
|
616 { |
|
617 mButtonActions[E2ndButton]->setEnabled( false ); |
|
618 mButtonActions[E4thButton]->setEnabled( false ); |
|
619 } |
|
620 |
|
621 // |
|
622 // The buttons 'Play' and 'Pause' are shared by the same 'E3rdButton' action. |
|
623 // The logic to enable or disable 'E3rdButton' will depend on the current playback state. |
|
624 // |
|
625 updateState( mController->state() ); |
|
626 |
|
627 // |
|
628 // toolbar creates button once it gets visible, so we don't know exact timing when toolbar |
|
629 // creates button, so start timer to get layout information once the toolbar gets visible. |
|
630 // This is needed since we don't use toolbar in proper way. |
|
631 // |
|
632 if ( ! mRetrieveButtonTimer && ! mButtons.count() ) |
|
633 { |
|
634 mRetrieveButtonTimer = new QTimer(); |
|
635 mRetrieveButtonTimer->setSingleShot( false ); |
|
636 mRetrieveButtonTimer->setInterval( KRetrieveButtonTimeOut ); |
|
637 connect( mRetrieveButtonTimer, SIGNAL( timeout() ), this, SLOT( retrieveButtons() ) ); |
|
638 |
|
639 mRetrieveButtonTimer->start(); |
|
640 } |
|
641 |
|
642 durationChanged( (qreal)mController->fileDetails()->mDuration / (qreal)KPbMilliMultiplier ); |
|
643 } |
|
644 |
|
645 // ------------------------------------------------------------------------------------------------- |
|
646 // VideoPlaybackToolBar::openDetailsView() |
|
647 // ------------------------------------------------------------------------------------------------- |
|
648 // |
|
649 void VideoPlaybackToolBar::openDetailsView() |
|
650 { |
|
651 MPX_ENTER_EXIT(_L("VideoPlaybackToolBar::openDetailsView()")); |
|
652 |
|
653 TPlaybackViewMode viewMode = mController->viewMode(); |
|
654 |
|
655 if ( viewMode == EFullScreenView ) |
|
656 { |
|
657 mController->changeViewMode( EDetailsView ); |
|
658 } |
|
659 } |
|
660 |
|
661 // ------------------------------------------------------------------------------------------------- |
|
662 // VideoPlaybackToolBar::positionChanged |
|
663 // ------------------------------------------------------------------------------------------------- |
|
664 // |
|
665 void VideoPlaybackToolBar::positionChanged( int position ) |
|
666 { |
|
667 MPX_DEBUG(_L("VideoPlaybackToolBar::positionChanged position = %d"), position ); |
|
668 |
|
669 mPosition = position; |
|
670 } |
|
671 |
|
672 // ------------------------------------------------------------------------------------------------- |
|
673 // VideoPlaybackToolBar::durationChanged |
|
674 // ------------------------------------------------------------------------------------------------- |
|
675 // |
|
676 void VideoPlaybackToolBar::durationChanged( int duration ) |
|
677 { |
|
678 MPX_DEBUG(_L("VideoPlaybackToolBar::durationChanged duration = %d"), duration ); |
|
679 |
|
680 mDuration = duration; |
|
681 } |
|
682 |
|
683 // ------------------------------------------------------------------------------------------------- |
|
684 // VideoPlaybackToolBar::setVisible |
|
685 // ------------------------------------------------------------------------------------------------- |
|
686 // |
|
687 void VideoPlaybackToolBar::setVisible( bool visible ) |
|
688 { |
|
689 MPX_DEBUG(_L("VideoPlaybackToolBar::setVisible visible = %d"), visible ); |
|
690 |
|
691 if ( visible ) |
|
692 { |
|
693 mController->view()->showItems( Hb::ToolBarItem ); |
|
694 } |
|
695 else |
|
696 { |
|
697 mController->view()->hideItems( Hb::ToolBarItem ); |
|
698 } |
|
699 } |
|
700 |
|
701 // ------------------------------------------------------------------------------------------------- |
|
702 // VideoPlaybackToolBar::retrieveButtons() |
|
703 // ------------------------------------------------------------------------------------------------- |
|
704 // |
|
705 void VideoPlaybackToolBar::retrieveButtons() |
|
706 { |
|
707 MPX_DEBUG(_L("VideoPlaybackToolBar::retrieveButtons()")); |
|
708 |
|
709 if ( mButtons.count() == 0 ) |
|
710 { |
|
711 QGraphicsLayout *layout = mToolBar->layout(); |
|
712 |
|
713 if ( layout ) |
|
714 { |
|
715 if ( mRetrieveButtonTimer ) |
|
716 { |
|
717 disconnect( mRetrieveButtonTimer, SIGNAL( timeout() ), this, SLOT( retrieveButtons() ) ); |
|
718 if ( mRetrieveButtonTimer->isActive() ) |
|
719 { |
|
720 mRetrieveButtonTimer->stop(); |
|
721 } |
|
722 } |
|
723 |
|
724 for ( int i = 0 ; i < layout->count() ; i++ ) |
|
725 { |
|
726 mButtons.append( dynamic_cast<HbToolButton*>( layout->itemAt( i ) ) ); |
|
727 } |
|
728 |
|
729 // |
|
730 // Connect signal and slots |
|
731 // |
|
732 connect( mButtons[E1stButton], SIGNAL( pressed() ), this, SLOT( handleButtonPressed() ) ); |
|
733 |
|
734 connect( mButtons[E2ndButton], SIGNAL( pressed() ), this, SLOT( handleRWButtonPressed() ) ); |
|
735 connect( mButtons[E2ndButton], SIGNAL( released() ), this, SLOT( rwReleased() ) ); |
|
736 |
|
737 connect( mButtons[E3rdButton], SIGNAL( pressed() ), this, SLOT( handleButtonPressed() ) ); |
|
738 connect( mButtons[E3rdButton], SIGNAL( released() ), this, SLOT( playPause() ) ); |
|
739 |
|
740 connect( mButtons[E4thButton], SIGNAL( pressed() ), this, SLOT( handleFFButtonPressed() ) ); |
|
741 connect( mButtons[E4thButton], SIGNAL( released() ), this, SLOT( ffReleased() ) ); |
|
742 |
|
743 connect( mButtons[E5thButton], SIGNAL( pressed() ), this, SLOT( handleButtonPressed() ) ); |
|
744 connect( mButtons[E5thButton], SIGNAL( released() ), this, SLOT( openDetailsView() ) ); |
|
745 |
|
746 if ( mController->isAttachOperation() ) |
|
747 { |
|
748 connect( mButtons[E1stButton], SIGNAL( released() ), |
|
749 mController, SLOT( attachVideo() ) ); |
|
750 } |
|
751 else |
|
752 { |
|
753 if ( mController->viewMode() == EFullScreenView ) |
|
754 { |
|
755 connect( mButtons[E1stButton], SIGNAL( released() ), |
|
756 this, SLOT( changeAspectRatio() ) ); |
|
757 } |
|
758 else if ( mController->viewMode() == EAudioOnlyView ) |
|
759 { |
|
760 connect( mButtons[E1stButton], SIGNAL( released() ), |
|
761 mController, SLOT( sendVideo() ) ); |
|
762 } |
|
763 } |
|
764 } |
|
765 } |
|
766 } |
|
767 |
|
768 //End of file |