author | simon <simon> | 2002-12-09 16:45:41 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-09 16:45:41 (UTC) |
commit | dbe0046eb82c8ee61ce7fc704d3b376730abc17f (patch) (unidiff) | |
tree | d8729a7844dc889024090afe1ffac1c6f3a3ab1b | |
parent | 1bb6aa52f2db85f65f75278310c328218caeae65 (diff) | |
download | opie-dbe0046eb82c8ee61ce7fc704d3b376730abc17f.zip opie-dbe0046eb82c8ee61ce7fc704d3b376730abc17f.tar.gz opie-dbe0046eb82c8ee61ce7fc704d3b376730abc17f.tar.bz2 |
- yay, mouseMoveEvent is no more duplicated code :)
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 45 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 5 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 44 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 6 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 40 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 1 |
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 | |||
@@ -333,51 +333,6 @@ void AudioWidget::timerEvent( QTimerEvent * ) { | |||
333 | } | 333 | } |
334 | } | 334 | } |
335 | 335 | ||
336 | |||
337 | void 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 | |||
381 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 336 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
382 | mouseMoveEvent( event ); | 337 | mouseMoveEvent( event ); |
383 | } | 338 | } |
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 | |||
@@ -69,10 +69,6 @@ public: | |||
69 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); | 69 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); |
70 | 70 | ||
71 | signals: | 71 | signals: |
72 | void moreClicked(); | ||
73 | void lessClicked(); | ||
74 | void forwardClicked(); | ||
75 | void backClicked(); | ||
76 | void sliderMoved(long); | 72 | void sliderMoved(long); |
77 | 73 | ||
78 | protected: | 74 | protected: |
@@ -80,7 +76,6 @@ protected: | |||
80 | void doUnblank(); | 76 | void doUnblank(); |
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 ); |
86 | void timerEvent( QTimerEvent *event ); | 81 | void timerEvent( QTimerEvent *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 | |||
@@ -69,6 +69,50 @@ void MediaWidget::paintEvent( QPaintEvent *pe ) | |||
69 | } | 69 | } |
70 | } | 70 | } |
71 | 71 | ||
72 | void 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 | |||
72 | void MediaWidget::makeVisible() | 116 | void MediaWidget::makeVisible() |
73 | { | 117 | { |
74 | } | 118 | } |
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 | |||
@@ -77,12 +77,18 @@ signals: | |||
77 | void lessReleased(); | 77 | void lessReleased(); |
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 | ||
81 | protected: | 85 | protected: |
82 | virtual void closeEvent( QCloseEvent * ); | 86 | virtual void closeEvent( QCloseEvent * ); |
83 | 87 | ||
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 | ||
88 | void handleCommand( Command command, bool buttonDown ); | 94 | void handleCommand( Command command, bool buttonDown ); |
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 | |||
@@ -243,46 +243,6 @@ void VideoWidget::updateSlider( long i, long max ) { | |||
243 | } | 243 | } |
244 | } | 244 | } |
245 | 245 | ||
246 | void 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 | |||
286 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 246 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
287 | mouseMoveEvent( event ); | 247 | mouseMoveEvent( event ); |
288 | } | 248 | } |
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 | |||
@@ -76,7 +76,6 @@ protected: | |||
76 | 76 | ||
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 ); |
82 | void keyReleaseEvent( QKeyEvent *e); | 81 | void keyReleaseEvent( QKeyEvent *e); |