summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/videowidget.cpp107
1 files changed, 0 insertions, 107 deletions
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp
index 6ed0108..48104ca 100644
--- a/core/multimedia/opieplayer/videowidget.cpp
+++ b/core/multimedia/opieplayer/videowidget.cpp
@@ -217,372 +217,265 @@ void VideoWidget::resizeEvent( QResizeEvent * ) {
217 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); 217 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p );
218 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); 218 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p );
219 219
220 for ( int i = 0; i < 7; i++ ) 220 for ( int i = 0; i < 7; i++ )
221 { 221 {
222 if ( !masks[i]->isNull() ) 222 if ( !masks[i]->isNull() )
223 { 223 {
224 delete buttonPixUp[i]; 224 delete buttonPixUp[i];
225 delete buttonPixDown[i]; 225 delete buttonPixDown[i];
226 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); 226 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] );
227 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); 227 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] );
228 } 228 }
229 } 229 }
230 230
231 delete pixUp; 231 delete pixUp;
232 delete pixDn; 232 delete pixDn;
233} 233}
234 234
235 235
236void VideoWidget::sliderPressed() { 236void VideoWidget::sliderPressed() {
237 videoSliderBeingMoved = TRUE; 237 videoSliderBeingMoved = TRUE;
238} 238}
239 239
240 240
241void VideoWidget::sliderReleased() { 241void VideoWidget::sliderReleased() {
242 videoSliderBeingMoved = FALSE; 242 videoSliderBeingMoved = FALSE;
243 if ( slider->width() == 0 ) 243 if ( slider->width() == 0 )
244 return; 244 return;
245 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 245 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
246 mediaPlayerState->setPosition( val ); 246 mediaPlayerState->setPosition( val );
247} 247}
248 248
249 249
250void VideoWidget::setPosition( long i ) { 250void VideoWidget::setPosition( long i ) {
251 updateSlider( i, mediaPlayerState->length() ); 251 updateSlider( i, mediaPlayerState->length() );
252} 252}
253 253
254 254
255void VideoWidget::setLength( long max ) { 255void VideoWidget::setLength( long max ) {
256 updateSlider( mediaPlayerState->position(), max ); 256 updateSlider( mediaPlayerState->position(), max );
257} 257}
258 258
259 259
260void VideoWidget::setView( char view ) { 260void VideoWidget::setView( char view ) {
261 if ( view == 'v' ) 261 if ( view == 'v' )
262 { 262 {
263 makeVisible(); 263 makeVisible();
264 } 264 }
265 else 265 else
266 { 266 {
267 // Effectively blank the view next time we show it so it looks nicer 267 // Effectively blank the view next time we show it so it looks nicer
268 scaledWidth = 0; 268 scaledWidth = 0;
269 scaledHeight = 0; 269 scaledHeight = 0;
270 hide(); 270 hide();
271 } 271 }
272} 272}
273 273
274 274
275void VideoWidget::updateSlider( long i, long max ) { 275void VideoWidget::updateSlider( long i, long max ) {
276 // Will flicker too much if we don't do this 276 // Will flicker too much if we don't do this
277 if ( max == 0 ) 277 if ( max == 0 )
278 return; 278 return;
279 int width = slider->width(); 279 int width = slider->width();
280 int val = int((double)i * width / max); 280 int val = int((double)i * width / max);
281 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) 281 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved )
282 { 282 {
283 if ( slider->value() != val ) 283 if ( slider->value() != val )
284 slider->setValue( val ); 284 slider->setValue( val );
285 if ( slider->maxValue() != width ) 285 if ( slider->maxValue() != width )
286 slider->setMaxValue( width ); 286 slider->setMaxValue( width );
287 } 287 }
288} 288}
289 289
290 290
291void VideoWidget::setToggleButton( int i, bool down ) { 291void VideoWidget::setToggleButton( int i, bool down ) {
292 if ( down != videoButtons[i].isDown ) 292 if ( down != videoButtons[i].isDown )
293 toggleButton( i ); 293 toggleButton( i );
294} 294}
295 295
296 296
297void VideoWidget::toggleButton( int i ) { 297void VideoWidget::toggleButton( int i ) {
298 videoButtons[i].isDown = !videoButtons[i].isDown; 298 videoButtons[i].isDown = !videoButtons[i].isDown;
299 QPainter p(this); 299 QPainter p(this);
300 paintButton ( &p, i ); 300 paintButton ( &p, i );
301} 301}
302 302
303 303
304void VideoWidget::paintButton( QPainter *p, int i ) { 304void VideoWidget::paintButton( QPainter *p, int i ) {
305 if ( videoButtons[i].isDown ) 305 if ( videoButtons[i].isDown )
306 { 306 {
307 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 307 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
308 } 308 }
309 else 309 else
310 { 310 {
311 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 311 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
312 } 312 }
313// int x = videoButtons[i].xPos;
314// int y = videoButtons[i].yPos;
315// int offset = 10 + videoButtons[i].isDown;
316// p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] );
317// p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 );
318} 313}
319 314
320 315
321void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 316void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
322 for ( int i = 0; i < numVButtons; i++ ) { 317 for ( int i = 0; i < numVButtons; i++ ) {
323 if ( event->state() == QMouseEvent::LeftButton ) { 318 if ( event->state() == QMouseEvent::LeftButton ) {
324 // The test to see if the mouse click is inside the button or not 319 // The test to see if the mouse click is inside the button or not
325 int x = event->pos().x() - xoff; 320 int x = event->pos().x() - xoff;
326 int y = event->pos().y() - yoff; 321 int y = event->pos().y() - yoff;
327 322
328 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 323 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
329 && y < imgButtonMask->height() 324 && y < imgButtonMask->height()
330 && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 325 && imgButtonMask->pixelIndex( x, y ) == i + 1 );
331 326
332 if ( isOnButton && !videoButtons[i].isHeld ) { 327 if ( isOnButton && !videoButtons[i].isHeld ) {
333 videoButtons[i].isHeld = TRUE; 328 videoButtons[i].isHeld = TRUE;
334 toggleButton(i); 329 toggleButton(i);
335 330
336 switch (i) { 331 switch (i) {
337 case VideoVolUp: 332 case VideoVolUp:
338 emit moreClicked(); 333 emit moreClicked();
339 return; 334 return;
340 case VideoVolDown: 335 case VideoVolDown:
341 emit lessClicked(); 336 emit lessClicked();
342 return; 337 return;
343 } 338 }
344 } else if ( !isOnButton && videoButtons[i].isHeld ) { 339 } else if ( !isOnButton && videoButtons[i].isHeld ) {
345 videoButtons[i].isHeld = FALSE; 340 videoButtons[i].isHeld = FALSE;
346 toggleButton(i); 341 toggleButton(i);
347 } 342 }
348 } else { 343 } else {
349 344
350 if ( videoButtons[i].isHeld ) { 345 if ( videoButtons[i].isHeld ) {
351 videoButtons[i].isHeld = FALSE; 346 videoButtons[i].isHeld = FALSE;
352 if ( !videoButtons[i].isToggle ) { 347 if ( !videoButtons[i].isToggle ) {
353 setToggleButton( i, FALSE ); 348 setToggleButton( i, FALSE );
354 } 349 }
355 350
356 switch(i) { 351 switch(i) {
357 352
358 case VideoPlay: { 353 case VideoPlay: {
359 qDebug("play"); 354 qDebug("play");
360 if( !mediaPlayerState->playing()) { 355 if( !mediaPlayerState->playing()) {
361 mediaPlayerState->setPlaying( true); 356 mediaPlayerState->setPlaying( true);
362 setToggleButton( i-1, false ); 357 setToggleButton( i-1, false );
363 setToggleButton( i, false ); 358 setToggleButton( i, false );
364 return; 359 return;
365 } 360 }
366 if( mediaPlayerState->isPaused ) { 361 if( mediaPlayerState->isPaused ) {
367 qDebug("isPaused"); 362 qDebug("isPaused");
368 setToggleButton( i, FALSE ); 363 setToggleButton( i, FALSE );
369 mediaPlayerState->setPaused( FALSE ); 364 mediaPlayerState->setPaused( FALSE );
370 return; 365 return;
371 } else if( !mediaPlayerState->isPaused ) { 366 } else if( !mediaPlayerState->isPaused ) {
372 qDebug("is not paused"); 367 qDebug("is not paused");
373 setToggleButton( i, TRUE ); 368 setToggleButton( i, TRUE );
374 mediaPlayerState->setPaused( TRUE ); 369 mediaPlayerState->setPaused( TRUE );
375 return; 370 return;
376 } else { 371 } else {
377 return; 372 return;
378 } 373 }
379 } 374 }
380 375
381 case VideoStop: qDebug("stop"); mediaPlayerState->setPlaying( FALSE ); setToggleButton( i+1, true); setToggleButton( i, true ); return; 376 case VideoStop: qDebug("stop"); mediaPlayerState->setPlaying( FALSE ); setToggleButton( i+1, true); setToggleButton( i, true ); return;
382 case VideoNext: mediaPlayerState->setNext(); return; 377 case VideoNext: mediaPlayerState->setNext(); return;
383 case VideoPrevious: mediaPlayerState->setPrev(); return; 378 case VideoPrevious: mediaPlayerState->setPrev(); return;
384 case VideoVolUp: emit moreReleased(); return; 379 case VideoVolUp: emit moreReleased(); return;
385 case VideoVolDown: emit lessReleased(); return; 380 case VideoVolDown: emit lessReleased(); return;
386 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; 381 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
387 } 382 }
388 } 383 }
389 } 384 }
390 } 385 }
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);
410// switch (i) {
411// case VideoVolUp:
412// emit moreClicked();
413// return;
414// case VideoVolDown:
415// emit lessClicked();
416// return;
417// }
418// } else if ( !isOnButton && videoButtons[i].isHeld ) {
419// videoButtons[i].isHeld = FALSE;
420// toggleButton(i);
421// }
422
423
424// } else {
425
426// if ( videoButtons[i].isHeld )
427// {
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:
435// {
436// if( mediaPlayerState->isPaused ) {
437// setToggleButton( i, FALSE );
438// mediaPlayerState->setPaused( FALSE );
439// return;
440// }
441// else if( !mediaPlayerState->isPaused ) {
442// setToggleButton( i, TRUE );
443// mediaPlayerState->setPaused( TRUE );
444// return;
445// } else {
446// return;
447// }
448// }
449
450// case VideoStop: mediaPlayerState->setPlaying(FALSE); return;
451// // case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return;
452// // case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return;
453// case VideoNext: mediaPlayerState->setNext(); return;
454// case VideoPrevious: mediaPlayerState->setPrev(); return;
455// case VideoVolUp: emit moreReleased(); return;
456// case VideoVolDown: emit lessReleased(); return;
457// // case VideoPlayList: mediaPlayerState->setList(); return;
458// case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
459// }
460// }
461// }
462// }
463
464
465
466
467
468// for ( int i = 0; i < numButtons; i++ ) {
469// int x = videoButtons[i].xPos;
470// int y = videoButtons[i].yPos;
471// if ( event->state() == QMouseEvent::LeftButton ) {
472// // The test to see if the mouse click is inside the circular button or not
473// // (compared with the radius squared to avoid a square-root of our distance)
474// int radius = 16;
475// QPoint center = QPoint( x + radius, y + radius );
476// QPoint dXY = center - event->pos();
477// int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y();
478// bool isOnButton = dist <= (radius * radius);
479// if ( isOnButton != videoButtons[i].isHeld ) {
480// videoButtons[i].isHeld = isOnButton;
481// toggleButton(i);
482// }
483// } else {
484// if ( videoButtons[i].isHeld ) {
485// videoButtons[i].isHeld = FALSE;
486// if ( !videoButtons[i].isToggle )
487// setToggleButton( i, FALSE );
488// }
489// }
490
491
492// }
493} 386}
494 387
495 388
496void VideoWidget::mousePressEvent( QMouseEvent *event ) { 389void VideoWidget::mousePressEvent( QMouseEvent *event ) {
497 mouseMoveEvent( event ); 390 mouseMoveEvent( event );
498} 391}
499 392
500 393
501void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 394void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
502 if ( mediaPlayerState->fullscreen() ) 395 if ( mediaPlayerState->fullscreen() )
503 { 396 {
504 mediaPlayerState->setFullscreen( FALSE ); 397 mediaPlayerState->setFullscreen( FALSE );
505 makeVisible(); 398 makeVisible();
506 } 399 }
507 mouseMoveEvent( event ); 400 mouseMoveEvent( event );
508// } 401// }
509} 402}
510 403
511 404
512void VideoWidget::makeVisible() { 405void VideoWidget::makeVisible() {
513 if ( mediaPlayerState->fullscreen() ) 406 if ( mediaPlayerState->fullscreen() )
514 { 407 {
515 setBackgroundMode( QWidget::NoBackground ); 408 setBackgroundMode( QWidget::NoBackground );
516 showFullScreen(); 409 showFullScreen();
517 resize( qApp->desktop()->size() ); 410 resize( qApp->desktop()->size() );
518 slider->hide(); 411 slider->hide();
519 } 412 }
520 else 413 else
521 { 414 {
522 setBackgroundPixmap( *pixBg ); 415 setBackgroundPixmap( *pixBg );
523 showNormal(); 416 showNormal();
524 showMaximized(); 417 showMaximized();
525 slider->show(); 418 slider->show();
526 } 419 }
527} 420}
528 421
529 422
530void VideoWidget::paintEvent( QPaintEvent * pe) { 423void VideoWidget::paintEvent( QPaintEvent * pe) {
531 QPainter p( this ); 424 QPainter p( this );
532 425
533 if ( mediaPlayerState->fullscreen() ) { 426 if ( mediaPlayerState->fullscreen() ) {
534 // Clear the background 427 // Clear the background
535 p.setBrush( QBrush( Qt::black ) ); 428 p.setBrush( QBrush( Qt::black ) );
536 p.drawRect( rect() ); 429 p.drawRect( rect() );
537 } else { 430 } else {
538 if ( !pe->erased() ) { 431 if ( !pe->erased() ) {
539 // Combine with background and double buffer 432 // Combine with background and double buffer
540 QPixmap pix( pe->rect().size() ); 433 QPixmap pix( pe->rect().size() );
541 QPainter p( &pix ); 434 QPainter p( &pix );
542 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 435 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
543 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 436 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
544 for ( int i = 0; i < numVButtons; i++ ) { 437 for ( int i = 0; i < numVButtons; i++ ) {
545 paintButton( &p, i ); 438 paintButton( &p, i );
546 } 439 }
547 QPainter p2( this ); 440 QPainter p2( this );
548 p2.drawPixmap( pe->rect().topLeft(), pix ); 441 p2.drawPixmap( pe->rect().topLeft(), pix );
549 } else { 442 } else {
550 QPainter p( this ); 443 QPainter p( this );
551 for ( int i = 0; i < numVButtons; i++ ) 444 for ( int i = 0; i < numVButtons; i++ )
552 paintButton( &p, i ); 445 paintButton( &p, i );
553 } 446 }
554 slider->repaint( TRUE ); 447 slider->repaint( TRUE );
555 } 448 }
556} 449}
557 450
558 451
559void VideoWidget::closeEvent( QCloseEvent* ) { 452void VideoWidget::closeEvent( QCloseEvent* ) {
560 mediaPlayerState->setList(); 453 mediaPlayerState->setList();
561} 454}
562 455
563 456
564bool VideoWidget::playVideo() { 457bool VideoWidget::playVideo() {
565 bool result = FALSE; 458 bool result = FALSE;
566// qDebug("<<<<<<<<<<<<<<<< play video"); 459// qDebug("<<<<<<<<<<<<<<<< play video");
567 int stream = 0; 460 int stream = 0;
568 461
569 int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); 462 int sw = mediaPlayerState->curDecoder()->videoWidth( stream );
570 int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); 463 int sh = mediaPlayerState->curDecoder()->videoHeight( stream );
571 int dd = QPixmap::defaultDepth(); 464 int dd = QPixmap::defaultDepth();
572 int w = height(); 465 int w = height();
573 int h = width(); 466 int h = width();
574 467
575 ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; 468 ColorFormat format = (dd == 16) ? RGB565 : BGRA8888;
576 469
577 if ( mediaPlayerState->fullscreen() ) 470 if ( mediaPlayerState->fullscreen() )
578 { 471 {
579#ifdef USE_DIRECT_PAINTER 472#ifdef USE_DIRECT_PAINTER
580 QDirectPainter p(this); 473 QDirectPainter p(this);
581 474
582 if ( ( qt_screen->transformOrientation() == 3 ) && 475 if ( ( qt_screen->transformOrientation() == 3 ) &&
583 ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) 476 ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) )
584 { 477 {
585 478
586 w = 320; 479 w = 320;
587 h = 240; 480 h = 240;
588 481