-rw-r--r-- | core/multimedia/opieplayer/videowidget.cpp | 171 | ||||
-rw-r--r-- | core/multimedia/opieplayer/videowidget.h | 14 |
2 files changed, 119 insertions, 66 deletions
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp index 1b38206..6ed0108 100644 --- a/core/multimedia/opieplayer/videowidget.cpp +++ b/core/multimedia/opieplayer/videowidget.cpp | |||
@@ -56,7 +56,7 @@ struct MediaButton { | |||
56 | // Layout information for the videoButtons (and if it is a toggle button or not) | 56 | // Layout information for the videoButtons (and if it is a toggle button or not) |
57 | MediaButton videoButtons[] = { | 57 | MediaButton videoButtons[] = { |
58 | { FALSE, FALSE, FALSE }, // stop | 58 | { FALSE, FALSE, FALSE }, // stop |
59 | { TRUE, FALSE, FALSE }, // play | 59 | { FALSE, FALSE, FALSE }, // play |
60 | { FALSE, FALSE, FALSE }, // previous | 60 | { FALSE, FALSE, FALSE }, // previous |
61 | { FALSE, FALSE, FALSE }, // next | 61 | { FALSE, FALSE, FALSE }, // next |
62 | { FALSE, FALSE, FALSE }, // volUp | 62 | { FALSE, FALSE, FALSE }, // volUp |
@@ -144,14 +144,14 @@ VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | |||
144 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 144 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
145 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 145 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
146 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 146 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
147 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 147 | // connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
148 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 148 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
149 | 149 | ||
150 | // Intialise state | 150 | // Intialise state |
151 | setLength( mediaPlayerState->length() ); | 151 | setLength( mediaPlayerState->length() ); |
152 | setPosition( mediaPlayerState->position() ); | 152 | setPosition( mediaPlayerState->position() ); |
153 | setFullscreen( mediaPlayerState->fullscreen() ); | 153 | setFullscreen( mediaPlayerState->fullscreen() ); |
154 | setPaused( mediaPlayerState->paused() ); | 154 | // setPaused( mediaPlayerState->paused() ); |
155 | setPlaying( mediaPlayerState->playing() ); | 155 | setPlaying( mediaPlayerState->playing() ); |
156 | } | 156 | } |
157 | 157 | ||
@@ -319,11 +319,8 @@ void VideoWidget::paintButton( QPainter *p, int i ) { | |||
319 | 319 | ||
320 | 320 | ||
321 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 321 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
322 | 322 | for ( int i = 0; i < numVButtons; i++ ) { | |
323 | for ( int i = 0; i < numVButtons; i++ ) | 323 | if ( event->state() == QMouseEvent::LeftButton ) { |
324 | { | ||
325 | if ( event->state() == QMouseEvent::LeftButton ) | ||
326 | { | ||
327 | // The test to see if the mouse click is inside the button or not | 324 | // The test to see if the mouse click is inside the button or not |
328 | int x = event->pos().x() - xoff; | 325 | int x = event->pos().x() - xoff; |
329 | int y = event->pos().y() - yoff; | 326 | int y = event->pos().y() - yoff; |
@@ -332,11 +329,84 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
332 | && y < imgButtonMask->height() | 329 | && y < imgButtonMask->height() |
333 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | 330 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); |
334 | 331 | ||
335 | if ( isOnButton && !videoButtons[i].isHeld ) | 332 | if ( isOnButton && !videoButtons[i].isHeld ) { |
336 | { | ||
337 | videoButtons[i].isHeld = TRUE; | 333 | videoButtons[i].isHeld = TRUE; |
338 | toggleButton(i); | 334 | toggleButton(i); |
339 | 335 | ||
336 | switch (i) { | ||
337 | case VideoVolUp: | ||
338 | emit moreClicked(); | ||
339 | return; | ||
340 | case VideoVolDown: | ||
341 | emit lessClicked(); | ||
342 | return; | ||
343 | } | ||
344 | } else if ( !isOnButton && videoButtons[i].isHeld ) { | ||
345 | videoButtons[i].isHeld = FALSE; | ||
346 | toggleButton(i); | ||
347 | } | ||
348 | } else { | ||
349 | |||
350 | if ( videoButtons[i].isHeld ) { | ||
351 | videoButtons[i].isHeld = FALSE; | ||
352 | if ( !videoButtons[i].isToggle ) { | ||
353 | setToggleButton( i, FALSE ); | ||
354 | } | ||
355 | |||
356 | switch(i) { | ||
357 | |||
358 | case VideoPlay: { | ||
359 | qDebug("play"); | ||
360 | if( !mediaPlayerState->playing()) { | ||
361 | mediaPlayerState->setPlaying( true); | ||
362 | setToggleButton( i-1, false ); | ||
363 | setToggleButton( i, false ); | ||
364 | return; | ||
365 | } | ||
366 | if( mediaPlayerState->isPaused ) { | ||
367 | qDebug("isPaused"); | ||
368 | setToggleButton( i, FALSE ); | ||
369 | mediaPlayerState->setPaused( FALSE ); | ||
370 | return; | ||
371 | } else if( !mediaPlayerState->isPaused ) { | ||
372 | qDebug("is not paused"); | ||
373 | setToggleButton( i, TRUE ); | ||
374 | mediaPlayerState->setPaused( TRUE ); | ||
375 | return; | ||
376 | } else { | ||
377 | return; | ||
378 | } | ||
379 | } | ||
380 | |||
381 | case VideoStop: qDebug("stop"); mediaPlayerState->setPlaying( FALSE ); setToggleButton( i+1, true); setToggleButton( i, true ); return; | ||
382 | case VideoNext: mediaPlayerState->setNext(); return; | ||
383 | case VideoPrevious: mediaPlayerState->setPrev(); return; | ||
384 | case VideoVolUp: emit moreReleased(); return; | ||
385 | case VideoVolDown: emit lessReleased(); return; | ||
386 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | ||
387 | } | ||
388 | } | ||
389 | } | ||
390 | } | ||
391 | |||
392 | // for ( int i = 0; i < numVButtons; i++ ) | ||
393 | // { | ||
394 | // if ( event->state() == QMouseEvent::LeftButton ) | ||
395 | // { | ||
396 | // // The test to see if the mouse click is inside the button or not | ||
397 | // int x = event->pos().x() - xoff; | ||
398 | // int y = event->pos().y() - yoff; | ||
399 | |||
400 | // bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() | ||
401 | // && y < imgButtonMask->height() | ||
402 | // && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | ||
403 | |||
404 | // if ( isOnButton && !videoButtons[i].isHeld ) | ||
405 | // { | ||
406 | // qDebug("key %d", i); | ||
407 | |||
408 | // videoButtons[i].isHeld = TRUE; | ||
409 | // toggleButton(i); | ||
340 | // switch (i) { | 410 | // switch (i) { |
341 | // case VideoVolUp: | 411 | // case VideoVolUp: |
342 | // emit moreClicked(); | 412 | // emit moreClicked(); |
@@ -345,65 +415,51 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
345 | // emit lessClicked(); | 415 | // emit lessClicked(); |
346 | // return; | 416 | // return; |
347 | // } | 417 | // } |
348 | } | 418 | // } else if ( !isOnButton && videoButtons[i].isHeld ) { |
349 | else if ( !isOnButton && videoButtons[i].isHeld ) | 419 | // videoButtons[i].isHeld = FALSE; |
350 | { | 420 | // toggleButton(i); |
351 | videoButtons[i].isHeld = FALSE; | 421 | // } |
352 | toggleButton(i); | ||
353 | } | ||
354 | } | ||
355 | else | ||
356 | { | ||
357 | 422 | ||
358 | if ( videoButtons[i].isHeld ) | 423 | |
359 | { | 424 | // } else { |
360 | videoButtons[i].isHeld = FALSE; | 425 | |
361 | if ( !videoButtons[i].isToggle ) | 426 | // if ( videoButtons[i].isHeld ) |
362 | { | ||
363 | setToggleButton( i, FALSE ); | ||
364 | } | ||
365 | qDebug("key %d", i); | ||
366 | switch(i) | ||
367 | { | ||
368 | // case VideoPlay: | ||
369 | // { | 427 | // { |
370 | // if( mediaPlayerState->isPaused ) | 428 | // videoButtons[i].isHeld = FALSE; |
429 | // if ( !videoButtons[i].isToggle ) { | ||
430 | // setToggleButton( i, FALSE ); | ||
431 | // } | ||
432 | // qDebug("key %d", i); | ||
433 | // switch(i) { | ||
434 | // case VideoPlay: | ||
371 | // { | 435 | // { |
436 | // if( mediaPlayerState->isPaused ) { | ||
372 | // setToggleButton( i, FALSE ); | 437 | // setToggleButton( i, FALSE ); |
373 | // mediaPlayerState->setPaused( FALSE ); | 438 | // mediaPlayerState->setPaused( FALSE ); |
374 | // return; | 439 | // return; |
375 | // } | 440 | // } |
376 | // else if( !mediaPlayerState->isPaused ) | 441 | // else if( !mediaPlayerState->isPaused ) { |
377 | // { | ||
378 | // setToggleButton( i, TRUE ); | 442 | // setToggleButton( i, TRUE ); |
379 | // mediaPlayerState->setPaused( TRUE ); | 443 | // mediaPlayerState->setPaused( TRUE ); |
380 | // return; | 444 | // return; |
381 | // } | 445 | // } else { |
382 | // else | ||
383 | // { | ||
384 | // return; | 446 | // return; |
385 | // } | 447 | // } |
386 | // } | 448 | // } |
387 | 449 | ||
388 | case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; | ||
389 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; | ||
390 | // case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; | ||
391 | case VideoNext: mediaPlayerState->setNext(); return; | ||
392 | case VideoPrevious: mediaPlayerState->setPrev(); return; | ||
393 | // case VideoPlayList: mediaPlayerState->setList(); return; | ||
394 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | ||
395 | |||
396 | // case VideoStop: mediaPlayerState->setPlaying( FALSE ); return; | 450 | // case VideoStop: mediaPlayerState->setPlaying( FALSE ); return; |
397 | // case VideoNext: if(playList->whichList() ==0) mediaPlayerState->setNext(); return; | 451 | // // case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; |
398 | // case VideoPrevious: if(playList->whichList() ==0) mediaPlayerState->setPrev(); return; | 452 | // // case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; |
453 | // case VideoNext: mediaPlayerState->setNext(); return; | ||
454 | // case VideoPrevious: mediaPlayerState->setPrev(); return; | ||
399 | // case VideoVolUp: emit moreReleased(); return; | 455 | // case VideoVolUp: emit moreReleased(); return; |
400 | // case VideoVolDown: emit lessReleased(); return; | 456 | // case VideoVolDown: emit lessReleased(); return; |
457 | // // case VideoPlayList: mediaPlayerState->setList(); return; | ||
401 | // case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | 458 | // case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; |
402 | } | 459 | // } |
403 | } | 460 | // } |
404 | } | 461 | // } |
405 | } | 462 | // } |
406 | |||
407 | 463 | ||
408 | 464 | ||
409 | 465 | ||
@@ -432,15 +488,6 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
432 | // } | 488 | // } |
433 | // } | 489 | // } |
434 | 490 | ||
435 | // switch (i) { | ||
436 | // case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; | ||
437 | // case VideoStop: mediaPlayerState->setPlaying(FALSE); return; | ||
438 | // case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; | ||
439 | // case VideoNext: mediaPlayerState->setNext(); return; | ||
440 | // case VideoPrevious: mediaPlayerState->setPrev(); return; | ||
441 | // case VideoPlayList: mediaPlayerState->setList(); return; | ||
442 | // case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | ||
443 | // } | ||
444 | 491 | ||
445 | // } | 492 | // } |
446 | } | 493 | } |
@@ -456,9 +503,9 @@ void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | |||
456 | { | 503 | { |
457 | mediaPlayerState->setFullscreen( FALSE ); | 504 | mediaPlayerState->setFullscreen( FALSE ); |
458 | makeVisible(); | 505 | makeVisible(); |
459 | |||
460 | mouseMoveEvent( event ); | ||
461 | } | 506 | } |
507 | mouseMoveEvent( event ); | ||
508 | // } | ||
462 | } | 509 | } |
463 | 510 | ||
464 | 511 | ||
diff --git a/core/multimedia/opieplayer/videowidget.h b/core/multimedia/opieplayer/videowidget.h index fd86cd2..e9778f1 100644 --- a/core/multimedia/opieplayer/videowidget.h +++ b/core/multimedia/opieplayer/videowidget.h | |||
@@ -28,12 +28,14 @@ class QSlider; | |||
28 | 28 | ||
29 | 29 | ||
30 | enum VideoButtons { | 30 | enum VideoButtons { |
31 | VideoPrevious, | ||
32 | VideoStop, | 31 | VideoStop, |
33 | VideoPlay, | 32 | VideoPlay, |
34 | VideoPause, | 33 | // VideoPause, |
34 | VideoPrevious, | ||
35 | VideoNext, | 35 | VideoNext, |
36 | VideoPlayList, | 36 | VideoVolUp, |
37 | VideoVolDown, | ||
38 | // VideoPlayList, | ||
37 | VideoFullscreen | 39 | VideoFullscreen |
38 | }; | 40 | }; |
39 | 41 | ||
@@ -49,7 +51,7 @@ public slots: | |||
49 | void updateSlider( long, long ); | 51 | void updateSlider( long, long ); |
50 | void sliderPressed( ); | 52 | void sliderPressed( ); |
51 | void sliderReleased( ); | 53 | void sliderReleased( ); |
52 | void setPaused( bool b) { setToggleButton( VideoPause, b ); } | 54 | // void setPaused( bool b) { setToggleButton( VideoPause, b ); } |
53 | void setPlaying( bool b) { setToggleButton( VideoPlay, b ); } | 55 | void setPlaying( bool b) { setToggleButton( VideoPlay, b ); } |
54 | void setFullscreen( bool b ) { setToggleButton( VideoFullscreen, b ); } | 56 | void setFullscreen( bool b ) { setToggleButton( VideoFullscreen, b ); } |
55 | void makeVisible(); | 57 | void makeVisible(); |
@@ -58,6 +60,10 @@ public slots: | |||
58 | void setView( char ); | 60 | void setView( char ); |
59 | 61 | ||
60 | signals: | 62 | signals: |
63 | void moreClicked(); | ||
64 | void lessClicked(); | ||
65 | void moreReleased(); | ||
66 | void lessReleased(); | ||
61 | void sliderMoved( long ); | 67 | void sliderMoved( long ); |
62 | 68 | ||
63 | protected: | 69 | protected: |