summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-09 16:45:41 (UTC)
committer simon <simon>2002-12-09 16:45:41 (UTC)
commitdbe0046eb82c8ee61ce7fc704d3b376730abc17f (patch) (unidiff)
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
@@ -334,49 +334,4 @@ void AudioWidget::timerEvent( QTimerEvent * ) {
334} 334}
335 335
336
337void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
338 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
339 Button &button = *it;
340 Command command = button.command;
341
342 if ( event->state() == QMouseEvent::LeftButton ) {
343 // The test to see if the mouse click is inside the button or not
344 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, command );
345
346 if ( isOnButton && !button.isHeld ) {
347 button.isHeld = TRUE;
348 toggleButton( button );
349 switch ( command ) {
350 case VolumeUp:
351 emit moreClicked();
352 return;
353 case VolumeDown:
354 emit lessClicked();
355 return;
356 case Forward:
357 emit forwardClicked();
358 return;
359 case Back:
360 emit backClicked();
361 return;
362 default: break;
363 }
364 } else if ( !isOnButton && button.isHeld ) {
365 button.isHeld = FALSE;
366 toggleButton( button );
367 }
368 } else {
369 if ( button.isHeld ) {
370 button.isHeld = FALSE;
371 if ( button.type != ToggleButton ) {
372 setToggleButton( button, FALSE );
373 }
374 handleCommand( command, button.isDown );
375 }
376 }
377 }
378}
379
380
381void AudioWidget::mousePressEvent( QMouseEvent *event ) { 336void AudioWidget::mousePressEvent( QMouseEvent *event ) {
382 mouseMoveEvent( event ); 337 mouseMoveEvent( 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
@@ -70,8 +70,4 @@ public:
70 70
71signals: 71signals:
72 void moreClicked();
73 void lessClicked();
74 void forwardClicked();
75 void backClicked();
76 void sliderMoved(long); 72 void sliderMoved(long);
77 73
@@ -81,5 +77,4 @@ protected:
81 void showEvent( QShowEvent *se ); 77 void showEvent( QShowEvent *se );
82 void resizeEvent( QResizeEvent *re ); 78 void resizeEvent( QResizeEvent *re );
83 void mouseMoveEvent( QMouseEvent *event );
84 void mousePressEvent( QMouseEvent *event ); 79 void mousePressEvent( QMouseEvent *event );
85 void mouseReleaseEvent( QMouseEvent *event ); 80 void mouseReleaseEvent( QMouseEvent *event );
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
@@ -70,4 +70,48 @@ void MediaWidget::paintEvent( QPaintEvent *pe )
70} 70}
71 71
72void MediaWidget::mouseMoveEvent( QMouseEvent *event )
73{
74 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
75 Button &button = *it;
76 Command command = button.command;
77
78 if ( event->state() == QMouseEvent::LeftButton ) {
79 // The test to see if the mouse click is inside the button or not
80 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, command );
81
82 if ( isOnButton && !button.isHeld ) {
83 button.isHeld = TRUE;
84 toggleButton( button );
85 switch ( command ) {
86 case VolumeUp:
87 emit moreClicked();
88 return;
89 case VolumeDown:
90 emit lessClicked();
91 return;
92 case Forward:
93 emit forwardClicked();
94 return;
95 case Back:
96 emit backClicked();
97 return;
98 default: break;
99 }
100 } else if ( !isOnButton && button.isHeld ) {
101 button.isHeld = FALSE;
102 toggleButton( button );
103 }
104 } else {
105 if ( button.isHeld ) {
106 button.isHeld = FALSE;
107 if ( button.type != ToggleButton ) {
108 setToggleButton( button, FALSE );
109 }
110 handleCommand( command, button.isDown );
111 }
112 }
113 }
114}
115
72void MediaWidget::makeVisible() 116void MediaWidget::makeVisible()
73{ 117{
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
@@ -78,4 +78,8 @@ signals:
78 void forwardReleased(); 78 void forwardReleased();
79 void backReleased(); 79 void backReleased();
80 void forwardClicked();
81 void backClicked();
82 void moreClicked();
83 void lessClicked();
80 84
81protected: 85protected:
@@ -84,4 +88,6 @@ protected:
84 virtual void paintEvent( QPaintEvent *pe ); 88 virtual void paintEvent( QPaintEvent *pe );
85 89
90 virtual void mouseMoveEvent( QMouseEvent *event );
91
86 virtual void makeVisible(); 92 virtual void makeVisible();
87 93
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
@@ -244,44 +244,4 @@ void VideoWidget::updateSlider( long i, long max ) {
244} 244}
245 245
246void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
247 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
248 Button &button = *it;
249 Command command = button.command;
250
251 if ( event->state() == QMouseEvent::LeftButton ) {
252 // The test to see if the mouse click is inside the button or not
253 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, command );
254
255 if ( isOnButton && !button.isHeld ) {
256 button.isHeld = TRUE;
257 toggleButton( button );
258
259 switch ( command ) {
260 case VolumeUp:
261 emit moreClicked();
262 return;
263 case VolumeDown:
264 emit lessClicked();
265 return;
266 default: break;
267 }
268 } else if ( !isOnButton && button.isHeld ) {
269 button.isHeld = FALSE;
270 toggleButton( button );
271 }
272 } else {
273
274 if ( button.isHeld ) {
275 button.isHeld = FALSE;
276 if ( button.type != ToggleButton ) {
277 setToggleButton( button, FALSE );
278 }
279
280 handleCommand( command, button.isDown );
281 }
282 }
283 }
284}
285
286void VideoWidget::mousePressEvent( QMouseEvent *event ) { 246void VideoWidget::mousePressEvent( QMouseEvent *event ) {
287 mouseMoveEvent( event ); 247 mouseMoveEvent( event );
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
@@ -77,5 +77,4 @@ protected:
77 void resizeEvent( QResizeEvent * ); 77 void resizeEvent( QResizeEvent * );
78 void showEvent( QShowEvent *se ); 78 void showEvent( QShowEvent *se );
79 void mouseMoveEvent( QMouseEvent *event );
80 void mousePressEvent( QMouseEvent *event ); 79 void mousePressEvent( QMouseEvent *event );
81 void mouseReleaseEvent( QMouseEvent *event ); 80 void mouseReleaseEvent( QMouseEvent *event );