Diffstat (limited to 'noncore/multimedia/opieplayer2/audiowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 30 |
1 files changed, 5 insertions, 25 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index d9beb90..3070bc3 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -41,26 +41,24 @@ | |||
41 | #include <qbutton.h> | 41 | #include <qbutton.h> |
42 | #include <qpainter.h> | 42 | #include <qpainter.h> |
43 | #include <qframe.h> | 43 | #include <qframe.h> |
44 | #include <qlayout.h> | 44 | #include <qlayout.h> |
45 | #include <qdir.h> | 45 | #include <qdir.h> |
46 | #include <stdlib.h> | 46 | #include <stdlib.h> |
47 | #include <stdio.h> | 47 | #include <stdio.h> |
48 | 48 | ||
49 | #include "audiowidget.h" | 49 | #include "audiowidget.h" |
50 | #include "mediaplayerstate.h" | 50 | #include "mediaplayerstate.h" |
51 | #include "playlistwidget.h" | 51 | #include "playlistwidget.h" |
52 | 52 | ||
53 | extern PlayListWidget *playList; | ||
54 | |||
55 | static const int xo = -2; // movable x offset | 53 | static const int xo = -2; // movable x offset |
56 | static const int yo = 22; // movable y offset | 54 | static const int yo = 22; // movable y offset |
57 | 55 | ||
58 | struct MediaButton { | 56 | struct MediaButton { |
59 | bool isToggle, isHeld, isDown; | 57 | bool isToggle, isHeld, isDown; |
60 | }; | 58 | }; |
61 | 59 | ||
62 | //Layout information for the audioButtons (and if it is a toggle button or not) | 60 | //Layout information for the audioButtons (and if it is a toggle button or not) |
63 | MediaButton audioButtons[] = { | 61 | MediaButton audioButtons[] = { |
64 | { TRUE, FALSE, FALSE }, // play | 62 | { TRUE, FALSE, FALSE }, // play |
65 | { FALSE, FALSE, FALSE }, // stop | 63 | { FALSE, FALSE, FALSE }, // stop |
66 | { FALSE, FALSE, FALSE }, // next | 64 | { FALSE, FALSE, FALSE }, // next |
@@ -384,67 +382,49 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
384 | // The test to see if the mouse click is inside the button or not | 382 | // The test to see if the mouse click is inside the button or not |
385 | int x = event->pos().x() - xoff; | 383 | int x = event->pos().x() - xoff; |
386 | int y = event->pos().y() - yoff; | 384 | int y = event->pos().y() - yoff; |
387 | 385 | ||
388 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width() | 386 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width() |
389 | && y < imgButtonMask.height() | 387 | && y < imgButtonMask.height() |
390 | && imgButtonMask.pixelIndex( x, y ) == i + 1 ); | 388 | && imgButtonMask.pixelIndex( x, y ) == i + 1 ); |
391 | 389 | ||
392 | if ( isOnButton && !audioButtons[i].isHeld ) { | 390 | if ( isOnButton && !audioButtons[i].isHeld ) { |
393 | audioButtons[i].isHeld = TRUE; | 391 | audioButtons[i].isHeld = TRUE; |
394 | toggleButton(i); | 392 | toggleButton(i); |
395 | switch (i) { | 393 | switch (i) { |
396 | case AudioVolumeUp: | 394 | case VolumeUp: |
397 | emit moreClicked(); | 395 | emit moreClicked(); |
398 | return; | 396 | return; |
399 | case AudioVolumeDown: | 397 | case VolumeDown: |
400 | emit lessClicked(); | 398 | emit lessClicked(); |
401 | return; | 399 | return; |
402 | case AudioForward: | 400 | case Forward: |
403 | emit forwardClicked(); | 401 | emit forwardClicked(); |
404 | return; | 402 | return; |
405 | case AudioBack: | 403 | case Back: |
406 | emit backClicked(); | 404 | emit backClicked(); |
407 | return; | 405 | return; |
408 | } | 406 | } |
409 | } else if ( !isOnButton && audioButtons[i].isHeld ) { | 407 | } else if ( !isOnButton && audioButtons[i].isHeld ) { |
410 | audioButtons[i].isHeld = FALSE; | 408 | audioButtons[i].isHeld = FALSE; |
411 | toggleButton(i); | 409 | toggleButton(i); |
412 | } | 410 | } |
413 | } else { | 411 | } else { |
414 | if ( audioButtons[i].isHeld ) { | 412 | if ( audioButtons[i].isHeld ) { |
415 | audioButtons[i].isHeld = FALSE; | 413 | audioButtons[i].isHeld = FALSE; |
416 | if ( !audioButtons[i].isToggle ) { | 414 | if ( !audioButtons[i].isToggle ) { |
417 | setToggleButton( i, FALSE ); | 415 | setToggleButton( i, FALSE ); |
418 | } | 416 | } |
419 | qDebug("mouseEvent %d", i); | 417 | qDebug("mouseEvent %d", i); |
420 | switch (i) { | 418 | handleCommand( static_cast<Command>( i ), audioButtons[ i ].isDown ); |
421 | case AudioPlay: | ||
422 | if( mediaPlayerState.isPaused() ) { | ||
423 | mediaPlayerState.setPaused( FALSE ); | ||
424 | return; | ||
425 | } else if( !mediaPlayerState.isPaused() ) { | ||
426 | mediaPlayerState.setPaused( TRUE ); | ||
427 | return; | ||
428 | } | ||
429 | case AudioStop: mediaPlayerState.setPlaying(FALSE); return; | ||
430 | case AudioNext: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; | ||
431 | case AudioPrevious: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; | ||
432 | case AudioLoop: mediaPlayerState.setLooping(audioButtons[i].isDown); return; | ||
433 | case AudioVolumeUp: emit moreReleased(); return; | ||
434 | case AudioVolumeDown: emit lessReleased(); return; | ||
435 | case AudioPlayList: mediaPlayerState.setList(); return; | ||
436 | case AudioForward: emit forwardReleased(); return; | ||
437 | case AudioBack: emit backReleased(); return; | ||
438 | } | ||
439 | } | 419 | } |
440 | } | 420 | } |
441 | } | 421 | } |
442 | } | 422 | } |
443 | 423 | ||
444 | 424 | ||
445 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 425 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
446 | mouseMoveEvent( event ); | 426 | mouseMoveEvent( event ); |
447 | } | 427 | } |
448 | 428 | ||
449 | 429 | ||
450 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | 430 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { |