summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-09 16:39:32 (UTC)
committer simon <simon>2002-12-09 16:39:32 (UTC)
commit1bb6aa52f2db85f65f75278310c328218caeae65 (patch) (unidiff)
tree1983547bac0da80bde93554038a57713feb715c1
parent1ae041fba55e218a2523de441bec6ec3a1eecf02 (diff)
downloadopie-1bb6aa52f2db85f65f75278310c328218caeae65.zip
opie-1bb6aa52f2db85f65f75278310c328218caeae65.tar.gz
opie-1bb6aa52f2db85f65f75278310c328218caeae65.tar.bz2
- removing duplicated code in VideoWidget
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp5
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h2
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp25
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h4
4 files changed, 9 insertions, 27 deletions
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index c0ebd63..7eb75e6 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -60,37 +60,42 @@ void MediaWidget::paintEvent( QPaintEvent *pe )
60 QPainter p( &pix ); 60 QPainter p( &pix );
61 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 61 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
62 p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() ); 62 p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() );
63 paintAllButtons( p ); 63 paintAllButtons( p );
64 QPainter p2( this ); 64 QPainter p2( this );
65 p2.drawPixmap( pe->rect().topLeft(), pix ); 65 p2.drawPixmap( pe->rect().topLeft(), pix );
66 } else { 66 } else {
67 QPainter p( this ); 67 QPainter p( this );
68 paintAllButtons( p ); 68 paintAllButtons( p );
69 } 69 }
70} 70}
71 71
72void MediaWidget::makeVisible()
73{
74}
75
72void MediaWidget::handleCommand( Command command, bool buttonDown ) 76void MediaWidget::handleCommand( Command command, bool buttonDown )
73{ 77{
74 switch ( command ) { 78 switch ( command ) {
75 case Play: mediaPlayerState.togglePaused(); 79 case Play: mediaPlayerState.togglePaused();
76 case Stop: mediaPlayerState.setPlaying(FALSE); return; 80 case Stop: mediaPlayerState.setPlaying(FALSE); return;
77 case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; 81 case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
78 case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; 82 case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
79 case Loop: mediaPlayerState.setLooping( buttonDown ); return; 83 case Loop: mediaPlayerState.setLooping( buttonDown ); return;
80 case VolumeUp: emit moreReleased(); return; 84 case VolumeUp: emit moreReleased(); return;
81 case VolumeDown: emit lessReleased(); return; 85 case VolumeDown: emit lessReleased(); return;
82 case PlayList: mediaPlayerState.setList(); return; 86 case PlayList: mediaPlayerState.setList(); return;
83 case Forward: emit forwardReleased(); return; 87 case Forward: emit forwardReleased(); return;
84 case Back: emit backReleased(); return; 88 case Back: emit backReleased(); return;
89 case FullScreen: mediaPlayerState.setFullscreen( true ); makeVisible(); return;
85 default: assert( false ); 90 default: assert( false );
86 } 91 }
87} 92}
88 93
89bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const 94bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const
90{ 95{
91 return ( position.x() > 0 && position.y() > 0 && 96 return ( position.x() > 0 && position.y() > 0 &&
92 position.x() < buttonMask.width() && 97 position.x() < buttonMask.width() &&
93 position.y() < buttonMask.height() && 98 position.y() < buttonMask.height() &&
94 buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); 99 buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 );
95} 100}
96 101
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index caae0a7..3f4c45d 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -74,24 +74,26 @@ public slots:
74 74
75signals: 75signals:
76 void moreReleased(); 76 void moreReleased();
77 void lessReleased(); 77 void lessReleased();
78 void forwardReleased(); 78 void forwardReleased();
79 void backReleased(); 79 void backReleased();
80 80
81protected: 81protected:
82 virtual void closeEvent( QCloseEvent * ); 82 virtual void closeEvent( QCloseEvent * );
83 83
84 virtual void paintEvent( QPaintEvent *pe ); 84 virtual void paintEvent( QPaintEvent *pe );
85 85
86 virtual void makeVisible();
87
86 void handleCommand( Command command, bool buttonDown ); 88 void handleCommand( Command command, bool buttonDown );
87 89
88 bool isOverButton( const QPoint &position, int buttonId ) const; 90 bool isOverButton( const QPoint &position, int buttonId ) const;
89 91
90 void paintAllButtons( QPainter &p ); 92 void paintAllButtons( QPainter &p );
91 void paintButton( const Button &button ); 93 void paintButton( const Button &button );
92 void paintButton( QPainter &p, const Button &button ); 94 void paintButton( QPainter &p, const Button &button );
93 95
94 void setToggleButton( Button &button, bool down ); 96 void setToggleButton( Button &button, bool down );
95 void setToggleButton( Command command, bool down ); 97 void setToggleButton( Command command, bool down );
96 void toggleButton( Button &button ); 98 void toggleButton( Button &button );
97 99
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 12316f8..cc586cc 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -268,48 +268,25 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
268 } else if ( !isOnButton && button.isHeld ) { 268 } else if ( !isOnButton && button.isHeld ) {
269 button.isHeld = FALSE; 269 button.isHeld = FALSE;
270 toggleButton( button ); 270 toggleButton( button );
271 } 271 }
272 } else { 272 } else {
273 273
274 if ( button.isHeld ) { 274 if ( button.isHeld ) {
275 button.isHeld = FALSE; 275 button.isHeld = FALSE;
276 if ( button.type != ToggleButton ) { 276 if ( button.type != ToggleButton ) {
277 setToggleButton( button, FALSE ); 277 setToggleButton( button, FALSE );
278 } 278 }
279 279
280 switch( command ) { 280 handleCommand( command, button.isDown );
281
282 case Play: {
283 if( mediaPlayerState.isPaused() ) {
284 setToggleButton( button, FALSE );
285 mediaPlayerState.setPaused( FALSE );
286 return;
287 } else if( !mediaPlayerState.isPaused() ) {
288 setToggleButton( button, TRUE );
289 mediaPlayerState.setPaused( TRUE );
290 return;
291 } else {
292 return;
293 }
294 }
295
296 case Stop: mediaPlayerState.setPlaying( FALSE ); return;
297 case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
298 case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
299 case VolumeUp: emit moreReleased(); return;
300 case VolumeDown: emit lessReleased(); return;
301 case FullScreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return;
302 default: break;
303 }
304 } 281 }
305 } 282 }
306 } 283 }
307} 284}
308 285
309void VideoWidget::mousePressEvent( QMouseEvent *event ) { 286void VideoWidget::mousePressEvent( QMouseEvent *event ) {
310 mouseMoveEvent( event ); 287 mouseMoveEvent( event );
311} 288}
312 289
313void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 290void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
314 if ( mediaPlayerState.isFullscreen() ) { 291 if ( mediaPlayerState.isFullscreen() ) {
315 mediaPlayerState.setFullscreen( FALSE ); 292 mediaPlayerState.setFullscreen( FALSE );
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index c3bc131..ef88186 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -48,38 +48,36 @@ class VideoWidget : public MediaWidget {
48 Q_OBJECT 48 Q_OBJECT
49public: 49public:
50 VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); 50 VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 );
51 ~VideoWidget(); 51 ~VideoWidget();
52 52
53 53
54 XineVideoWidget* vidWidget(); 54 XineVideoWidget* vidWidget();
55public slots: 55public slots:
56 void updateSlider( long, long ); 56 void updateSlider( long, long );
57 void sliderPressed( ); 57 void sliderPressed( );
58 void sliderReleased( ); 58 void sliderReleased( );
59 void setFullscreen( bool b ); 59 void setFullscreen( bool b );
60 void makeVisible(); 60 virtual void makeVisible();
61 void backToNormal(); 61 void backToNormal();
62 void setPosition( long ); 62 void setPosition( long );
63 63
64public: 64public:
65 virtual void setPlaying( bool b); 65 virtual void setPlaying( bool b);
66 virtual void setLength( long ); 66 virtual void setLength( long );
67 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); 67 virtual void setDisplayType( MediaPlayerState::DisplayType displayType );
68 68
69signals: 69signals:
70 void moreClicked(); 70 void moreClicked();
71 void lessClicked(); 71 void lessClicked();
72 void moreReleased();
73 void lessReleased();
74 void sliderMoved( long ); 72 void sliderMoved( long );
75 void videoResized ( const QSize &s ); 73 void videoResized ( const QSize &s );
76 74
77protected: 75protected:
78 76
79 void resizeEvent( QResizeEvent * ); 77 void resizeEvent( QResizeEvent * );
80 void showEvent( QShowEvent *se ); 78 void showEvent( QShowEvent *se );
81 void mouseMoveEvent( QMouseEvent *event ); 79 void mouseMoveEvent( QMouseEvent *event );
82 void mousePressEvent( QMouseEvent *event ); 80 void mousePressEvent( QMouseEvent *event );
83 void mouseReleaseEvent( QMouseEvent *event ); 81 void mouseReleaseEvent( QMouseEvent *event );
84 void keyReleaseEvent( QKeyEvent *e); 82 void keyReleaseEvent( QKeyEvent *e);
85 83