-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 956789f..6f3842f 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -256,242 +256,246 @@ void VideoWidget::updateSlider( long i, long max ) { | |||
256 | slider->setValue( val ); | 256 | slider->setValue( val ); |
257 | } | 257 | } |
258 | if ( slider->maxValue() != width ) { | 258 | if ( slider->maxValue() != width ) { |
259 | slider->setMaxValue( width ); | 259 | slider->setMaxValue( width ); |
260 | } | 260 | } |
261 | } | 261 | } |
262 | } | 262 | } |
263 | 263 | ||
264 | void VideoWidget::setToggleButton( int i, bool down ) { | 264 | void VideoWidget::setToggleButton( int i, bool down ) { |
265 | if ( down != videoButtons[i].isDown ) { | 265 | if ( down != videoButtons[i].isDown ) { |
266 | toggleButton( i ); | 266 | toggleButton( i ); |
267 | } | 267 | } |
268 | } | 268 | } |
269 | 269 | ||
270 | void VideoWidget::toggleButton( int i ) { | 270 | void VideoWidget::toggleButton( int i ) { |
271 | videoButtons[i].isDown = !videoButtons[i].isDown; | 271 | videoButtons[i].isDown = !videoButtons[i].isDown; |
272 | QPainter p(this); | 272 | QPainter p(this); |
273 | paintButton ( &p, i ); | 273 | paintButton ( &p, i ); |
274 | } | 274 | } |
275 | 275 | ||
276 | void VideoWidget::paintButton( QPainter *p, int i ) { | 276 | void VideoWidget::paintButton( QPainter *p, int i ) { |
277 | 277 | ||
278 | if ( videoButtons[i].isDown ) { | 278 | if ( videoButtons[i].isDown ) { |
279 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 279 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
280 | } else { | 280 | } else { |
281 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 281 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
282 | } | 282 | } |
283 | } | 283 | } |
284 | 284 | ||
285 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 285 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
286 | for ( int i = 0; i < numVButtons; i++ ) { | 286 | for ( int i = 0; i < numVButtons; i++ ) { |
287 | if ( event->state() == QMouseEvent::LeftButton ) { | 287 | if ( event->state() == QMouseEvent::LeftButton ) { |
288 | // The test to see if the mouse click is inside the button or not | 288 | // The test to see if the mouse click is inside the button or not |
289 | int x = event->pos().x() - xoff; | 289 | int x = event->pos().x() - xoff; |
290 | int y = event->pos().y() - yoff; | 290 | int y = event->pos().y() - yoff; |
291 | 291 | ||
292 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() | 292 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() |
293 | && y < imgButtonMask->height() | 293 | && y < imgButtonMask->height() |
294 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | 294 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); |
295 | 295 | ||
296 | if ( isOnButton && !videoButtons[i].isHeld ) { | 296 | if ( isOnButton && !videoButtons[i].isHeld ) { |
297 | videoButtons[i].isHeld = TRUE; | 297 | videoButtons[i].isHeld = TRUE; |
298 | toggleButton(i); | 298 | toggleButton(i); |
299 | 299 | ||
300 | switch (i) { | 300 | switch (i) { |
301 | case VideoVolUp: | 301 | case VideoVolUp: |
302 | emit moreClicked(); | 302 | emit moreClicked(); |
303 | return; | 303 | return; |
304 | case VideoVolDown: | 304 | case VideoVolDown: |
305 | emit lessClicked(); | 305 | emit lessClicked(); |
306 | return; | 306 | return; |
307 | } | 307 | } |
308 | } else if ( !isOnButton && videoButtons[i].isHeld ) { | 308 | } else if ( !isOnButton && videoButtons[i].isHeld ) { |
309 | videoButtons[i].isHeld = FALSE; | 309 | videoButtons[i].isHeld = FALSE; |
310 | toggleButton(i); | 310 | toggleButton(i); |
311 | } | 311 | } |
312 | } else { | 312 | } else { |
313 | 313 | ||
314 | if ( videoButtons[i].isHeld ) { | 314 | if ( videoButtons[i].isHeld ) { |
315 | videoButtons[i].isHeld = FALSE; | 315 | videoButtons[i].isHeld = FALSE; |
316 | if ( !videoButtons[i].isToggle ) { | 316 | if ( !videoButtons[i].isToggle ) { |
317 | setToggleButton( i, FALSE ); | 317 | setToggleButton( i, FALSE ); |
318 | } | 318 | } |
319 | 319 | ||
320 | switch(i) { | 320 | switch(i) { |
321 | 321 | ||
322 | case VideoPlay: { | 322 | case VideoPlay: { |
323 | if( mediaPlayerState->isPaused ) { | 323 | if( mediaPlayerState->isPaused ) { |
324 | setToggleButton( i, FALSE ); | 324 | setToggleButton( i, FALSE ); |
325 | mediaPlayerState->setPaused( FALSE ); | 325 | mediaPlayerState->setPaused( FALSE ); |
326 | return; | 326 | return; |
327 | } else if( !mediaPlayerState->isPaused ) { | 327 | } else if( !mediaPlayerState->isPaused ) { |
328 | setToggleButton( i, TRUE ); | 328 | setToggleButton( i, TRUE ); |
329 | mediaPlayerState->setPaused( TRUE ); | 329 | mediaPlayerState->setPaused( TRUE ); |
330 | return; | 330 | return; |
331 | } else { | 331 | } else { |
332 | return; | 332 | return; |
333 | } | 333 | } |
334 | } | 334 | } |
335 | 335 | ||
336 | case VideoStop: mediaPlayerState->setPlaying( FALSE ); return; | 336 | case VideoStop: mediaPlayerState->setPlaying( FALSE ); return; |
337 | case VideoNext: mediaPlayerState->setNext(); return; | 337 | case VideoNext: mediaPlayerState->setNext(); return; |
338 | case VideoPrevious: mediaPlayerState->setPrev(); return; | 338 | case VideoPrevious: mediaPlayerState->setPrev(); return; |
339 | case VideoVolUp: emit moreReleased(); return; | 339 | case VideoVolUp: emit moreReleased(); return; |
340 | case VideoVolDown: emit lessReleased(); return; | 340 | case VideoVolDown: emit lessReleased(); return; |
341 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | 341 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; |
342 | } | 342 | } |
343 | } | 343 | } |
344 | } | 344 | } |
345 | } | 345 | } |
346 | } | 346 | } |
347 | 347 | ||
348 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 348 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
349 | mouseMoveEvent( event ); | 349 | mouseMoveEvent( event ); |
350 | } | 350 | } |
351 | 351 | ||
352 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 352 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
353 | if ( mediaPlayerState->fullscreen() ) { | 353 | if ( mediaPlayerState->fullscreen() ) { |
354 | mediaPlayerState->setFullscreen( FALSE ); | 354 | mediaPlayerState->setFullscreen( FALSE ); |
355 | makeVisible(); | 355 | makeVisible(); |
356 | } | 356 | } |
357 | mouseMoveEvent( event ); | 357 | mouseMoveEvent( event ); |
358 | } | 358 | } |
359 | 359 | ||
360 | void VideoWidget::showEvent( QShowEvent* ) { | 360 | void VideoWidget::showEvent( QShowEvent* ) { |
361 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 361 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
362 | mouseMoveEvent( &event ); | 362 | mouseMoveEvent( &event ); |
363 | } | 363 | } |
364 | 364 | ||
365 | 365 | ||
366 | void VideoWidget::backToNormal() { | 366 | void VideoWidget::backToNormal() { |
367 | mediaPlayerState->setFullscreen( FALSE ); | 367 | mediaPlayerState->setFullscreen( FALSE ); |
368 | makeVisible(); | 368 | makeVisible(); |
369 | } | 369 | } |
370 | 370 | ||
371 | void VideoWidget::makeVisible() { | 371 | void VideoWidget::makeVisible() { |
372 | if ( mediaPlayerState->fullscreen() ) { | 372 | if ( mediaPlayerState->fullscreen() ) { |
373 | setBackgroundMode( QWidget::NoBackground ); | 373 | setBackgroundMode( QWidget::NoBackground ); |
374 | showFullScreen(); | 374 | showFullScreen(); |
375 | resize( qApp->desktop()->size() ); | 375 | resize( qApp->desktop()->size() ); |
376 | slider->hide(); | 376 | slider->hide(); |
377 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); | 377 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); |
378 | 378 | ||
379 | } else { | 379 | } else { |
380 | showMaximized(); | 380 | showMaximized(); |
381 | setBackgroundPixmap( *pixBg ); | 381 | setBackgroundPixmap( *pixBg ); |
382 | if ( mediaPlayerState->streaming() ) { | 382 | if ( mediaPlayerState->streaming() ) { |
383 | slider->hide(); | 383 | slider->hide(); |
384 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | ||
385 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | ||
384 | } else { | 386 | } else { |
385 | slider->show(); | 387 | slider->show(); |
388 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | ||
389 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | ||
386 | } | 390 | } |
387 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); | 391 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); |
388 | qApp->processEvents(); | 392 | qApp->processEvents(); |
389 | } | 393 | } |
390 | } | 394 | } |
391 | 395 | ||
392 | 396 | ||
393 | void VideoWidget::paintEvent( QPaintEvent * pe) { | 397 | void VideoWidget::paintEvent( QPaintEvent * pe) { |
394 | QPainter p( this ); | 398 | QPainter p( this ); |
395 | 399 | ||
396 | if ( mediaPlayerState->fullscreen() ) { | 400 | if ( mediaPlayerState->fullscreen() ) { |
397 | // Clear the background | 401 | // Clear the background |
398 | p.setBrush( QBrush( Qt::black ) ); | 402 | p.setBrush( QBrush( Qt::black ) ); |
399 | } else { | 403 | } else { |
400 | if ( !pe->erased() ) { | 404 | if ( !pe->erased() ) { |
401 | // Combine with background and double buffer | 405 | // Combine with background and double buffer |
402 | QPixmap pix( pe->rect().size() ); | 406 | QPixmap pix( pe->rect().size() ); |
403 | QPainter p( &pix ); | 407 | QPainter p( &pix ); |
404 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 408 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
405 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); | 409 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); |
406 | for ( int i = 0; i < numVButtons; i++ ) { | 410 | for ( int i = 0; i < numVButtons; i++ ) { |
407 | paintButton( &p, i ); | 411 | paintButton( &p, i ); |
408 | } | 412 | } |
409 | QPainter p2( this ); | 413 | QPainter p2( this ); |
410 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 414 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
411 | } else { | 415 | } else { |
412 | QPainter p( this ); | 416 | QPainter p( this ); |
413 | for ( int i = 0; i < numVButtons; i++ ) | 417 | for ( int i = 0; i < numVButtons; i++ ) |
414 | paintButton( &p, i ); | 418 | paintButton( &p, i ); |
415 | } | 419 | } |
416 | slider->repaint( TRUE ); | 420 | slider->repaint( TRUE ); |
417 | } | 421 | } |
418 | } | 422 | } |
419 | 423 | ||
420 | 424 | ||
421 | void VideoWidget::closeEvent( QCloseEvent* ) { | 425 | void VideoWidget::closeEvent( QCloseEvent* ) { |
422 | mediaPlayerState->setList(); | 426 | mediaPlayerState->setList(); |
423 | } | 427 | } |
424 | 428 | ||
425 | 429 | ||
426 | 430 | ||
427 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | 431 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { |
428 | switch ( e->key() ) { | 432 | switch ( e->key() ) { |
429 | ////////////////////////////// Zaurus keys | 433 | ////////////////////////////// Zaurus keys |
430 | case Key_Home: | 434 | case Key_Home: |
431 | break; | 435 | break; |
432 | case Key_F9: //activity | 436 | case Key_F9: //activity |
433 | break; | 437 | break; |
434 | case Key_F10: //contacts | 438 | case Key_F10: //contacts |
435 | // hide(); | 439 | // hide(); |
436 | break; | 440 | break; |
437 | case Key_F11: //menu | 441 | case Key_F11: //menu |
438 | break; | 442 | break; |
439 | case Key_F12: //home | 443 | case Key_F12: //home |
440 | break; | 444 | break; |
441 | case Key_F13: //mail | 445 | case Key_F13: //mail |
442 | break; | 446 | break; |
443 | case Key_Space: { | 447 | case Key_Space: { |
444 | if(mediaPlayerState->playing()) { | 448 | if(mediaPlayerState->playing()) { |
445 | mediaPlayerState->setPlaying(FALSE); | 449 | mediaPlayerState->setPlaying(FALSE); |
446 | } else { | 450 | } else { |
447 | mediaPlayerState->setPlaying(TRUE); | 451 | mediaPlayerState->setPlaying(TRUE); |
448 | } | 452 | } |
449 | } | 453 | } |
450 | break; | 454 | break; |
451 | case Key_Down: | 455 | case Key_Down: |
452 | // toggleButton(6); | 456 | // toggleButton(6); |
453 | emit lessClicked(); | 457 | emit lessClicked(); |
454 | emit lessReleased(); | 458 | emit lessReleased(); |
455 | // toggleButton(6); | 459 | // toggleButton(6); |
456 | break; | 460 | break; |
457 | case Key_Up: | 461 | case Key_Up: |
458 | // toggleButton(5); | 462 | // toggleButton(5); |
459 | emit moreClicked(); | 463 | emit moreClicked(); |
460 | emit moreReleased(); | 464 | emit moreReleased(); |
461 | // toggleButton(5); | 465 | // toggleButton(5); |
462 | break; | 466 | break; |
463 | case Key_Right: | 467 | case Key_Right: |
464 | mediaPlayerState->setNext(); | 468 | mediaPlayerState->setNext(); |
465 | break; | 469 | break; |
466 | case Key_Left: | 470 | case Key_Left: |
467 | mediaPlayerState->setPrev(); | 471 | mediaPlayerState->setPrev(); |
468 | break; | 472 | break; |
469 | case Key_Escape: | 473 | case Key_Escape: |
470 | #if defined(QT_QWS_IPAQ) | 474 | #if defined(QT_QWS_IPAQ) |
471 | if( mediaPlayerState->isPaused ) { | 475 | if( mediaPlayerState->isPaused ) { |
472 | setToggleButton( i, FALSE ); | 476 | setToggleButton( i, FALSE ); |
473 | mediaPlayerState->setPaused( FALSE ); | 477 | mediaPlayerState->setPaused( FALSE ); |
474 | } else if( !mediaPlayerState->isPaused ) { | 478 | } else if( !mediaPlayerState->isPaused ) { |
475 | setToggleButton( i, TRUE ); | 479 | setToggleButton( i, TRUE ); |
476 | mediaPlayerState->setPaused( TRUE ); | 480 | mediaPlayerState->setPaused( TRUE ); |
477 | } | 481 | } |
478 | #endif | 482 | #endif |
479 | break; | 483 | break; |
480 | 484 | ||
481 | }; | 485 | }; |
482 | } | 486 | } |
483 | 487 | ||
484 | XineVideoWidget* VideoWidget::vidWidget() { | 488 | XineVideoWidget* VideoWidget::vidWidget() { |
485 | return videoFrame; | 489 | return videoFrame; |
486 | } | 490 | } |
487 | 491 | ||
488 | 492 | ||
489 | void VideoWidget::setFullscreen ( bool b ) { | 493 | void VideoWidget::setFullscreen ( bool b ) { |
490 | setToggleButton( VideoFullscreen, b ); | 494 | setToggleButton( VideoFullscreen, b ); |
491 | } | 495 | } |
492 | 496 | ||
493 | 497 | ||
494 | void VideoWidget::setPlaying( bool b) { | 498 | void VideoWidget::setPlaying( bool b) { |
495 | setToggleButton( VideoPlay, b ); | 499 | setToggleButton( VideoPlay, b ); |
496 | } | 500 | } |
497 | 501 | ||