summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-09 16:45:41 (UTC)
committer simon <simon>2002-12-09 16:45:41 (UTC)
commitdbe0046eb82c8ee61ce7fc704d3b376730abc17f (patch) (side-by-side diff)
treed8729a7844dc889024090afe1ffac1c6f3a3ab1b
parent1bb6aa52f2db85f65f75278310c328218caeae65 (diff)
downloadopie-dbe0046eb82c8ee61ce7fc704d3b376730abc17f.zip
opie-dbe0046eb82c8ee61ce7fc704d3b376730abc17f.tar.gz
opie-dbe0046eb82c8ee61ce7fc704d3b376730abc17f.tar.bz2
- yay, mouseMoveEvent is no more duplicated code :)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp45
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.h5
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp44
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h6
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp40
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h1
6 files changed, 50 insertions, 91 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 37c565b..dda039c 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -330,57 +330,12 @@ void AudioWidget::timerEvent( QTimerEvent * ) {
mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
} else if ( skipDirection == -1 ) {
mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
}
}
-
-void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
- for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
- Button &button = *it;
- 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, command );
-
- if ( isOnButton && !button.isHeld ) {
- button.isHeld = TRUE;
- toggleButton( button );
- switch ( command ) {
- case VolumeUp:
- emit moreClicked();
- return;
- case VolumeDown:
- emit lessClicked();
- return;
- case Forward:
- emit forwardClicked();
- return;
- case Back:
- emit backClicked();
- 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 );
- }
- handleCommand( command, button.isDown );
- }
- }
- }
-}
-
-
void AudioWidget::mousePressEvent( QMouseEvent *event ) {
mouseMoveEvent( event );
}
void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h
index 9b276b5..690d1b3 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.h
+++ b/noncore/multimedia/opieplayer2/audiowidget.h
@@ -66,24 +66,19 @@ public slots:
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 showEvent( QShowEvent *se );
void resizeEvent( QResizeEvent *re );
- void mouseMoveEvent( QMouseEvent *event );
void mousePressEvent( QMouseEvent *event );
void mouseReleaseEvent( QMouseEvent *event );
void timerEvent( QTimerEvent *event );
void keyReleaseEvent( QKeyEvent *e);
private slots:
void skipFor();
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index 7eb75e6..3533d74 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -66,12 +66,56 @@ void MediaWidget::paintEvent( QPaintEvent *pe )
} else {
QPainter p( this );
paintAllButtons( p );
}
}
+void MediaWidget::mouseMoveEvent( QMouseEvent *event )
+{
+ for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
+ Button &button = *it;
+ 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, command );
+
+ if ( isOnButton && !button.isHeld ) {
+ button.isHeld = TRUE;
+ toggleButton( button );
+ switch ( command ) {
+ case VolumeUp:
+ emit moreClicked();
+ return;
+ case VolumeDown:
+ emit lessClicked();
+ return;
+ case Forward:
+ emit forwardClicked();
+ return;
+ case Back:
+ emit backClicked();
+ 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 );
+ }
+ handleCommand( command, button.isDown );
+ }
+ }
+ }
+}
+
void MediaWidget::makeVisible()
{
}
void MediaWidget::handleCommand( Command command, bool buttonDown )
{
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index 3f4c45d..c19fdbb 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -74,18 +74,24 @@ public slots:
signals:
void moreReleased();
void lessReleased();
void forwardReleased();
void backReleased();
+ void forwardClicked();
+ void backClicked();
+ void moreClicked();
+ void lessClicked();
protected:
virtual void closeEvent( QCloseEvent * );
virtual void paintEvent( QPaintEvent *pe );
+ virtual void mouseMoveEvent( QMouseEvent *event );
+
virtual void makeVisible();
void handleCommand( Command command, bool buttonDown );
bool isOverButton( const QPoint &position, int buttonId ) const;
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index cc586cc..41844e1 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -240,52 +240,12 @@ void VideoWidget::updateSlider( long i, long max ) {
if ( slider->maxValue() != width ) {
slider->setMaxValue( width );
}
}
}
-void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
- for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
- Button &button = *it;
- 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, command );
-
- if ( isOnButton && !button.isHeld ) {
- button.isHeld = TRUE;
- toggleButton( button );
-
- switch ( command ) {
- case VolumeUp:
- emit moreClicked();
- return;
- 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 );
- }
-
- handleCommand( command, button.isDown );
- }
- }
- }
-}
-
void VideoWidget::mousePressEvent( QMouseEvent *event ) {
mouseMoveEvent( event );
}
void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
if ( mediaPlayerState.isFullscreen() ) {
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index ef88186..7d50ea0 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -73,13 +73,12 @@ signals:
void videoResized ( const QSize &s );
protected:
void resizeEvent( QResizeEvent * );
void showEvent( QShowEvent *se );
- void mouseMoveEvent( QMouseEvent *event );
void mousePressEvent( QMouseEvent *event );
void mouseReleaseEvent( QMouseEvent *event );
void keyReleaseEvent( QKeyEvent *e);
private:
// Ticker songInfo;