-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 30 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 24 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 19 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 10 |
4 files changed, 35 insertions, 48 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 ) { |
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index 087d711..1778a30 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h | |||
@@ -40,68 +40,48 @@ | |||
40 | #include <qstring.h> | 40 | #include <qstring.h> |
41 | #include <qslider.h> | 41 | #include <qslider.h> |
42 | #include <qframe.h> | 42 | #include <qframe.h> |
43 | #include <qlineedit.h> | 43 | #include <qlineedit.h> |
44 | #include <qimage.h> | 44 | #include <qimage.h> |
45 | 45 | ||
46 | #include <opie/oticker.h> | 46 | #include <opie/oticker.h> |
47 | 47 | ||
48 | #include "mediawidget.h" | 48 | #include "mediawidget.h" |
49 | 49 | ||
50 | class QPixmap; | 50 | class QPixmap; |
51 | 51 | ||
52 | namespace { | ||
53 | |||
54 | enum AudioButtons { | ||
55 | AudioPlay=0, | ||
56 | AudioStop, | ||
57 | AudioNext, | ||
58 | AudioPrevious, | ||
59 | AudioVolumeUp, | ||
60 | AudioVolumeDown, | ||
61 | AudioLoop, | ||
62 | AudioPlayList, | ||
63 | AudioForward, | ||
64 | AudioBack | ||
65 | }; | ||
66 | }; | ||
67 | |||
68 | class AudioWidget : public MediaWidget { | 52 | class AudioWidget : public MediaWidget { |
69 | Q_OBJECT | 53 | Q_OBJECT |
70 | public: | 54 | public: |
71 | AudioWidget( MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); | 55 | AudioWidget( MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); |
72 | ~AudioWidget(); | 56 | ~AudioWidget(); |
73 | void setTickerText( const QString &text ) { songInfo.setText( text ); } | 57 | void setTickerText( const QString &text ) { songInfo.setText( text ); } |
74 | public slots: | 58 | public slots: |
75 | void updateSlider( long, long ); | 59 | void updateSlider( long, long ); |
76 | void sliderPressed( ); | 60 | void sliderPressed( ); |
77 | void sliderReleased( ); | 61 | void sliderReleased( ); |
78 | void setLooping( bool b) { setToggleButton( AudioLoop, b ); } | 62 | void setLooping( bool b) { setToggleButton( Loop, b ); } |
79 | void setPosition( long ); | 63 | void setPosition( long ); |
80 | void setSeekable( bool ); | 64 | void setSeekable( bool ); |
81 | 65 | ||
82 | public: | 66 | public: |
83 | virtual void setLength( long ); | 67 | virtual void setLength( long ); |
84 | virtual void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } | 68 | virtual void setPlaying( bool b) { setToggleButton( Play, b ); } |
85 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); | 69 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); |
86 | 70 | ||
87 | signals: | 71 | signals: |
88 | void moreClicked(); | 72 | void moreClicked(); |
89 | void lessClicked(); | 73 | void lessClicked(); |
90 | void moreReleased(); | ||
91 | void lessReleased(); | ||
92 | void forwardClicked(); | 74 | void forwardClicked(); |
93 | void backClicked(); | 75 | void backClicked(); |
94 | void forwardReleased(); | ||
95 | void backReleased(); | ||
96 | void sliderMoved(long); | 76 | void sliderMoved(long); |
97 | 77 | ||
98 | protected: | 78 | protected: |
99 | void doBlank(); | 79 | void doBlank(); |
100 | void doUnblank(); | 80 | void doUnblank(); |
101 | void paintEvent( QPaintEvent *pe ); | 81 | void paintEvent( QPaintEvent *pe ); |
102 | void showEvent( QShowEvent *se ); | 82 | void showEvent( QShowEvent *se ); |
103 | void resizeEvent( QResizeEvent *re ); | 83 | void resizeEvent( QResizeEvent *re ); |
104 | void mouseMoveEvent( QMouseEvent *event ); | 84 | void mouseMoveEvent( QMouseEvent *event ); |
105 | void mousePressEvent( QMouseEvent *event ); | 85 | void mousePressEvent( QMouseEvent *event ); |
106 | void mouseReleaseEvent( QMouseEvent *event ); | 86 | void mouseReleaseEvent( QMouseEvent *event ); |
107 | void timerEvent( QTimerEvent *event ); | 87 | void timerEvent( QTimerEvent *event ); |
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp index d58e87e..01a7295 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.cpp +++ b/noncore/multimedia/opieplayer2/mediawidget.cpp | |||
@@ -10,32 +10,49 @@ | |||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | 20 | ||
21 | #include "mediawidget.h" | 21 | #include "mediawidget.h" |
22 | #include "playlistwidget.h" | ||
22 | 23 | ||
23 | extern MediaPlayerState *mediaPlayerState; | 24 | extern PlayListWidget *playList; |
24 | 25 | ||
25 | MediaWidget::MediaWidget( MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) | 26 | MediaWidget::MediaWidget( MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) |
26 | : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ) | 27 | : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ) |
27 | { | 28 | { |
28 | connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), | 29 | connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), |
29 | this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); | 30 | this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); |
30 | connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), | 31 | connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), |
31 | this, SLOT( setLength( long ) ) ); | 32 | this, SLOT( setLength( long ) ) ); |
32 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 33 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), |
33 | this, SLOT( setPlaying( bool ) ) ); | 34 | this, SLOT( setPlaying( bool ) ) ); |
34 | } | 35 | } |
35 | 36 | ||
36 | MediaWidget::~MediaWidget() | 37 | MediaWidget::~MediaWidget() |
37 | { | 38 | { |
38 | } | 39 | } |
39 | 40 | ||
41 | void MediaWidget::handleCommand( Command command, bool buttonDown ) | ||
42 | { | ||
43 | switch ( command ) { | ||
44 | case Play: mediaPlayerState.togglePaused(); | ||
45 | case Stop: mediaPlayerState.setPlaying(FALSE); return; | ||
46 | case Next: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; | ||
47 | case Previous: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; | ||
48 | case Loop: mediaPlayerState.setLooping( buttonDown ); return; | ||
49 | case VolumeUp: emit moreReleased(); return; | ||
50 | case VolumeDown: emit lessReleased(); return; | ||
51 | case PlayList: mediaPlayerState.setList(); return; | ||
52 | case Forward: emit forwardReleased(); return; | ||
53 | case Back: emit backReleased(); return; | ||
54 | } | ||
55 | } | ||
56 | |||
40 | /* vim: et sw=4 ts=4 | 57 | /* vim: et sw=4 ts=4 |
41 | */ | 58 | */ |
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h index 64adba9..550f0fc 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.h +++ b/noncore/multimedia/opieplayer2/mediawidget.h | |||
@@ -19,27 +19,37 @@ | |||
19 | 19 | ||
20 | #ifndef MEDIAWIDGET_H | 20 | #ifndef MEDIAWIDGET_H |
21 | #define MEDIAWIDGET_H | 21 | #define MEDIAWIDGET_H |
22 | 22 | ||
23 | #include <qwidget.h> | 23 | #include <qwidget.h> |
24 | 24 | ||
25 | #include "mediaplayerstate.h" | 25 | #include "mediaplayerstate.h" |
26 | 26 | ||
27 | class MediaWidget : public QWidget | 27 | class MediaWidget : public QWidget |
28 | { | 28 | { |
29 | Q_OBJECT | 29 | Q_OBJECT |
30 | public: | 30 | public: |
31 | enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back }; | ||
32 | |||
31 | MediaWidget( MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); | 33 | MediaWidget( MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); |
32 | virtual ~MediaWidget(); | 34 | virtual ~MediaWidget(); |
33 | 35 | ||
34 | public slots: | 36 | public slots: |
35 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; | 37 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; |
36 | virtual void setLength( long length ) = 0; | 38 | virtual void setLength( long length ) = 0; |
37 | virtual void setPlaying( bool playing ) = 0; | 39 | virtual void setPlaying( bool playing ) = 0; |
38 | 40 | ||
41 | signals: | ||
42 | void moreReleased(); | ||
43 | void lessReleased(); | ||
44 | void forwardReleased(); | ||
45 | void backReleased(); | ||
46 | |||
39 | protected: | 47 | protected: |
48 | void handleCommand( Command command, bool buttonDown ); | ||
49 | |||
40 | MediaPlayerState &mediaPlayerState; | 50 | MediaPlayerState &mediaPlayerState; |
41 | }; | 51 | }; |
42 | 52 | ||
43 | #endif // MEDIAWIDGET_H | 53 | #endif // MEDIAWIDGET_H |
44 | /* vim: et sw=4 ts=4 | 54 | /* vim: et sw=4 ts=4 |
45 | */ | 55 | */ |