-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 7c2b007..5cdfbf2 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -250,305 +250,305 @@ static bool audioSliderBeingMoved = FALSE; | |||
250 | void AudioWidget::sliderPressed() { | 250 | void AudioWidget::sliderPressed() { |
251 | audioSliderBeingMoved = TRUE; | 251 | audioSliderBeingMoved = TRUE; |
252 | } | 252 | } |
253 | 253 | ||
254 | 254 | ||
255 | void AudioWidget::sliderReleased() { | 255 | void AudioWidget::sliderReleased() { |
256 | audioSliderBeingMoved = FALSE; | 256 | audioSliderBeingMoved = FALSE; |
257 | if ( slider.width() == 0 ) | 257 | if ( slider.width() == 0 ) |
258 | return; | 258 | return; |
259 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); | 259 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); |
260 | mediaPlayerState->setPosition( val ); | 260 | mediaPlayerState->setPosition( val ); |
261 | } | 261 | } |
262 | 262 | ||
263 | void AudioWidget::setPosition( long i ) { | 263 | void AudioWidget::setPosition( long i ) { |
264 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); | 264 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); |
265 | updateSlider( i, mediaPlayerState->length() ); | 265 | updateSlider( i, mediaPlayerState->length() ); |
266 | } | 266 | } |
267 | 267 | ||
268 | 268 | ||
269 | void AudioWidget::setLength( long max ) { | 269 | void AudioWidget::setLength( long max ) { |
270 | updateSlider( mediaPlayerState->position(), max ); | 270 | updateSlider( mediaPlayerState->position(), max ); |
271 | } | 271 | } |
272 | 272 | ||
273 | 273 | ||
274 | void AudioWidget::setView( char view ) { | 274 | void AudioWidget::setView( char view ) { |
275 | 275 | ||
276 | if ( view == 'a' ) { | 276 | if ( view == 'a' ) { |
277 | // startTimer( 150 ); | 277 | // startTimer( 150 ); |
278 | showMaximized(); | 278 | showMaximized(); |
279 | } else { | 279 | } else { |
280 | killTimers(); | 280 | killTimers(); |
281 | hide(); | 281 | hide(); |
282 | } | 282 | } |
283 | // qApp->processEvents(); | 283 | // qApp->processEvents(); |
284 | } | 284 | } |
285 | 285 | ||
286 | 286 | ||
287 | void AudioWidget::setSeekable( bool isSeekable ) { | 287 | void AudioWidget::setSeekable( bool isSeekable ) { |
288 | 288 | ||
289 | if ( !isSeekable ) { | 289 | if ( !isSeekable ) { |
290 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); | 290 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); |
291 | if( !slider.isHidden()) { | 291 | if( !slider.isHidden()) { |
292 | slider.hide(); | 292 | slider.hide(); |
293 | } | 293 | } |
294 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 294 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
295 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 295 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
296 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 296 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
297 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 297 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
298 | } else { | 298 | } else { |
299 | // this stops the slider from being moved, thus | 299 | // this stops the slider from being moved, thus |
300 | // does not stop stream when it reaches the end | 300 | // does not stop stream when it reaches the end |
301 | slider.show(); | 301 | slider.show(); |
302 | qDebug( " CONNECT SET POSTION " ); | 302 | qDebug( " CONNECT SET POSTION " ); |
303 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 303 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
304 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 304 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
305 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 305 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
306 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 306 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
307 | } | 307 | } |
308 | } | 308 | } |
309 | 309 | ||
310 | 310 | ||
311 | static QString timeAsString( long length ) { | 311 | static QString timeAsString( long length ) { |
312 | int minutes = length / 60; | 312 | int minutes = length / 60; |
313 | int seconds = length % 60; | 313 | int seconds = length % 60; |
314 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); | 314 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); |
315 | } | 315 | } |
316 | 316 | ||
317 | void AudioWidget::updateSlider( long i, long max ) { | 317 | void AudioWidget::updateSlider( long i, long max ) { |
318 | 318 | ||
319 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | 319 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); |
320 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; | 320 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; |
321 | 321 | ||
322 | if ( max == 0 ) { | 322 | if ( max == 0 ) { |
323 | return; | 323 | return; |
324 | } | 324 | } |
325 | // Will flicker too much if we don't do this | 325 | // Will flicker too much if we don't do this |
326 | // Scale to something reasonable | 326 | // Scale to something reasonable |
327 | int width = slider.width(); | 327 | int width = slider.width(); |
328 | int val = int((double)i * width / max); | 328 | int val = int((double)i * width / max); |
329 | if ( !audioSliderBeingMoved ) { | 329 | if ( !audioSliderBeingMoved ) { |
330 | if ( slider.value() != val ) { | 330 | if ( slider.value() != val ) { |
331 | slider.setValue( val ); | 331 | slider.setValue( val ); |
332 | } | 332 | } |
333 | 333 | ||
334 | if ( slider.maxValue() != width ) { | 334 | if ( slider.maxValue() != width ) { |
335 | slider.setMaxValue( width ); | 335 | slider.setMaxValue( width ); |
336 | } | 336 | } |
337 | } | 337 | } |
338 | } | 338 | } |
339 | 339 | ||
340 | 340 | ||
341 | void AudioWidget::setToggleButton( int i, bool down ) { | 341 | void AudioWidget::setToggleButton( int i, bool down ) { |
342 | qDebug("setToggleButton %d", i); | 342 | qDebug("setToggleButton %d", i); |
343 | if ( down != audioButtons[i].isDown ) { | 343 | if ( down != audioButtons[i].isDown ) { |
344 | toggleButton( i ); | 344 | toggleButton( i ); |
345 | } | 345 | } |
346 | } | 346 | } |
347 | 347 | ||
348 | 348 | ||
349 | void AudioWidget::toggleButton( int i ) { | 349 | void AudioWidget::toggleButton( int i ) { |
350 | audioButtons[i].isDown = !audioButtons[i].isDown; | 350 | audioButtons[i].isDown = !audioButtons[i].isDown; |
351 | QPainter p(this); | 351 | QPainter p(this); |
352 | paintButton ( &p, i ); | 352 | paintButton ( &p, i ); |
353 | } | 353 | } |
354 | 354 | ||
355 | 355 | ||
356 | void AudioWidget::paintButton( QPainter *p, int i ) { | 356 | void AudioWidget::paintButton( QPainter *p, int i ) { |
357 | if ( audioButtons[i].isDown ) { | 357 | if ( audioButtons[i].isDown ) { |
358 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 358 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
359 | } else { | 359 | } else { |
360 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 360 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
361 | } | 361 | } |
362 | } | 362 | } |
363 | 363 | ||
364 | 364 | ||
365 | void AudioWidget::skipFor() { | 365 | void AudioWidget::skipFor() { |
366 | skipDirection = +1; | 366 | skipDirection = +1; |
367 | startTimer( 50 ); | 367 | startTimer( 50 ); |
368 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); | 368 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); |
369 | } | 369 | } |
370 | 370 | ||
371 | void AudioWidget::skipBack() { | 371 | void AudioWidget::skipBack() { |
372 | skipDirection = -1; | 372 | skipDirection = -1; |
373 | startTimer( 50 ); | 373 | startTimer( 50 ); |
374 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); | 374 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); |
375 | } | 375 | } |
376 | 376 | ||
377 | 377 | ||
378 | 378 | ||
379 | void AudioWidget::stopSkip() { | 379 | void AudioWidget::stopSkip() { |
380 | killTimers(); | 380 | killTimers(); |
381 | } | 381 | } |
382 | 382 | ||
383 | 383 | ||
384 | void AudioWidget::timerEvent( QTimerEvent * ) { | 384 | void AudioWidget::timerEvent( QTimerEvent * ) { |
385 | if ( skipDirection == +1 ) { | 385 | if ( skipDirection == +1 ) { |
386 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); | 386 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); |
387 | } else if ( skipDirection == -1 ) { | 387 | } else if ( skipDirection == -1 ) { |
388 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); | 388 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); |
389 | } | 389 | } |
390 | } | 390 | } |
391 | 391 | ||
392 | 392 | ||
393 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 393 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
394 | for ( int i = 0; i < numButtons; i++ ) { | 394 | for ( int i = 0; i < numButtons; i++ ) { |
395 | if ( event->state() == QMouseEvent::LeftButton ) { | 395 | if ( event->state() == QMouseEvent::LeftButton ) { |
396 | // The test to see if the mouse click is inside the button or not | 396 | // The test to see if the mouse click is inside the button or not |
397 | int x = event->pos().x() - xoff; | 397 | int x = event->pos().x() - xoff; |
398 | int y = event->pos().y() - yoff; | 398 | int y = event->pos().y() - yoff; |
399 | 399 | ||
400 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() | 400 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() |
401 | && y < imgButtonMask->height() | 401 | && y < imgButtonMask->height() |
402 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | 402 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); |
403 | 403 | ||
404 | if ( isOnButton && !audioButtons[i].isHeld ) { | 404 | if ( isOnButton && !audioButtons[i].isHeld ) { |
405 | audioButtons[i].isHeld = TRUE; | 405 | audioButtons[i].isHeld = TRUE; |
406 | toggleButton(i); | 406 | toggleButton(i); |
407 | switch (i) { | 407 | switch (i) { |
408 | case AudioVolumeUp: | 408 | case AudioVolumeUp: |
409 | emit moreClicked(); | 409 | emit moreClicked(); |
410 | return; | 410 | return; |
411 | case AudioVolumeDown: | 411 | case AudioVolumeDown: |
412 | emit lessClicked(); | 412 | emit lessClicked(); |
413 | return; | 413 | return; |
414 | case AudioForward: | 414 | case AudioForward: |
415 | emit forwardClicked(); | 415 | emit forwardClicked(); |
416 | return; | 416 | return; |
417 | case AudioBack: | 417 | case AudioBack: |
418 | emit backClicked(); | 418 | emit backClicked(); |
419 | return; | 419 | return; |
420 | } | 420 | } |
421 | } else if ( !isOnButton && audioButtons[i].isHeld ) { | 421 | } else if ( !isOnButton && audioButtons[i].isHeld ) { |
422 | audioButtons[i].isHeld = FALSE; | 422 | audioButtons[i].isHeld = FALSE; |
423 | toggleButton(i); | 423 | toggleButton(i); |
424 | } | 424 | } |
425 | } else { | 425 | } else { |
426 | if ( audioButtons[i].isHeld ) { | 426 | if ( audioButtons[i].isHeld ) { |
427 | audioButtons[i].isHeld = FALSE; | 427 | audioButtons[i].isHeld = FALSE; |
428 | if ( !audioButtons[i].isToggle ) { | 428 | if ( !audioButtons[i].isToggle ) { |
429 | setToggleButton( i, FALSE ); | 429 | setToggleButton( i, FALSE ); |
430 | } | 430 | } |
431 | qDebug("mouseEvent %d", i); | 431 | qDebug("mouseEvent %d", i); |
432 | switch (i) { | 432 | switch (i) { |
433 | case AudioPlay: | 433 | case AudioPlay: |
434 | if( mediaPlayerState->isPaused() ) { | 434 | if( mediaPlayerState->isPaused() ) { |
435 | mediaPlayerState->setPaused( FALSE ); | 435 | mediaPlayerState->setPaused( FALSE ); |
436 | return; | 436 | return; |
437 | } else if( !mediaPlayerState->isPaused() ) { | 437 | } else if( !mediaPlayerState->isPaused() ) { |
438 | mediaPlayerState->setPaused( TRUE ); | 438 | mediaPlayerState->setPaused( TRUE ); |
439 | return; | 439 | return; |
440 | } | 440 | } |
441 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; | 441 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; |
442 | case AudioNext: if( playList->whichList() ==0 ) mediaPlayerState->setNext(); return; | 442 | case AudioNext: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setNext(); return; |
443 | case AudioPrevious: if( playList->whichList() ==0 ) mediaPlayerState->setPrev(); return; | 443 | case AudioPrevious: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setPrev(); return; |
444 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; | 444 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; |
445 | case AudioVolumeUp: emit moreReleased(); return; | 445 | case AudioVolumeUp: emit moreReleased(); return; |
446 | case AudioVolumeDown: emit lessReleased(); return; | 446 | case AudioVolumeDown: emit lessReleased(); return; |
447 | case AudioPlayList: mediaPlayerState->setList(); return; | 447 | case AudioPlayList: mediaPlayerState->setList(); return; |
448 | case AudioForward: emit forwardReleased(); return; | 448 | case AudioForward: emit forwardReleased(); return; |
449 | case AudioBack: emit backReleased(); return; | 449 | case AudioBack: emit backReleased(); return; |
450 | } | 450 | } |
451 | } | 451 | } |
452 | } | 452 | } |
453 | } | 453 | } |
454 | } | 454 | } |
455 | 455 | ||
456 | 456 | ||
457 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 457 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
458 | mouseMoveEvent( event ); | 458 | mouseMoveEvent( event ); |
459 | } | 459 | } |
460 | 460 | ||
461 | 461 | ||
462 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | 462 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { |
463 | mouseMoveEvent( event ); | 463 | mouseMoveEvent( event ); |
464 | } | 464 | } |
465 | 465 | ||
466 | 466 | ||
467 | void AudioWidget::showEvent( QShowEvent* ) { | 467 | void AudioWidget::showEvent( QShowEvent* ) { |
468 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 468 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
469 | mouseMoveEvent( &event ); | 469 | mouseMoveEvent( &event ); |
470 | } | 470 | } |
471 | 471 | ||
472 | 472 | ||
473 | void AudioWidget::closeEvent( QCloseEvent* ) { | 473 | void AudioWidget::closeEvent( QCloseEvent* ) { |
474 | mediaPlayerState->setList(); | 474 | mediaPlayerState->setList(); |
475 | } | 475 | } |
476 | 476 | ||
477 | 477 | ||
478 | void AudioWidget::paintEvent( QPaintEvent * pe ) { | 478 | void AudioWidget::paintEvent( QPaintEvent * pe ) { |
479 | if ( !pe->erased() ) { | 479 | if ( !pe->erased() ) { |
480 | // Combine with background and double buffer | 480 | // Combine with background and double buffer |
481 | QPixmap pix( pe->rect().size() ); | 481 | QPixmap pix( pe->rect().size() ); |
482 | QPainter p( &pix ); | 482 | QPainter p( &pix ); |
483 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 483 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
484 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); | 484 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); |
485 | for ( int i = 0; i < numButtons; i++ ) | 485 | for ( int i = 0; i < numButtons; i++ ) |
486 | paintButton( &p, i ); | 486 | paintButton( &p, i ); |
487 | QPainter p2( this ); | 487 | QPainter p2( this ); |
488 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 488 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
489 | } else { | 489 | } else { |
490 | QPainter p( this ); | 490 | QPainter p( this ); |
491 | for ( int i = 0; i < numButtons; i++ ) | 491 | for ( int i = 0; i < numButtons; i++ ) |
492 | paintButton( &p, i ); | 492 | paintButton( &p, i ); |
493 | } | 493 | } |
494 | } | 494 | } |
495 | 495 | ||
496 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | 496 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { |
497 | switch ( e->key() ) { | 497 | switch ( e->key() ) { |
498 | ////////////////////////////// Zaurus keys | 498 | ////////////////////////////// Zaurus keys |
499 | case Key_Home: | 499 | case Key_Home: |
500 | break; | 500 | break; |
501 | case Key_F9: //activity | 501 | case Key_F9: //activity |
502 | hide(); | 502 | hide(); |
503 | // qDebug("Audio F9"); | 503 | // qDebug("Audio F9"); |
504 | break; | 504 | break; |
505 | case Key_F10: //contacts | 505 | case Key_F10: //contacts |
506 | break; | 506 | break; |
507 | case Key_F11: //menu | 507 | case Key_F11: //menu |
508 | mediaPlayerState->toggleBlank(); | 508 | mediaPlayerState->toggleBlank(); |
509 | break; | 509 | break; |
510 | case Key_F12: //home | 510 | case Key_F12: //home |
511 | break; | 511 | break; |
512 | case Key_F13: //mail | 512 | case Key_F13: //mail |
513 | mediaPlayerState->toggleBlank(); | 513 | mediaPlayerState->toggleBlank(); |
514 | break; | 514 | break; |
515 | case Key_Space: { | 515 | case Key_Space: { |
516 | if(mediaPlayerState->isPlaying()) { | 516 | if(mediaPlayerState->isPlaying()) { |
517 | // toggleButton(1); | 517 | // toggleButton(1); |
518 | mediaPlayerState->setPlaying(FALSE); | 518 | mediaPlayerState->setPlaying(FALSE); |
519 | // toggleButton(1); | 519 | // toggleButton(1); |
520 | } else { | 520 | } else { |
521 | // toggleButton(0); | 521 | // toggleButton(0); |
522 | mediaPlayerState->setPlaying(TRUE); | 522 | mediaPlayerState->setPlaying(TRUE); |
523 | // toggleButton(0); | 523 | // toggleButton(0); |
524 | } | 524 | } |
525 | } | 525 | } |
526 | break; | 526 | break; |
527 | case Key_Down: | 527 | case Key_Down: |
528 | // toggleButton(6); | 528 | // toggleButton(6); |
529 | emit lessClicked(); | 529 | emit lessClicked(); |
530 | emit lessReleased(); | 530 | emit lessReleased(); |
531 | // toggleButton(6); | 531 | // toggleButton(6); |
532 | break; | 532 | break; |
533 | case Key_Up: | 533 | case Key_Up: |
534 | // toggleButton(5); | 534 | // toggleButton(5); |
535 | emit moreClicked(); | 535 | emit moreClicked(); |
536 | emit moreReleased(); | 536 | emit moreReleased(); |
537 | // toggleButton(5); | 537 | // toggleButton(5); |
538 | break; | 538 | break; |
539 | case Key_Right: | 539 | case Key_Right: |
540 | // toggleButton(3); | 540 | // toggleButton(3); |
541 | mediaPlayerState->setNext(); | 541 | mediaPlayerState->setNext(); |
542 | // toggleButton(3); | 542 | // toggleButton(3); |
543 | break; | 543 | break; |
544 | case Key_Left: | 544 | case Key_Left: |
545 | // toggleButton(4); | 545 | // toggleButton(4); |
546 | mediaPlayerState->setPrev(); | 546 | mediaPlayerState->setPrev(); |
547 | // toggleButton(4); | 547 | // toggleButton(4); |
548 | break; | 548 | break; |
549 | case Key_Escape: { | 549 | case Key_Escape: { |
550 | } | 550 | } |
551 | break; | 551 | break; |
552 | 552 | ||
553 | }; | 553 | }; |
554 | } | 554 | } |