summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-08-15 16:30:24 (UTC)
committer harlekin <harlekin>2002-08-15 16:30:24 (UTC)
commit747a98bb3b2a92b6f3577fa383fc44a8644a7ce2 (patch) (unidiff)
tree59ec78ec83871cb52ef4b4332cd7c44fa18de737
parent320f73ae9a8ffc6daf009b3fefb9035506b0f684 (diff)
downloadopie-747a98bb3b2a92b6f3577fa383fc44a8644a7ce2.zip
opie-747a98bb3b2a92b6f3577fa383fc44a8644a7ce2.tar.gz
opie-747a98bb3b2a92b6f3577fa383fc44a8644a7ce2.tar.bz2
update
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index a3d34f4..2cb1385 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -281,244 +281,243 @@ void AudioWidget::sliderPressed() {
281} 281}
282 282
283 283
284void AudioWidget::sliderReleased() { 284void AudioWidget::sliderReleased() {
285 audioSliderBeingMoved = FALSE; 285 audioSliderBeingMoved = FALSE;
286 if ( slider.width() == 0 ) 286 if ( slider.width() == 0 )
287 return; 287 return;
288 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); 288 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width());
289 mediaPlayerState->setPosition( val ); 289 mediaPlayerState->setPosition( val );
290} 290}
291 291
292void AudioWidget::setPosition( long i ) { 292void AudioWidget::setPosition( long i ) {
293// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); 293// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i);
294 updateSlider( i, mediaPlayerState->length() ); 294 updateSlider( i, mediaPlayerState->length() );
295} 295}
296 296
297 297
298void AudioWidget::setLength( long max ) { 298void AudioWidget::setLength( long max ) {
299 updateSlider( mediaPlayerState->position(), max ); 299 updateSlider( mediaPlayerState->position(), max );
300} 300}
301 301
302 302
303void AudioWidget::setView( char view ) { 303void AudioWidget::setView( char view ) {
304 304
305// this isnt working for some reason 305// this isnt working for some reason
306 306
307 if ( mediaPlayerState->streaming() ) { 307 if ( mediaPlayerState->streaming() ) {
308 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); 308 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
309 if( !slider.isHidden()) { 309 if( !slider.isHidden()) {
310 slider.hide(); 310 slider.hide();
311 } 311 }
312 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 312 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
313 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 313 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
314 } else { 314 } else {
315 // this stops the slider from being moved, thus 315 // this stops the slider from being moved, thus
316 // does not stop stream when it reaches the end 316 // does not stop stream when it reaches the end
317 slider.show(); 317 slider.show();
318 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 318 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
319 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 319 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
320 } 320 }
321 321
322 if ( view == 'a' ) { 322 if ( view == 'a' ) {
323 // startTimer( 150 ); 323 // startTimer( 150 );
324 showMaximized(); 324 showMaximized();
325 } else { 325 } else {
326 killTimers(); 326 killTimers();
327 hide(); 327 hide();
328 } 328 }
329} 329}
330 330
331 331
332static QString timeAsString( long length ) { 332static QString timeAsString( long length ) {
333 int minutes = length / 60; 333 int minutes = length / 60;
334 int seconds = length % 60; 334 int seconds = length % 60;
335 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 335 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
336} 336}
337 337
338void AudioWidget::updateSlider( long i, long max ) { 338void AudioWidget::updateSlider( long i, long max ) {
339 339
340 time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); 340 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
341// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; 341// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ;
342 342
343 if ( max == 0 ) { 343 if ( max == 0 ) {
344 return; 344 return;
345 } 345 }
346 // Will flicker too much if we don't do this 346 // Will flicker too much if we don't do this
347 // Scale to something reasonable 347 // Scale to something reasonable
348 int width = slider.width(); 348 int width = slider.width();
349 int val = int((double)i * width / max); 349 int val = int((double)i * width / max);
350 if ( !audioSliderBeingMoved ) { 350 if ( !audioSliderBeingMoved ) {
351 if ( slider.value() != val ) { 351 if ( slider.value() != val ) {
352 slider.setValue( val ); 352 slider.setValue( val );
353 } 353 }
354 354
355 if ( slider.maxValue() != width ) { 355 if ( slider.maxValue() != width ) {
356 slider.setMaxValue( width ); 356 slider.setMaxValue( width );
357 } 357 }
358 } 358 }
359} 359}
360 360
361 361
362void AudioWidget::setToggleButton( int i, bool down ) { 362void AudioWidget::setToggleButton( int i, bool down ) {
363 if ( down != audioButtons[i].isDown ) { 363 if ( down != audioButtons[i].isDown ) {
364 toggleButton( i ); 364 toggleButton( i );
365 } 365 }
366} 366}
367 367
368 368
369void AudioWidget::toggleButton( int i ) { 369void AudioWidget::toggleButton( int i ) {
370 audioButtons[i].isDown = !audioButtons[i].isDown; 370 audioButtons[i].isDown = !audioButtons[i].isDown;
371 QPainter p(this); 371 QPainter p(this);
372 paintButton ( &p, i ); 372 paintButton ( &p, i );
373} 373}
374 374
375 375
376void AudioWidget::paintButton( QPainter *p, int i ) { 376void AudioWidget::paintButton( QPainter *p, int i ) {
377 if ( audioButtons[i].isDown ) 377 if ( audioButtons[i].isDown ) {
378 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 378 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
379 else 379 } else {
380 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 380 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
381 }
381} 382}
382 383
383 384
384void AudioWidget::skipFor() { 385void AudioWidget::skipFor() {
385 skipDirection = +1; 386 skipDirection = +1;
386 startTimer( 50 ); 387 startTimer( 50 );
387 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); 388 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 );
388} 389}
389 390
390void AudioWidget::skipBack() { 391void AudioWidget::skipBack() {
391 skipDirection = -1; 392 skipDirection = -1;
392 startTimer( 50 ); 393 startTimer( 50 );
393 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); 394 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 );
394} 395}
395 396
396 397
397 398
398void AudioWidget::stopSkip() { 399void AudioWidget::stopSkip() {
399 killTimers(); 400 killTimers();
400} 401}
401 402
402 403
403void AudioWidget::timerEvent( QTimerEvent * ) { 404void AudioWidget::timerEvent( QTimerEvent * ) {
404 if ( skipDirection == +1 ) { 405 if ( skipDirection == +1 ) {
405 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); 406 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 );
406 } else if ( skipDirection == -1 ) { 407 } else if ( skipDirection == -1 ) {
407 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); 408 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 );
408 } 409 }
409} 410}
410 411
411 412
412void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 413void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
413 for ( int i = 0; i < numButtons; i++ ) { 414 for ( int i = 0; i < numButtons; i++ ) {
414 if ( event->state() == QMouseEvent::LeftButton ) { 415 if ( event->state() == QMouseEvent::LeftButton ) {
415 416 // The test to see if the mouse click is inside the button or not
416 // The test to see if the mouse click is inside the button or not
417 int x = event->pos().x() - xoff; 417 int x = event->pos().x() - xoff;
418 int y = event->pos().y() - yoff; 418 int y = event->pos().y() - yoff;
419 419
420 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 420 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
421 && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 421 && y < imgButtonMask->height()
422 422 && imgButtonMask->pixelIndex( x, y ) == i + 1 );
423 if ( isOnButton && i == AudioVolumeUp )
424 qDebug("on up");
425 423
426 if ( isOnButton && !audioButtons[i].isHeld ) { 424 if ( isOnButton && !audioButtons[i].isHeld ) {
427 audioButtons[i].isHeld = TRUE; 425 audioButtons[i].isHeld = TRUE;
428 toggleButton(i); 426 toggleButton(i);
427
429 switch (i) { 428 switch (i) {
430 case AudioVolumeUp: 429 case AudioVolumeUp:
431 qDebug("more clicked"); 430 qDebug("more clicked");
432 emit moreClicked(); 431 emit moreClicked();
433 return; 432 return;
434 case AudioVolumeDown: 433 case AudioVolumeDown:
435 emit lessClicked(); 434 emit lessClicked();
436 return; 435 return;
437 case AudioForward: 436 case AudioForward:
438 emit forwardClicked(); 437 emit forwardClicked();
439 return; 438 return;
440 case AudioBack: 439 case AudioBack:
441 emit backClicked(); 440 emit backClicked();
442 return; 441 return;
443 } 442 }
444 } else if ( !isOnButton && audioButtons[i].isHeld ) { 443 } else if ( !isOnButton && audioButtons[i].isHeld ) {
445 audioButtons[i].isHeld = FALSE; 444 audioButtons[i].isHeld = FALSE;
446 toggleButton(i); 445 toggleButton(i);
447 } 446 }
448 } else { 447 } else {
449 if ( audioButtons[i].isHeld ) { 448 if ( audioButtons[i].isHeld ) {
450 audioButtons[i].isHeld = FALSE; 449 audioButtons[i].isHeld = FALSE;
451 if ( !audioButtons[i].isToggle ) { 450 if ( !audioButtons[i].isToggle ) {
452 setToggleButton( i, FALSE ); 451 setToggleButton( i, FALSE );
453 qDebug("button toggled3 %d",i); 452 qDebug("button toggled3 %d",i);
454 } 453 }
455 switch (i) { 454 switch (i) {
456 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; 455 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return;
457 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 456 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
458 case AudioPause: mediaPlayerState->setPaused( audioButtons[i].isDown); return; 457 case AudioPause: mediaPlayerState->setPaused( audioButtons[i].isDown); return;
459 case AudioNext: mediaPlayerState->setNext(); return; 458 case AudioNext: mediaPlayerState->setNext(); return;
460 case AudioPrevious: mediaPlayerState->setPrev(); return; 459 case AudioPrevious: mediaPlayerState->setPrev(); return;
461 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; 460 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
462 case AudioVolumeUp: emit moreReleased(); return; 461 case AudioVolumeUp: emit moreReleased(); return;
463 case AudioVolumeDown: emit lessReleased(); return; 462 case AudioVolumeDown: emit lessReleased(); return;
464 case AudioPlayList: mediaPlayerState->setList(); return; 463 case AudioPlayList: mediaPlayerState->setList(); return;
465 case AudioForward: emit forwardReleased(); return; 464 case AudioForward: emit forwardReleased(); return;
466 case AudioBack: emit backReleased(); return; 465 case AudioBack: emit backReleased(); return;
467 } 466 }
468 } 467 }
469 } 468 }
470 } 469 }
471} 470}
472 471
473 472
474void AudioWidget::mousePressEvent( QMouseEvent *event ) { 473void AudioWidget::mousePressEvent( QMouseEvent *event ) {
475 mouseMoveEvent( event ); 474 mouseMoveEvent( event );
476} 475}
477 476
478 477
479void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 478void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
480 mouseMoveEvent( event ); 479 mouseMoveEvent( event );
481} 480}
482 481
483 482
484void AudioWidget::showEvent( QShowEvent* ) { 483void AudioWidget::showEvent( QShowEvent* ) {
485 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 484 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
486 mouseMoveEvent( &event ); 485 mouseMoveEvent( &event );
487} 486}
488 487
489 488
490void AudioWidget::closeEvent( QCloseEvent* ) { 489void AudioWidget::closeEvent( QCloseEvent* ) {
491 mediaPlayerState->setList(); 490 mediaPlayerState->setList();
492} 491}
493 492
494 493
495void AudioWidget::paintEvent( QPaintEvent * pe) { 494void AudioWidget::paintEvent( QPaintEvent * pe) {
496 if ( !pe->erased() ) { 495 if ( !pe->erased() ) {
497 // Combine with background and double buffer 496 // Combine with background and double buffer
498 QPixmap pix( pe->rect().size() ); 497 QPixmap pix( pe->rect().size() );
499 QPainter p( &pix ); 498 QPainter p( &pix );
500 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 499 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
501 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 500 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
502 for ( int i = 0; i < numButtons; i++ ) 501 for ( int i = 0; i < numButtons; i++ )
503 paintButton( &p, i ); 502 paintButton( &p, i );
504 QPainter p2( this ); 503 QPainter p2( this );
505 p2.drawPixmap( pe->rect().topLeft(), pix ); 504 p2.drawPixmap( pe->rect().topLeft(), pix );
506 } else { 505 } else {
507 QPainter p( this ); 506 QPainter p( this );
508 for ( int i = 0; i < numButtons; i++ ) 507 for ( int i = 0; i < numButtons; i++ )
509 paintButton( &p, i ); 508 paintButton( &p, i );
510 } 509 }
511} 510}
512 511
513void AudioWidget::keyReleaseEvent( QKeyEvent *e) 512void AudioWidget::keyReleaseEvent( QKeyEvent *e)
514{ 513{
515 switch ( e->key() ) { 514 switch ( e->key() ) {
516////////////////////////////// Zaurus keys 515////////////////////////////// Zaurus keys
517 case Key_Home: 516 case Key_Home:
518 break; 517 break;
519 case Key_F9: //activity 518 case Key_F9: //activity
520 hide(); 519 hide();
521// qDebug("Audio F9"); 520// qDebug("Audio F9");
522 break; 521 break;
523 case Key_F10: //contacts 522 case Key_F10: //contacts
524 break; 523 break;