Diffstat (limited to 'noncore/multimedia/opieplayer2/videowidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 87 |
1 files changed, 72 insertions, 15 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 9b88299..33153d4 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -63,12 +63,12 @@ struct MediaButton { | |||
63 | }; | 63 | }; |
64 | 64 | ||
65 | MediaButton videoButtons[] = { | 65 | MediaButton videoButtons[] = { |
66 | { FALSE, FALSE, FALSE }, // previous | ||
67 | { FALSE, FALSE, FALSE }, // stop | 66 | { FALSE, FALSE, FALSE }, // stop |
68 | { TRUE, FALSE, FALSE }, // play | 67 | { TRUE, FALSE, FALSE }, // play |
69 | { TRUE, FALSE, FALSE }, // pause | 68 | { FALSE, FALSE, FALSE }, // previous |
70 | { FALSE, FALSE, FALSE }, // next | 69 | { FALSE, FALSE, FALSE }, // next |
71 | { FALSE, FALSE, FALSE }, // playlist | 70 | { FALSE, FALSE, FALSE }, // volUp |
71 | { FALSE, FALSE, FALSE }, // volDown | ||
72 | { TRUE, FALSE, FALSE } // fullscreen | 72 | { TRUE, FALSE, FALSE } // fullscreen |
73 | }; | 73 | }; |
74 | 74 | ||
@@ -76,7 +76,7 @@ const char *skinV_mask_file_names[7] = { | |||
76 | "stop","play","back","fwd","up","down","full" | 76 | "stop","play","back","fwd","up","down","full" |
77 | }; | 77 | }; |
78 | 78 | ||
79 | static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | 79 | static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); |
80 | 80 | ||
81 | 81 | ||
82 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | 82 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : |
@@ -137,6 +137,7 @@ QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | |||
137 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 137 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
138 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 138 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
139 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 139 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
140 | |||
140 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 141 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
141 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 142 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
142 | 143 | ||
@@ -152,6 +153,7 @@ QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | |||
152 | 153 | ||
153 | 154 | ||
154 | VideoWidget::~VideoWidget() { | 155 | VideoWidget::~VideoWidget() { |
156 | mediaPlayerState->setPlaying( FALSE ); | ||
155 | for ( int i = 0; i < 7; i++ ) { | 157 | for ( int i = 0; i < 7; i++ ) { |
156 | delete buttonPixUp[i]; | 158 | delete buttonPixUp[i]; |
157 | delete buttonPixDown[i]; | 159 | delete buttonPixDown[i]; |
@@ -164,6 +166,7 @@ VideoWidget::~VideoWidget() { | |||
164 | for ( int i = 0; i < 7; i++ ) { | 166 | for ( int i = 0; i < 7; i++ ) { |
165 | delete masks[i]; | 167 | delete masks[i]; |
166 | } | 168 | } |
169 | |||
167 | } | 170 | } |
168 | 171 | ||
169 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 172 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
@@ -290,7 +293,7 @@ void VideoWidget::paintButton( QPainter *p, int i ) { | |||
290 | } | 293 | } |
291 | 294 | ||
292 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 295 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
293 | for ( int i = 0; i < numButtons; i++ ) { | 296 | for ( int i = 0; i < numVButtons; i++ ) { |
294 | if ( event->state() == QMouseEvent::LeftButton ) { | 297 | if ( event->state() == QMouseEvent::LeftButton ) { |
295 | // The test to see if the mouse click is inside the button or not | 298 | // The test to see if the mouse click is inside the button or not |
296 | int x = event->pos().x() - xoff; | 299 | int x = event->pos().x() - xoff; |
@@ -302,23 +305,68 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
302 | videoButtons[i].isHeld = isOnButton; | 305 | videoButtons[i].isHeld = isOnButton; |
303 | toggleButton(i); | 306 | toggleButton(i); |
304 | } | 307 | } |
308 | |||
309 | // qDebug("mouseMove event switch1 %d", i); | ||
310 | if( isOnButton) | ||
311 | switch (i) { | ||
312 | case VideoStop:{ | ||
313 | setToggleButton( i, FALSE ); | ||
314 | mediaPlayerState->setStop(TRUE); | ||
315 | mediaPlayerState->setPlaying(FALSE); | ||
316 | return; | ||
317 | } | ||
318 | case VideoPlay: { | ||
319 | |||
320 | if( mediaPlayerState->isPaused) { | ||
321 | setToggleButton( i, FALSE ); | ||
322 | mediaPlayerState->setPaused( FALSE); | ||
323 | return; | ||
324 | } | ||
325 | else if( mediaPlayerState->isPlaying) { | ||
326 | setToggleButton( i, TRUE ); | ||
327 | mediaPlayerState->setPaused( TRUE); | ||
328 | return; | ||
329 | } | ||
330 | else { | ||
331 | setToggleButton( i, FALSE ); | ||
332 | mediaPlayerState->setPlaying( videoButtons[i].isDown ); | ||
333 | return; | ||
334 | } | ||
335 | } | ||
336 | case VideoNext: qDebug("next"); mediaPlayerState->setNext(); return; | ||
337 | case VideoPrevious: qDebug("previous"); mediaPlayerState->setPrev(); return; | ||
338 | case VideoVolUp: return; | ||
339 | case VideoVolDown: return; | ||
340 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | ||
341 | |||
342 | }; | ||
343 | |||
305 | } else { | 344 | } else { |
306 | if ( videoButtons[i].isHeld ) { | 345 | if ( videoButtons[i].isHeld ) { |
307 | videoButtons[i].isHeld = FALSE; | 346 | videoButtons[i].isHeld = FALSE; |
308 | if ( !videoButtons[i].isToggle ) | 347 | if ( !videoButtons[i].isToggle ) { |
309 | setToggleButton( i, FALSE ); | 348 | setToggleButton( i, FALSE ); |
310 | } | 349 | } |
311 | } | 350 | // qDebug("mouseMove event switch2 %d %d", i, VideoPlay); |
312 | switch (i) { | 351 | switch (i) { |
313 | case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; | 352 | case VideoPlay: { |
353 | if( mediaPlayerState->isPaused) { | ||
354 | mediaPlayerState->setPaused( FALSE); return; } | ||
355 | else if( mediaPlayerState->isPlaying) { | ||
356 | mediaPlayerState->setPaused( TRUE); return; } | ||
357 | else | ||
358 | mediaPlayerState->setPlaying( TRUE /*videoButtons[i].isDown*/ ); return; | ||
359 | } | ||
314 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; | 360 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; |
315 | case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; | 361 | // case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; |
316 | case VideoNext: mediaPlayerState->setNext(); return; | 362 | case VideoNext: mediaPlayerState->setNext(); return; |
317 | case VideoPrevious: mediaPlayerState->setPrev(); return; | 363 | case VideoPrevious: mediaPlayerState->setPrev(); return; |
318 | case VideoPlayList: mediaPlayerState->setList(); return; | 364 | case VideoVolUp: return; |
365 | case VideoVolDown: return; | ||
319 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | 366 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; |
320 | } | 367 | } |
321 | 368 | } | |
369 | } | ||
322 | } | 370 | } |
323 | } | 371 | } |
324 | 372 | ||
@@ -371,20 +419,20 @@ void VideoWidget::paintEvent( QPaintEvent * pe) { | |||
371 | QPainter p( &pix ); | 419 | QPainter p( &pix ); |
372 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 420 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
373 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); | 421 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); |
374 | for ( int i = 0; i < numButtons; i++ ) | 422 | for ( int i = 0; i < numVButtons; i++ ) |
375 | paintButton( &p, i ); | 423 | paintButton( &p, i ); |
376 | QPainter p2( this ); | 424 | QPainter p2( this ); |
377 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 425 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
378 | } else { | 426 | } else { |
379 | QPainter p( this ); | 427 | QPainter p( this ); |
380 | for ( int i = 0; i < numButtons; i++ ) | 428 | for ( int i = 0; i < numVButtons; i++ ) |
381 | paintButton( &p, i ); | 429 | paintButton( &p, i ); |
382 | } | 430 | } |
383 | // for ( int i = 0; i < numButtons; i++ ) { | 431 | // for ( int i = 0; i < numButtons; i++ ) { |
384 | // paintButton( &p, i ); | 432 | // paintButton( &p, i ); |
385 | // } | 433 | // } |
386 | // // draw the slider | 434 | // draw the slider |
387 | // slider->repaint( TRUE ); | 435 | slider->repaint( TRUE ); |
388 | } | 436 | } |
389 | } | 437 | } |
390 | 438 | ||
@@ -464,3 +512,12 @@ XineVideoWidget* VideoWidget::vidWidget() { | |||
464 | void VideoWidget::setFullscreen ( bool b ) { | 512 | void VideoWidget::setFullscreen ( bool b ) { |
465 | setToggleButton( VideoFullscreen, b ); | 513 | setToggleButton( VideoFullscreen, b ); |
466 | } | 514 | } |
515 | |||
516 | void VideoWidget::setPaused( bool b) { | ||
517 | // setToggleButton( VideoPause, b ); | ||
518 | } | ||
519 | |||
520 | void VideoWidget::setPlaying( bool b) { | ||
521 | setToggleButton( VideoPlay, b ); | ||
522 | } | ||
523 | |||