summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-09 00:02:49 (UTC)
committer simon <simon>2002-12-09 00:02:49 (UTC)
commit373051a9f8e624e57bac83bb09af1840fef14b4c (patch) (unidiff)
tree8061ea742db5d311607e48dc2b033f971a0a4042
parent9c2b4d917af88b6051a3bc4273d6a50d124f65dd (diff)
downloadopie-373051a9f8e624e57bac83bb09af1840fef14b4c.zip
opie-373051a9f8e624e57bac83bb09af1840fef14b4c.tar.gz
opie-373051a9f8e624e57bac83bb09af1840fef14b4c.tar.bz2
- Key_Space triggers togglePaused()
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp10
1 files changed, 1 insertions, 9 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 2a158a8..8f34736 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -275,231 +275,223 @@ void AudioWidget::setSeekable( bool isSeekable ) {
275 275
276 if ( !isSeekable ) { 276 if ( !isSeekable ) {
277 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); 277 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
278 if( !slider.isHidden()) { 278 if( !slider.isHidden()) {
279 slider.hide(); 279 slider.hide();
280 } 280 }
281 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 281 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
282 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 282 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
283 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 283 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
284 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 284 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
285 } else { 285 } else {
286 // this stops the slider from being moved, thus 286 // this stops the slider from being moved, thus
287 // does not stop stream when it reaches the end 287 // does not stop stream when it reaches the end
288 slider.show(); 288 slider.show();
289 qDebug( " CONNECT SET POSTION " ); 289 qDebug( " CONNECT SET POSTION " );
290 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 290 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
291 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 291 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
292 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 292 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
293 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 293 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
294 } 294 }
295} 295}
296 296
297 297
298static QString timeAsString( long length ) { 298static QString timeAsString( long length ) {
299 int minutes = length / 60; 299 int minutes = length / 60;
300 int seconds = length % 60; 300 int seconds = length % 60;
301 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 301 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
302} 302}
303 303
304void AudioWidget::updateSlider( long i, long max ) { 304void AudioWidget::updateSlider( long i, long max ) {
305 305
306 time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); 306 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
307// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; 307// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ;
308 308
309 if ( max == 0 ) { 309 if ( max == 0 ) {
310 return; 310 return;
311 } 311 }
312 // Will flicker too much if we don't do this 312 // Will flicker too much if we don't do this
313 // Scale to something reasonable 313 // Scale to something reasonable
314 int width = slider.width(); 314 int width = slider.width();
315 int val = int((double)i * width / max); 315 int val = int((double)i * width / max);
316 if ( !audioSliderBeingMoved ) { 316 if ( !audioSliderBeingMoved ) {
317 if ( slider.value() != val ) { 317 if ( slider.value() != val ) {
318 slider.setValue( val ); 318 slider.setValue( val );
319 } 319 }
320 320
321 if ( slider.maxValue() != width ) { 321 if ( slider.maxValue() != width ) {
322 slider.setMaxValue( width ); 322 slider.setMaxValue( width );
323 } 323 }
324 } 324 }
325} 325}
326 326
327 327
328void AudioWidget::setToggleButton( int i, bool down ) { 328void AudioWidget::setToggleButton( int i, bool down ) {
329 qDebug("setToggleButton %d", i); 329 qDebug("setToggleButton %d", i);
330 if ( down != buttons[i].isDown ) { 330 if ( down != buttons[i].isDown ) {
331 toggleButton( i ); 331 toggleButton( i );
332 } 332 }
333} 333}
334 334
335void AudioWidget::paintButton( QPainter &p, int i ) { 335void AudioWidget::paintButton( QPainter &p, int i ) {
336 if ( buttons[i].isDown ) { 336 if ( buttons[i].isDown ) {
337 p.drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] ); 337 p.drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] );
338 } else { 338 } else {
339 p.drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] ); 339 p.drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] );
340 } 340 }
341} 341}
342 342
343 343
344void AudioWidget::skipFor() { 344void AudioWidget::skipFor() {
345 skipDirection = +1; 345 skipDirection = +1;
346 startTimer( 50 ); 346 startTimer( 50 );
347 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); 347 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
348} 348}
349 349
350void AudioWidget::skipBack() { 350void AudioWidget::skipBack() {
351 skipDirection = -1; 351 skipDirection = -1;
352 startTimer( 50 ); 352 startTimer( 50 );
353 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); 353 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
354} 354}
355 355
356 356
357 357
358void AudioWidget::stopSkip() { 358void AudioWidget::stopSkip() {
359 killTimers(); 359 killTimers();
360} 360}
361 361
362 362
363void AudioWidget::timerEvent( QTimerEvent * ) { 363void AudioWidget::timerEvent( QTimerEvent * ) {
364 if ( skipDirection == +1 ) { 364 if ( skipDirection == +1 ) {
365 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); 365 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
366 } else if ( skipDirection == -1 ) { 366 } else if ( skipDirection == -1 ) {
367 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); 367 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
368 } 368 }
369} 369}
370 370
371 371
372void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 372void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
373 for ( unsigned int i = 0; i < buttons.size(); i++ ) { 373 for ( unsigned int i = 0; i < buttons.size(); i++ ) {
374 if ( event->state() == QMouseEvent::LeftButton ) { 374 if ( event->state() == QMouseEvent::LeftButton ) {
375 // The test to see if the mouse click is inside the button or not 375 // The test to see if the mouse click is inside the button or not
376 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); 376 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i );
377 377
378 if ( isOnButton && !buttons[i].isHeld ) { 378 if ( isOnButton && !buttons[i].isHeld ) {
379 buttons[i].isHeld = TRUE; 379 buttons[i].isHeld = TRUE;
380 toggleButton(i); 380 toggleButton(i);
381 switch (i) { 381 switch (i) {
382 case VolumeUp: 382 case VolumeUp:
383 emit moreClicked(); 383 emit moreClicked();
384 return; 384 return;
385 case VolumeDown: 385 case VolumeDown:
386 emit lessClicked(); 386 emit lessClicked();
387 return; 387 return;
388 case Forward: 388 case Forward:
389 emit forwardClicked(); 389 emit forwardClicked();
390 return; 390 return;
391 case Back: 391 case Back:
392 emit backClicked(); 392 emit backClicked();
393 return; 393 return;
394 } 394 }
395 } else if ( !isOnButton && buttons[i].isHeld ) { 395 } else if ( !isOnButton && buttons[i].isHeld ) {
396 buttons[i].isHeld = FALSE; 396 buttons[i].isHeld = FALSE;
397 toggleButton(i); 397 toggleButton(i);
398 } 398 }
399 } else { 399 } else {
400 if ( buttons[i].isHeld ) { 400 if ( buttons[i].isHeld ) {
401 buttons[i].isHeld = FALSE; 401 buttons[i].isHeld = FALSE;
402 if ( !buttons[i].isToggle ) { 402 if ( !buttons[i].isToggle ) {
403 setToggleButton( i, FALSE ); 403 setToggleButton( i, FALSE );
404 } 404 }
405 qDebug("mouseEvent %d", i); 405 qDebug("mouseEvent %d", i);
406 handleCommand( static_cast<Command>( i ), buttons[ i ].isDown ); 406 handleCommand( static_cast<Command>( i ), buttons[ i ].isDown );
407 } 407 }
408 } 408 }
409 } 409 }
410} 410}
411 411
412 412
413void AudioWidget::mousePressEvent( QMouseEvent *event ) { 413void AudioWidget::mousePressEvent( QMouseEvent *event ) {
414 mouseMoveEvent( event ); 414 mouseMoveEvent( event );
415} 415}
416 416
417 417
418void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 418void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
419 mouseMoveEvent( event ); 419 mouseMoveEvent( event );
420} 420}
421 421
422 422
423void AudioWidget::showEvent( QShowEvent* ) { 423void AudioWidget::showEvent( QShowEvent* ) {
424 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 424 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
425 mouseMoveEvent( &event ); 425 mouseMoveEvent( &event );
426} 426}
427 427
428 428
429void AudioWidget::paintEvent( QPaintEvent * pe ) { 429void AudioWidget::paintEvent( QPaintEvent * pe ) {
430 if ( !pe->erased() ) { 430 if ( !pe->erased() ) {
431 // Combine with background and double buffer 431 // Combine with background and double buffer
432 QPixmap pix( pe->rect().size() ); 432 QPixmap pix( pe->rect().size() );
433 QPainter p( &pix ); 433 QPainter p( &pix );
434 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 434 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
435 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); 435 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() );
436 for ( unsigned int i = 0; i < buttons.size(); i++ ) 436 for ( unsigned int i = 0; i < buttons.size(); i++ )
437 paintButton( p, i ); 437 paintButton( p, i );
438 QPainter p2( this ); 438 QPainter p2( this );
439 p2.drawPixmap( pe->rect().topLeft(), pix ); 439 p2.drawPixmap( pe->rect().topLeft(), pix );
440 } else { 440 } else {
441 QPainter p( this ); 441 QPainter p( this );
442 for ( unsigned int i = 0; i < buttons.size(); i++ ) 442 for ( unsigned int i = 0; i < buttons.size(); i++ )
443 paintButton( p, i ); 443 paintButton( p, i );
444 } 444 }
445} 445}
446 446
447void AudioWidget::keyReleaseEvent( QKeyEvent *e) { 447void AudioWidget::keyReleaseEvent( QKeyEvent *e) {
448 switch ( e->key() ) { 448 switch ( e->key() ) {
449 ////////////////////////////// Zaurus keys 449 ////////////////////////////// Zaurus keys
450 case Key_Home: 450 case Key_Home:
451 break; 451 break;
452 case Key_F9: //activity 452 case Key_F9: //activity
453 hide(); 453 hide();
454 // qDebug("Audio F9"); 454 // qDebug("Audio F9");
455 break; 455 break;
456 case Key_F10: //contacts 456 case Key_F10: //contacts
457 break; 457 break;
458 case Key_F11: //menu 458 case Key_F11: //menu
459 mediaPlayerState.toggleBlank(); 459 mediaPlayerState.toggleBlank();
460 break; 460 break;
461 case Key_F12: //home 461 case Key_F12: //home
462 break; 462 break;
463 case Key_F13: //mail 463 case Key_F13: //mail
464 mediaPlayerState.toggleBlank(); 464 mediaPlayerState.toggleBlank();
465 break; 465 break;
466 case Key_Space: { 466 case Key_Space: {
467 if(mediaPlayerState.isPlaying()) { 467 mediaPlayerState.togglePaused();
468 // toggleButton(1);
469 mediaPlayerState.setPlaying(FALSE);
470 // toggleButton(1);
471 } else {
472 // toggleButton(0);
473 mediaPlayerState.setPlaying(TRUE);
474 // toggleButton(0);
475 }
476 } 468 }
477 break; 469 break;
478 case Key_Down: 470 case Key_Down:
479 // toggleButton(6); 471 // toggleButton(6);
480 emit lessClicked(); 472 emit lessClicked();
481 emit lessReleased(); 473 emit lessReleased();
482 // toggleButton(6); 474 // toggleButton(6);
483 break; 475 break;
484 case Key_Up: 476 case Key_Up:
485 // toggleButton(5); 477 // toggleButton(5);
486 emit moreClicked(); 478 emit moreClicked();
487 emit moreReleased(); 479 emit moreReleased();
488 // toggleButton(5); 480 // toggleButton(5);
489 break; 481 break;
490 case Key_Right: 482 case Key_Right:
491 // toggleButton(3); 483 // toggleButton(3);
492 mediaPlayerState.setNext(); 484 mediaPlayerState.setNext();
493 // toggleButton(3); 485 // toggleButton(3);
494 break; 486 break;
495 case Key_Left: 487 case Key_Left:
496 // toggleButton(4); 488 // toggleButton(4);
497 mediaPlayerState.setPrev(); 489 mediaPlayerState.setPrev();
498 // toggleButton(4); 490 // toggleButton(4);
499 break; 491 break;
500 case Key_Escape: { 492 case Key_Escape: {
501 } 493 }
502 break; 494 break;
503 495
504 }; 496 };
505} 497}