author | simon <simon> | 2002-12-02 20:56:19 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-02 20:56:19 (UTC) |
commit | 649ea9e9586ce51847ebeb9c062290137c9248f4 (patch) (side-by-side diff) | |
tree | 334d6fe0fe91e29ed3600d96443ab104939c1eef | |
parent | 0090a335a7162f4b0d34f78850ebf9a8bd544c01 (diff) | |
download | opie-649ea9e9586ce51847ebeb9c062290137c9248f4.zip opie-649ea9e9586ce51847ebeb9c062290137c9248f4.tar.gz opie-649ea9e9586ce51847ebeb9c062290137c9248f4.tar.bz2 |
- centralized the button command handling into MediaWidget (as it is
duplicated between AudioWidget and VideoWidget -- the latter still to
come though)
-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 @@ -52,4 +52,2 @@ -extern PlayListWidget *playList; - static const int xo = -2; // movable x offset @@ -395,12 +393,12 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { switch (i) { - case AudioVolumeUp: + case VolumeUp: emit moreClicked(); return; - case AudioVolumeDown: + case VolumeDown: emit lessClicked(); return; - case AudioForward: + case Forward: emit forwardClicked(); return; - case AudioBack: + case Back: emit backClicked(); @@ -419,21 +417,3 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { qDebug("mouseEvent %d", i); - switch (i) { - case AudioPlay: - if( mediaPlayerState.isPaused() ) { - mediaPlayerState.setPaused( FALSE ); - return; - } else if( !mediaPlayerState.isPaused() ) { - mediaPlayerState.setPaused( TRUE ); - return; - } - case AudioStop: mediaPlayerState.setPlaying(FALSE); return; - case AudioNext: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; - case AudioPrevious: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; - case AudioLoop: mediaPlayerState.setLooping(audioButtons[i].isDown); return; - case AudioVolumeUp: emit moreReleased(); return; - case AudioVolumeDown: emit lessReleased(); return; - case AudioPlayList: mediaPlayerState.setList(); return; - case AudioForward: emit forwardReleased(); return; - case AudioBack: emit backReleased(); return; - } + handleCommand( static_cast<Command>( i ), audioButtons[ i ].isDown ); } 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 @@ -51,18 +51,2 @@ class QPixmap; -namespace { - -enum AudioButtons { - AudioPlay=0, - AudioStop, - AudioNext, - AudioPrevious, - AudioVolumeUp, - AudioVolumeDown, - AudioLoop, - AudioPlayList, - AudioForward, - AudioBack -}; -}; - class AudioWidget : public MediaWidget { @@ -77,3 +61,3 @@ public slots: void sliderReleased( ); - void setLooping( bool b) { setToggleButton( AudioLoop, b ); } + void setLooping( bool b) { setToggleButton( Loop, b ); } void setPosition( long ); @@ -83,3 +67,3 @@ public: virtual void setLength( long ); - virtual void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } + virtual void setPlaying( bool b) { setToggleButton( Play, b ); } virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); @@ -89,8 +73,4 @@ signals: void lessClicked(); - void moreReleased(); - void lessReleased(); void forwardClicked(); void backClicked(); - void forwardReleased(); - void backReleased(); void sliderMoved(long); 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 @@ -21,4 +21,5 @@ #include "mediawidget.h" +#include "playlistwidget.h" -extern MediaPlayerState *mediaPlayerState; +extern PlayListWidget *playList; @@ -39,2 +40,18 @@ MediaWidget::~MediaWidget() +void MediaWidget::handleCommand( Command command, bool buttonDown ) +{ + switch ( command ) { + case Play: mediaPlayerState.togglePaused(); + case Stop: mediaPlayerState.setPlaying(FALSE); return; + case Next: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; + case Previous: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; + case Loop: mediaPlayerState.setLooping( buttonDown ); return; + case VolumeUp: emit moreReleased(); return; + case VolumeDown: emit lessReleased(); return; + case PlayList: mediaPlayerState.setList(); return; + case Forward: emit forwardReleased(); return; + case Back: emit backReleased(); return; + } +} + /* vim: et sw=4 ts=4 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 @@ -30,2 +30,4 @@ class MediaWidget : public QWidget public: + enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back }; + MediaWidget( MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); @@ -38,3 +40,11 @@ public slots: +signals: + void moreReleased(); + void lessReleased(); + void forwardReleased(); + void backReleased(); + protected: + void handleCommand( Command command, bool buttonDown ); + MediaPlayerState &mediaPlayerState; |