34
|
1 |
/*
|
|
2 |
* Copyright (c) 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 QMPXVideoPlaybackButtonBar
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// Version : %version: da1mmcf#20 %
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
#include <hbframeitem.h>
|
|
23 |
#include <hbpushbutton.h>
|
|
24 |
#include <hbframedrawer.h>
|
|
25 |
|
|
26 |
#include "mpxvideo_debug.h"
|
|
27 |
#include "mpxvideoplaybackbuttonbar.h"
|
|
28 |
#include "mpxvideoplaybackviewfiledetails.h"
|
|
29 |
#include "mpxcommonvideoplaybackview.hrh"
|
|
30 |
#include "mpxvideoplaybackdocumentloader.h"
|
|
31 |
#include "mpxvideoplaybackcontrolscontroller.h"
|
|
32 |
|
|
33 |
|
|
34 |
// -------------------------------------------------------------------------------------------------
|
|
35 |
// QMPXVideoPlaybackButtonBar::QMPXVideoPlaybackButtonBar()
|
|
36 |
// -------------------------------------------------------------------------------------------------
|
|
37 |
//
|
|
38 |
QMPXVideoPlaybackButtonBar::QMPXVideoPlaybackButtonBar(
|
|
39 |
QMPXVideoPlaybackControlsController* controller )
|
|
40 |
: mController( controller )
|
|
41 |
, mInitialized( false )
|
|
42 |
, mFrameItem( NULL )
|
|
43 |
{
|
|
44 |
MPX_ENTER_EXIT(_L("QMPXVideoPlaybackButtonBar::QMPXVideoPlaybackButtonBar"));
|
|
45 |
}
|
|
46 |
|
|
47 |
// -------------------------------------------------------------------------------------------------
|
|
48 |
// QMPXVideoPlaybackButtonBar::~QMPXVideoPlaybackButtonBar()
|
|
49 |
// -------------------------------------------------------------------------------------------------
|
|
50 |
//
|
|
51 |
QMPXVideoPlaybackButtonBar::~QMPXVideoPlaybackButtonBar()
|
|
52 |
{
|
|
53 |
MPX_DEBUG(_L("QMPXVideoPlaybackButtonBar::~QMPXVideoPlaybackButtonBar()"));
|
|
54 |
}
|
|
55 |
|
|
56 |
// -------------------------------------------------------------------------------------------------
|
|
57 |
// QMPXVideoPlaybackButtonBar::initialize()
|
|
58 |
// -------------------------------------------------------------------------------------------------
|
|
59 |
//
|
|
60 |
void QMPXVideoPlaybackButtonBar::initialize()
|
|
61 |
{
|
|
62 |
MPX_ENTER_EXIT(_L("QMPXVideoPlaybackButtonBar::initialize()"));
|
|
63 |
|
|
64 |
QMPXVideoPlaybackDocumentLoader *loader = mController->layoutLoader();
|
|
65 |
|
|
66 |
//
|
|
67 |
// Don't need to initialize buttons once it gets initialized
|
|
68 |
//
|
|
69 |
if ( loader && ! mInitialized )
|
|
70 |
{
|
|
71 |
mInitialized = true;
|
|
72 |
|
|
73 |
//
|
|
74 |
// RW button
|
|
75 |
//
|
|
76 |
QGraphicsWidget *widget = loader->findWidget( QString( "rwButton" ) );
|
|
77 |
HbPushButton *rwButton = qobject_cast<HbPushButton*>( widget );
|
|
78 |
connect( rwButton, SIGNAL( pressed() ), this, SLOT( startRWSeeking() ) );
|
|
79 |
connect( rwButton, SIGNAL( released() ), this, SLOT( endSeeking() ) );
|
|
80 |
mButtons.append( rwButton );
|
|
81 |
|
|
82 |
//
|
|
83 |
// Play button
|
|
84 |
//
|
|
85 |
widget = loader->findWidget( QString( "playButton" ) );
|
|
86 |
HbPushButton *playButton = qobject_cast<HbPushButton*>( widget );
|
|
87 |
connect( playButton, SIGNAL( pressed() ), this, SLOT( handleButtonPressed() ) );
|
|
88 |
connect( playButton, SIGNAL( released() ), this, SLOT( play() ) );
|
|
89 |
|
|
90 |
mButtons.append( playButton );
|
|
91 |
|
|
92 |
//
|
|
93 |
// Pause button
|
|
94 |
//
|
|
95 |
widget = loader->findWidget( QString( "pauseButton" ) );
|
|
96 |
HbPushButton *pauseButton = qobject_cast<HbPushButton*>( widget );
|
|
97 |
connect( pauseButton, SIGNAL( pressed() ), this, SLOT( handleButtonPressed() ) );
|
|
98 |
connect( pauseButton, SIGNAL( released() ), this, SLOT( pause() ) );
|
|
99 |
|
|
100 |
mButtons.append( pauseButton );
|
|
101 |
|
|
102 |
//
|
|
103 |
// FW button
|
|
104 |
//
|
|
105 |
widget = loader->findWidget( QString( "ffButton" ) );
|
|
106 |
HbPushButton *ffButton = qobject_cast<HbPushButton*>( widget );
|
|
107 |
connect( ffButton, SIGNAL( pressed() ), this, SLOT( startFFSeeking() ) );
|
|
108 |
connect( ffButton, SIGNAL( released() ), this, SLOT( endSeeking() ) );
|
|
109 |
mButtons.append( ffButton );
|
|
110 |
|
|
111 |
//
|
|
112 |
// Aspect ratio button
|
|
113 |
//
|
|
114 |
widget = loader->findWidget( QString( "naturalButton" ) );
|
|
115 |
HbPushButton *naturalButton = qobject_cast<HbPushButton*>( widget );
|
|
116 |
connect( naturalButton, SIGNAL( pressed() ), this, SLOT( handleButtonPressed() ) );
|
|
117 |
connect( naturalButton, SIGNAL( released() ), this, SLOT( changeAspectRatio() ) );
|
|
118 |
mButtons.append( naturalButton );
|
|
119 |
|
|
120 |
widget = loader->findWidget( QString( "stretchButton" ) );
|
|
121 |
HbPushButton *stretchButton = qobject_cast<HbPushButton*>( widget );
|
|
122 |
connect( stretchButton, SIGNAL( pressed() ), this, SLOT( handleButtonPressed() ) );
|
|
123 |
connect( stretchButton, SIGNAL( released() ), this, SLOT( changeAspectRatio() ) );
|
|
124 |
mButtons.append( stretchButton );
|
|
125 |
|
|
126 |
widget = loader->findWidget( QString( "zoomButton" ) );
|
|
127 |
HbPushButton *zoomButton = qobject_cast<HbPushButton*>( widget );
|
|
128 |
connect( zoomButton, SIGNAL( pressed() ), this, SLOT( handleButtonPressed() ) );
|
|
129 |
connect( zoomButton, SIGNAL( released() ), this, SLOT( changeAspectRatio() ) );
|
|
130 |
mButtons.append( zoomButton );
|
|
131 |
|
|
132 |
//
|
|
133 |
// Details button
|
|
134 |
//
|
|
135 |
widget = loader->findWidget( QString( "detailsButton" ) );
|
|
136 |
HbPushButton *detailsButton = qobject_cast<HbPushButton*>( widget );
|
|
137 |
connect( detailsButton, SIGNAL( pressed() ), this, SLOT( handleButtonPressed() ) );
|
|
138 |
connect( detailsButton, SIGNAL( released() ), this, SLOT( openDetailsView() ) );
|
|
139 |
mButtons.append( detailsButton );
|
|
140 |
|
|
141 |
for ( int i = 0 ; i < EMPXButtonCount ; i++ )
|
|
142 |
{
|
|
143 |
mButtons[i]->setFlag( QGraphicsItem::ItemIsFocusable, false );
|
|
144 |
}
|
|
145 |
|
|
146 |
//
|
|
147 |
// Set framedrawer for semi transparent background
|
|
148 |
//
|
|
149 |
mFrameItem = new HbFrameItem ( this );
|
|
150 |
mFrameItem->setGeometry( boundingRect() );
|
|
151 |
mFrameItem->frameDrawer().setFrameType( HbFrameDrawer::OnePiece );
|
|
152 |
mFrameItem->frameDrawer().setFillWholeRect( true );
|
|
153 |
mFrameItem->frameDrawer().setFrameGraphicsName( "qtg_fr_status_trans_normal_c" );
|
|
154 |
mFrameItem->setVisible( false );
|
|
155 |
}
|
|
156 |
}
|
|
157 |
|
|
158 |
// -------------------------------------------------------------------------------------------------
|
|
159 |
// QMPXVideoPlaybackButtonBar::play()
|
|
160 |
// -------------------------------------------------------------------------------------------------
|
|
161 |
//
|
|
162 |
void QMPXVideoPlaybackButtonBar::play()
|
|
163 |
{
|
|
164 |
MPX_DEBUG(_L("QMPXVideoPlaybackButtonBar::play()"));
|
|
165 |
|
|
166 |
mController->resetDisappearingTimers( EMPXTimerReset );
|
|
167 |
mController->handleCommand( EMPXPbvCmdPlay );
|
|
168 |
}
|
|
169 |
|
|
170 |
// -------------------------------------------------------------------------------------------------
|
|
171 |
// QMPXVideoPlaybackButtonBar::startFFSeeking()
|
|
172 |
// -------------------------------------------------------------------------------------------------
|
|
173 |
//
|
|
174 |
void QMPXVideoPlaybackButtonBar::startFFSeeking()
|
|
175 |
{
|
|
176 |
MPX_DEBUG(_L("QMPXVideoPlaybackButtonBar::startFFSeeking()"));
|
|
177 |
|
|
178 |
mButtons[EMPXButtonFF]->setSelected( true );
|
|
179 |
|
|
180 |
mController->resetDisappearingTimers( EMPXTimerCancel );
|
|
181 |
mController->handleCommand( EMPXPbvCmdSeekForward );
|
|
182 |
}
|
|
183 |
|
|
184 |
// -------------------------------------------------------------------------------------------------
|
|
185 |
// QMPXVideoPlaybackButtonBar::startRWSeeking()
|
|
186 |
// -------------------------------------------------------------------------------------------------
|
|
187 |
//
|
|
188 |
void QMPXVideoPlaybackButtonBar::startRWSeeking()
|
|
189 |
{
|
|
190 |
MPX_DEBUG(_L("QMPXVideoPlaybackButtonBar::startRWSeeking()"));
|
|
191 |
|
|
192 |
mButtons[EMPXButtonRW]->setSelected( true );
|
|
193 |
|
|
194 |
mController->resetDisappearingTimers( EMPXTimerCancel );
|
|
195 |
mController->handleCommand( EMPXPbvCmdSeekBackward );
|
|
196 |
}
|
|
197 |
|
|
198 |
// -------------------------------------------------------------------------------------------------
|
|
199 |
// QMPXVideoPlaybackButtonBar::endSeeking()
|
|
200 |
// -------------------------------------------------------------------------------------------------
|
|
201 |
//
|
|
202 |
void QMPXVideoPlaybackButtonBar::endSeeking()
|
|
203 |
{
|
|
204 |
MPX_DEBUG(_L("QMPXVideoPlaybackButtonBar::endSeeking()"));
|
|
205 |
|
|
206 |
mButtons[EMPXButtonFF]->setSelected( false );
|
|
207 |
mButtons[EMPXButtonRW]->setSelected( false );
|
|
208 |
|
|
209 |
mController->resetDisappearingTimers( EMPXTimerReset );
|
|
210 |
mController->handleCommand( EMPXPbvCmdEndSeek );
|
|
211 |
}
|
|
212 |
|
|
213 |
// -------------------------------------------------------------------------------------------------
|
|
214 |
// QMPXVideoPlaybackButtonBar::pause()
|
|
215 |
// -------------------------------------------------------------------------------------------------
|
|
216 |
//
|
|
217 |
void QMPXVideoPlaybackButtonBar::pause()
|
|
218 |
{
|
|
219 |
MPX_DEBUG(_L("QMPXVideoPlaybackButtonBar::pause()"));
|
|
220 |
|
|
221 |
mController->resetDisappearingTimers( EMPXTimerReset );
|
|
222 |
mController->handleCommand( EMPXPbvCmdPause );
|
|
223 |
}
|
|
224 |
|
|
225 |
// -------------------------------------------------------------------------------------------------
|
|
226 |
// QMPXVideoPlaybackButtonBar::changeAspectRatio()
|
|
227 |
// -------------------------------------------------------------------------------------------------
|
|
228 |
//
|
|
229 |
void QMPXVideoPlaybackButtonBar::changeAspectRatio()
|
|
230 |
{
|
|
231 |
MPX_DEBUG(_L("QMPXVideoPlaybackButtonBar::changeAspectRatio()"));
|
|
232 |
|
|
233 |
mController->resetDisappearingTimers( EMPXTimerReset );
|
|
234 |
|
|
235 |
TMPXVideoPlaybackViewCommandIds cmd = EMPXPbvCmdNaturalAspectRatio;
|
|
236 |
|
|
237 |
if ( mButtons[EMPXButtonStretch]->isVisible() )
|
|
238 |
{
|
|
239 |
cmd = EMPXPbvCmdStretchAspectRatio;
|
|
240 |
}
|
|
241 |
else if ( mButtons[EMPXButtonZoom]->isVisible() )
|
|
242 |
{
|
|
243 |
cmd = EMPXPbvCmdZoomAspectRatio;
|
|
244 |
}
|
|
245 |
|
|
246 |
mController->handleCommand( cmd );
|
|
247 |
}
|
|
248 |
|
|
249 |
// -------------------------------------------------------------------------------------------------
|
|
250 |
// QMPXVideoPlaybackButtonBar::updateState()
|
|
251 |
// -------------------------------------------------------------------------------------------------
|
|
252 |
//
|
|
253 |
void QMPXVideoPlaybackButtonBar::updateState( TMPXPlaybackState state )
|
|
254 |
{
|
|
255 |
MPX_DEBUG(_L("QMPXVideoPlaybackButtonBar::updateState() state = %d"), state );
|
|
256 |
|
|
257 |
switch ( state )
|
|
258 |
{
|
|
259 |
case EPbStatePlaying:
|
|
260 |
{
|
|
261 |
setEnabled( true );
|
|
262 |
|
|
263 |
mButtons[EMPXButtonPlay]->setVisible( false );
|
|
264 |
mButtons[EMPXButtonPause]->setVisible( true );
|
|
265 |
break;
|
|
266 |
}
|
|
267 |
case EPbStatePaused:
|
|
268 |
{
|
|
269 |
setEnabled( true );
|
|
270 |
|
|
271 |
mButtons[EMPXButtonPause]->setVisible( false );
|
|
272 |
mButtons[EMPXButtonPlay]->setVisible( true );
|
|
273 |
break;
|
|
274 |
}
|
|
275 |
case EPbStateNotInitialised:
|
|
276 |
case EPbStateInitialising:
|
|
277 |
case EPbStateBuffering:
|
|
278 |
{
|
|
279 |
setEnabled( false );
|
|
280 |
|
|
281 |
break;
|
|
282 |
}
|
|
283 |
}
|
|
284 |
}
|
|
285 |
|
|
286 |
// -------------------------------------------------------------------------------------------------
|
|
287 |
// QMPXVideoPlaybackButtonBar::aspectRatioChanged()
|
|
288 |
// -------------------------------------------------------------------------------------------------
|
|
289 |
//
|
|
290 |
void QMPXVideoPlaybackButtonBar::aspectRatioChanged( int aspectRatio )
|
|
291 |
{
|
|
292 |
MPX_DEBUG(_L("QMPXVideoPlaybackButtonBar::aspectRatioChanged() aspectRatio = %d"), aspectRatio );
|
|
293 |
|
|
294 |
switch( aspectRatio )
|
|
295 |
{
|
|
296 |
case EMMFNatural:
|
|
297 |
{
|
|
298 |
mButtons[EMPXButtonNatural]->setVisible( false );
|
|
299 |
mButtons[EMPXButtonStretch]->setVisible( true );
|
|
300 |
mButtons[EMPXButtonZoom]->setVisible( false );
|
|
301 |
break;
|
|
302 |
}
|
|
303 |
case EMMFStretch:
|
|
304 |
{
|
|
305 |
mButtons[EMPXButtonNatural]->setVisible( false );
|
|
306 |
mButtons[EMPXButtonStretch]->setVisible( false );
|
|
307 |
mButtons[EMPXButtonZoom]->setVisible( true );
|
|
308 |
break;
|
|
309 |
}
|
|
310 |
default:
|
|
311 |
{
|
|
312 |
mButtons[EMPXButtonNatural]->setVisible( true );
|
|
313 |
mButtons[EMPXButtonStretch]->setVisible( false );
|
|
314 |
mButtons[EMPXButtonZoom]->setVisible( false );
|
|
315 |
break;
|
|
316 |
}
|
|
317 |
}
|
|
318 |
}
|
|
319 |
|
|
320 |
// -------------------------------------------------------------------------------------------------
|
|
321 |
// QMPXVideoPlaybackButtonBar::handleButtonPressed()
|
|
322 |
// -------------------------------------------------------------------------------------------------
|
|
323 |
//
|
|
324 |
void QMPXVideoPlaybackButtonBar::handleButtonPressed()
|
|
325 |
{
|
|
326 |
MPX_DEBUG(_L("QMPXVideoPlaybackButtonBar::handleButtonPressed()"));
|
|
327 |
|
|
328 |
mController->resetDisappearingTimers( EMPXTimerCancel );
|
|
329 |
}
|
|
330 |
|
|
331 |
// -------------------------------------------------------------------------------------------------
|
|
332 |
// QMPXVideoPlaybackButtonBar::updateWithFileDetails()
|
|
333 |
// -------------------------------------------------------------------------------------------------
|
|
334 |
//
|
|
335 |
void QMPXVideoPlaybackButtonBar::updateWithFileDetails(
|
|
336 |
QMPXVideoPlaybackViewFileDetails* details )
|
|
337 |
{
|
|
338 |
MPX_DEBUG(_L("QMPXVideoPlaybackButtonBar::updateWithFileDetails()"));
|
|
339 |
|
|
340 |
if ( ! details->mVideoEnabled ||
|
|
341 |
details->mVideoHeight <= 0 ||
|
|
342 |
details->mVideoWidth <= 0 ||
|
|
343 |
details->mTvOutConnected )
|
|
344 |
{
|
|
345 |
mButtons[EMPXButtonNatural]->setEnabled( false );
|
|
346 |
mButtons[EMPXButtonStretch]->setEnabled( false );
|
|
347 |
mButtons[EMPXButtonZoom]->setEnabled( false );
|
|
348 |
}
|
|
349 |
else
|
|
350 |
{
|
|
351 |
mButtons[EMPXButtonNatural]->setEnabled( true );
|
|
352 |
mButtons[EMPXButtonStretch]->setEnabled( true );
|
|
353 |
mButtons[EMPXButtonZoom]->setEnabled( true );
|
|
354 |
}
|
|
355 |
|
|
356 |
//
|
|
357 |
// for audio-only clips and tv-out, default view is audionOnlyView
|
|
358 |
// therefore, dim details button
|
|
359 |
//
|
|
360 |
if ( ! details->mVideoEnabled || details->mTvOutConnected )
|
|
361 |
{
|
|
362 |
mButtons[EMPXButtonDetails]->setEnabled( false );
|
|
363 |
}
|
|
364 |
else
|
|
365 |
{
|
|
366 |
mButtons[EMPXButtonDetails]->setEnabled( true );
|
|
367 |
}
|
|
368 |
|
|
369 |
if ( ! details->mSeekable || ( details->mTvOutConnected && ! details->mTvOutPlayAllowed ) )
|
|
370 |
{
|
|
371 |
mButtons[EMPXButtonRW]->setEnabled( false );
|
|
372 |
mButtons[EMPXButtonFF]->setEnabled( false );
|
|
373 |
}
|
|
374 |
else
|
|
375 |
{
|
|
376 |
mButtons[EMPXButtonRW]->setEnabled( true );
|
|
377 |
mButtons[EMPXButtonFF]->setEnabled( true );
|
|
378 |
}
|
|
379 |
|
|
380 |
if ( ! details->mPausableStream || ( details->mTvOutConnected && ! details->mTvOutPlayAllowed ) )
|
|
381 |
{
|
|
382 |
mButtons[EMPXButtonPause]->setEnabled( false );
|
|
383 |
}
|
|
384 |
else
|
|
385 |
{
|
|
386 |
mButtons[EMPXButtonPause]->setEnabled( true );
|
|
387 |
}
|
|
388 |
|
|
389 |
if ( details->mTvOutConnected && ! details->mTvOutPlayAllowed )
|
|
390 |
{
|
|
391 |
mButtons[EMPXButtonPlay]->setEnabled( false );
|
|
392 |
}
|
|
393 |
else
|
|
394 |
{
|
|
395 |
mButtons[EMPXButtonPlay]->setEnabled( true );
|
|
396 |
}
|
|
397 |
|
|
398 |
//
|
|
399 |
// If it is audio only view, show the background of button
|
|
400 |
//
|
|
401 |
bool backgrondVisible = false;
|
|
402 |
|
|
403 |
if ( mController->viewMode() == EAudioOnlyView )
|
|
404 |
{
|
|
405 |
backgrondVisible = true;
|
|
406 |
}
|
|
407 |
|
|
408 |
for ( int i = 0 ; i < EMPXButtonCount ; i++ )
|
|
409 |
{
|
|
410 |
QGraphicsItem* widget = mButtons[i]->primitive( HbStyle::P_PushButton_background );
|
|
411 |
widget->setVisible( backgrondVisible );
|
|
412 |
}
|
|
413 |
|
|
414 |
mFrameItem->setVisible( ( mController->viewMode() == EFullScreenView )? ETrue:EFalse );
|
|
415 |
}
|
|
416 |
|
|
417 |
// -------------------------------------------------------------------------------------------------
|
|
418 |
// QMPXVideoPlaybackButtonBar::openDetailsView()
|
|
419 |
// -------------------------------------------------------------------------------------------------
|
|
420 |
//
|
|
421 |
void QMPXVideoPlaybackButtonBar::openDetailsView()
|
|
422 |
{
|
|
423 |
MPX_ENTER_EXIT(_L("QMPXVideoPlaybackButtonBar::openDetailsView()"));
|
|
424 |
|
|
425 |
TPlaybackViewMode viewMode = mController->viewMode();
|
|
426 |
|
|
427 |
if ( viewMode == EFullScreenView )
|
|
428 |
{
|
|
429 |
mController->changeViewMode( EDetailsView );
|
|
430 |
}
|
|
431 |
}
|
|
432 |
|
|
433 |
//End of file
|