author | simon <simon> | 2002-12-02 22:51:21 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-02 22:51:21 (UTC) |
commit | b3bf297da8836a678a21f2ebe83e0f1961f91d97 (patch) (side-by-side diff) | |
tree | fa5fa20421d833816d355c109458661b2f245177 | |
parent | 649ea9e9586ce51847ebeb9c062290137c9248f4 (diff) | |
download | opie-b3bf297da8836a678a21f2ebe83e0f1961f91d97.zip opie-b3bf297da8836a678a21f2ebe83e0f1961f91d97.tar.gz opie-b3bf297da8836a678a21f2ebe83e0f1961f91d97.tar.bz2 |
- centralized closeEvent implementation
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 5 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 5 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 5 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 1 |
6 files changed, 7 insertions, 12 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 3070bc3..f6e6086 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp @@ -417,53 +417,48 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { qDebug("mouseEvent %d", i); handleCommand( static_cast<Command>( i ), audioButtons[ i ].isDown ); } } } } void AudioWidget::mousePressEvent( QMouseEvent *event ) { mouseMoveEvent( event ); } void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { mouseMoveEvent( event ); } void AudioWidget::showEvent( QShowEvent* ) { QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); mouseMoveEvent( &event ); } -void AudioWidget::closeEvent( QCloseEvent* ) { - mediaPlayerState.setList(); -} - - void AudioWidget::paintEvent( QPaintEvent * pe ) { if ( !pe->erased() ) { // Combine with background and double buffer QPixmap pix( pe->rect().size() ); QPainter p( &pix ); p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); for ( int i = 0; i < numButtons; i++ ) paintButton( &p, i ); QPainter p2( this ); p2.drawPixmap( pe->rect().topLeft(), pix ); } else { QPainter p( this ); for ( int i = 0; i < numButtons; i++ ) paintButton( &p, i ); } } void AudioWidget::keyReleaseEvent( QKeyEvent *e) { switch ( e->key() ) { ////////////////////////////// Zaurus keys case Key_Home: break; case Key_F9: //activity diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index 1778a30..f092699 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h @@ -64,49 +64,48 @@ public slots: void setSeekable( bool ); public: virtual void setLength( long ); 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(); void paintEvent( QPaintEvent *pe ); void showEvent( QShowEvent *se ); void resizeEvent( QResizeEvent *re ); void mouseMoveEvent( QMouseEvent *event ); void mousePressEvent( QMouseEvent *event ); void mouseReleaseEvent( QMouseEvent *event ); void timerEvent( QTimerEvent *event ); - void closeEvent( QCloseEvent *event ); void keyReleaseEvent( QKeyEvent *e); private slots: void skipFor(); void skipBack(); void stopSkip(); private: void toggleButton( int ); void setToggleButton( int, bool ); void paintButton( QPainter *p, int i ); int skipDirection; QString skin; QPixmap pixBg; QImage imgUp; QImage imgDn; QImage imgButtonMask; QBitmap *masks[10]; QPixmap *buttonPixUp[10]; QPixmap *buttonPixDown[10]; QPixmap *pixmaps[4]; OTicker songInfo; QSlider slider; QLineEdit time; int xoff, yoff; diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp index 01a7295..2992fd6 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.cpp +++ b/noncore/multimedia/opieplayer2/mediawidget.cpp @@ -17,42 +17,47 @@ Boston, MA 02111-1307, USA. */ #include "mediawidget.h" #include "playlistwidget.h" extern PlayListWidget *playList; MediaWidget::MediaWidget( MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ) { connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), this, SLOT( setLength( long ) ) ); connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); } MediaWidget::~MediaWidget() { } +void MediaWidget::closeEvent( QCloseEvent * ) +{ + mediaPlayerState.setList(); +} + 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 550f0fc..e3f09ce 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.h +++ b/noncore/multimedia/opieplayer2/mediawidget.h @@ -24,32 +24,34 @@ #include "mediaplayerstate.h" class MediaWidget : public QWidget { Q_OBJECT public: enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back }; MediaWidget( MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); virtual ~MediaWidget(); public slots: virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; virtual void setLength( long length ) = 0; virtual void setPlaying( bool playing ) = 0; signals: void moreReleased(); void lessReleased(); void forwardReleased(); void backReleased(); protected: + virtual void closeEvent( QCloseEvent * ); + void handleCommand( Command command, bool buttonDown ); MediaPlayerState &mediaPlayerState; }; #endif // MEDIAWIDGET_H /* vim: et sw=4 ts=4 */ diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index b4ecb4c..41dddb7 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp @@ -426,53 +426,48 @@ void VideoWidget::paintEvent( QPaintEvent * pe) { // Clear the background p.setBrush( QBrush( Qt::black ) ); } else { if ( !pe->erased() ) { // Combine with background and double buffer QPixmap pix( pe->rect().size() ); QPainter p( &pix ); p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); for ( int i = 0; i < numVButtons; i++ ) { paintButton( &p, i ); } QPainter p2( this ); p2.drawPixmap( pe->rect().topLeft(), pix ); } else { QPainter p( this ); for ( int i = 0; i < numVButtons; i++ ) paintButton( &p, i ); } //slider->repaint( TRUE ); } } -void VideoWidget::closeEvent( QCloseEvent* ) { - mediaPlayerState.setList(); -} - - void VideoWidget::keyReleaseEvent( QKeyEvent *e) { switch ( e->key() ) { ////////////////////////////// Zaurus keys case Key_Home: break; case Key_F9: //activity break; case Key_F10: //contacts // hide(); break; case Key_F11: //menu break; case Key_F12: //home break; case Key_F13: //mail break; case Key_Space: { if(mediaPlayerState.isPlaying()) { mediaPlayerState.setPlaying(FALSE); } else { mediaPlayerState.setPlaying(TRUE); } } break; diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index 38eb726..149c78e 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h @@ -70,49 +70,48 @@ public slots: void backToNormal(); void setPosition( long ); public: virtual void setPlaying( bool b); virtual void setLength( long ); virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); signals: void moreClicked(); void lessClicked(); void moreReleased(); void lessReleased(); void sliderMoved( long ); void videoResized ( const QSize &s ); protected: void resizeEvent( QResizeEvent * ); void paintEvent( QPaintEvent *pe ); void showEvent( QShowEvent *se ); void mouseMoveEvent( QMouseEvent *event ); void mousePressEvent( QMouseEvent *event ); void mouseReleaseEvent( QMouseEvent *event ); - void closeEvent( QCloseEvent *event ); void keyReleaseEvent( QKeyEvent *e); private: // Ticker songInfo; QPixmap *pixBg; QImage *imgUp; QImage *imgDn; QImage *imgButtonMask; QBitmap *masks[7]; QPixmap *buttonPixUp[7]; QPixmap *buttonPixDown[7]; QString skin; // QPixmap *pixmaps[4]; int xoff, yoff; void paintButton( QPainter *p, int i ); void toggleButton( int ); void setToggleButton( int, bool ); QString backgroundPix; QSlider *slider; QPixmap *pixmaps[3]; QImage *currentFrame; |