author | simon <simon> | 2002-12-09 16:28:55 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-09 16:28:55 (UTC) |
commit | 3b31b000db15e7618b3ef06a652bae41d87a1348 (patch) (side-by-side diff) | |
tree | 25360f74f235f016d6ca50f2e4b8cc280a2e3a2e | |
parent | eeb797c68aca5cad9989b8438facebee13eede5e (diff) | |
download | opie-3b31b000db15e7618b3ef06a652bae41d87a1348.zip opie-3b31b000db15e7618b3ef06a652bae41d87a1348.tar.gz opie-3b31b000db15e7618b3ef06a652bae41d87a1348.tar.bz2 |
- transition to MediaWidget::Command completed
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 4 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 9 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 33 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 11 |
5 files changed, 30 insertions, 28 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index 092e5ce..9b276b5 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h @@ -50,31 +50,31 @@ class QPixmap; class AudioWidget : public MediaWidget { Q_OBJECT public: AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); ~AudioWidget(); void setTickerText( const QString &text ) { songInfo.setText( text ); } public slots: void updateSlider( long, long ); void sliderPressed( ); void sliderReleased( ); - void setLooping( bool b) { setToggleButton( buttons[ Loop ], b ); } + void setLooping( bool b) { setToggleButton( Loop, b ); } void setPosition( long ); void setSeekable( bool ); public: virtual void setLength( long ); - virtual void setPlaying( bool b) { setToggleButton( buttons[ Play ], b ); } + virtual void setPlaying( bool b) { setToggleButton( Play, b ); } virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); signals: void moreClicked(); void lessClicked(); void forwardClicked(); void backClicked(); void sliderMoved(long); protected: void doBlank(); void doUnblank(); diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp index 7891a7e..c0ebd63 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.cpp +++ b/noncore/multimedia/opieplayer2/mediawidget.cpp @@ -106,24 +106,33 @@ void MediaWidget::paintButton( const Button &button ) QPainter p( this ); paintButton( p, button ); } void MediaWidget::paintButton( QPainter &p, const Button &button ) { if ( button.isDown ) p.drawPixmap( upperLeftOfButtonMask, button.pixDown ); else p.drawPixmap( upperLeftOfButtonMask, button.pixUp ); } +void MediaWidget::setToggleButton( Command command, bool down ) +{ + for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) + if ( it->command == command ) { + setToggleButton( *it, down ); + return; + } +} + void MediaWidget::setToggleButton( Button &button, bool down ) { if ( down != button.isDown ) toggleButton( button ); } void MediaWidget::toggleButton( Button &button ) { button.isDown = !button.isDown; paintButton( button ); } diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h index 3bf01b6..caae0a7 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.h +++ b/noncore/multimedia/opieplayer2/mediawidget.h @@ -83,24 +83,25 @@ protected: virtual void paintEvent( QPaintEvent *pe ); void handleCommand( Command command, bool buttonDown ); bool isOverButton( const QPoint &position, int buttonId ) const; void paintAllButtons( QPainter &p ); void paintButton( const Button &button ); void paintButton( QPainter &p, const Button &button ); void setToggleButton( Button &button, bool down ); + void setToggleButton( Command command, bool down ); void toggleButton( Button &button ); MediaPlayerState &mediaPlayerState; PlayListWidget &playList; ButtonVector buttons; QImage buttonMask; QPoint upperLeftOfButtonMask; QPixmap backgroundPixmap; diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 4867ef1..06f6cd2 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp @@ -103,25 +103,25 @@ VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye button.type = skinInfo[ i ].type; QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinInfo[i].fileName + ".png" ); button.mask =QBitmap( filename ); if ( !button.mask.isNull() ) { QImage imgMask = button.mask.convertToImage(); uchar **dest = buttonMask.jumpTable(); for ( int y = 0; y < imgUp.height(); y++ ) { uchar *line = dest[y]; for ( int x = 0; x < imgUp.width(); x++ ) if ( !qRed( imgMask.pixel( x, y ) ) ) - line[x] = i + 1; + line[x] = button.command + 1; } } buttons.push_back( button ); } setBackgroundPixmap( backgroundPixmap ); slider = new QSlider( Qt::Horizontal, this ); slider->setMinValue( 0 ); slider->setMaxValue( 1 ); slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); @@ -238,75 +238,78 @@ void VideoWidget::updateSlider( long i, long max ) { slider->setValue( val ); } if ( slider->maxValue() != width ) { slider->setMaxValue( width ); } } } void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { for ( unsigned int i = 0; i < buttons.size(); i++ ) { Button &button = buttons[ i ]; + Command command = button.command; if ( event->state() == QMouseEvent::LeftButton ) { // The test to see if the mouse click is inside the button or not - bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); + bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, command ); if ( isOnButton && !button.isHeld ) { button.isHeld = TRUE; toggleButton( button ); - switch (i) { - case VideoVolUp: + switch ( command ) { + case VolumeUp: emit moreClicked(); return; - case VideoVolDown: + case VolumeDown: emit lessClicked(); return; + default: break; } } else if ( !isOnButton && button.isHeld ) { button.isHeld = FALSE; toggleButton( button ); } } else { if ( button.isHeld ) { button.isHeld = FALSE; if ( button.type != ToggleButton ) { setToggleButton( button, FALSE ); } - switch(i) { + switch( command ) { - case VideoPlay: { + case Play: { if( mediaPlayerState.isPaused() ) { setToggleButton( button, FALSE ); mediaPlayerState.setPaused( FALSE ); return; } else if( !mediaPlayerState.isPaused() ) { setToggleButton( button, TRUE ); mediaPlayerState.setPaused( TRUE ); return; } else { return; } } - case VideoStop: mediaPlayerState.setPlaying( FALSE ); return; - case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; - case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; - case VideoVolUp: emit moreReleased(); return; - case VideoVolDown: emit lessReleased(); return; - case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return; + 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 VolumeUp: emit moreReleased(); return; + case VolumeDown: emit lessReleased(); return; + case FullScreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return; + default: break; } } } } } void VideoWidget::mousePressEvent( QMouseEvent *event ) { mouseMoveEvent( event ); } void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { if ( mediaPlayerState.isFullscreen() ) { @@ -418,20 +421,20 @@ void VideoWidget::keyReleaseEvent( QKeyEvent *e) { case Key_Escape: break; }; } XineVideoWidget* VideoWidget::vidWidget() { return videoFrame; } void VideoWidget::setFullscreen ( bool b ) { - setToggleButton( buttons[ VideoFullscreen ], b ); + setToggleButton( FullScreen, b ); } void VideoWidget::setPlaying( bool b) { - setToggleButton( buttons[ VideoPlay ], b ); + setToggleButton( Play, b ); } diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index 915e9cc..c3bc131 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h @@ -35,35 +35,24 @@ #define VIDEO_WIDGET_H #include <qwidget.h> #include <qimage.h> #include <qpixmap.h> #include "xinevideowidget.h" #include "mediawidget.h" class QPixmap; class QSlider; -enum VideoButtons { - VideoPlay = 0, - VideoStop, -// VideoPause, - VideoNext, - VideoPrevious, - VideoVolUp, - VideoVolDown, - VideoFullscreen -}; - class VideoWidget : public MediaWidget { Q_OBJECT public: VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); ~VideoWidget(); XineVideoWidget* vidWidget(); public slots: void updateSlider( long, long ); void sliderPressed( ); void sliderReleased( ); |