author | simon <simon> | 2002-12-09 15:39:26 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-09 15:39:26 (UTC) |
commit | 21738c78103c42605625f85abf7bfd0d6beaad3f (patch) (unidiff) | |
tree | 0d64cf6453265f4730025d4965b4fff6d1613115 | |
parent | 9aa2442f6ea4e0d58fa7888995ebad04b3692049 (diff) | |
download | opie-21738c78103c42605625f85abf7bfd0d6beaad3f.zip opie-21738c78103c42605625f85abf7bfd0d6beaad3f.tar.gz opie-21738c78103c42605625f85abf7bfd0d6beaad3f.tar.bz2 |
- merged duplicated setToggleButton method
- minor fixlet for paintAllButtons
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 8 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 12 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 6 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 1 |
6 files changed, 12 insertions, 17 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 277d162..8c7e614 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -292,40 +292,32 @@ void AudioWidget::updateSlider( long i, long max ) { | |||
292 | } | 292 | } |
293 | // Will flicker too much if we don't do this | 293 | // Will flicker too much if we don't do this |
294 | // Scale to something reasonable | 294 | // Scale to something reasonable |
295 | int width = slider.width(); | 295 | int width = slider.width(); |
296 | int val = int((double)i * width / max); | 296 | int val = int((double)i * width / max); |
297 | if ( !audioSliderBeingMoved ) { | 297 | if ( !audioSliderBeingMoved ) { |
298 | if ( slider.value() != val ) { | 298 | if ( slider.value() != val ) { |
299 | slider.setValue( val ); | 299 | slider.setValue( val ); |
300 | } | 300 | } |
301 | 301 | ||
302 | if ( slider.maxValue() != width ) { | 302 | if ( slider.maxValue() != width ) { |
303 | slider.setMaxValue( width ); | 303 | slider.setMaxValue( width ); |
304 | } | 304 | } |
305 | } | 305 | } |
306 | } | 306 | } |
307 | 307 | ||
308 | |||
309 | void AudioWidget::setToggleButton( int i, bool down ) { | ||
310 | qDebug("setToggleButton %d", i); | ||
311 | if ( down != buttons[i].isDown ) { | ||
312 | toggleButton( i ); | ||
313 | } | ||
314 | } | ||
315 | |||
316 | void AudioWidget::skipFor() { | 308 | void AudioWidget::skipFor() { |
317 | skipDirection = +1; | 309 | skipDirection = +1; |
318 | startTimer( 50 ); | 310 | startTimer( 50 ); |
319 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 311 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
320 | } | 312 | } |
321 | 313 | ||
322 | void AudioWidget::skipBack() { | 314 | void AudioWidget::skipBack() { |
323 | skipDirection = -1; | 315 | skipDirection = -1; |
324 | startTimer( 50 ); | 316 | startTimer( 50 ); |
325 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 317 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
326 | } | 318 | } |
327 | 319 | ||
328 | 320 | ||
329 | 321 | ||
330 | void AudioWidget::stopSkip() { | 322 | void AudioWidget::stopSkip() { |
331 | killTimers(); | 323 | killTimers(); |
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index 8c433ac..9b276b5 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h | |||
@@ -77,32 +77,31 @@ signals: | |||
77 | 77 | ||
78 | protected: | 78 | protected: |
79 | void doBlank(); | 79 | void doBlank(); |
80 | void doUnblank(); | 80 | void doUnblank(); |
81 | void showEvent( QShowEvent *se ); | 81 | void showEvent( QShowEvent *se ); |
82 | void resizeEvent( QResizeEvent *re ); | 82 | void resizeEvent( QResizeEvent *re ); |
83 | void mouseMoveEvent( QMouseEvent *event ); | 83 | void mouseMoveEvent( QMouseEvent *event ); |
84 | void mousePressEvent( QMouseEvent *event ); | 84 | void mousePressEvent( QMouseEvent *event ); |
85 | void mouseReleaseEvent( QMouseEvent *event ); | 85 | void mouseReleaseEvent( QMouseEvent *event ); |
86 | void timerEvent( QTimerEvent *event ); | 86 | void timerEvent( QTimerEvent *event ); |
87 | void keyReleaseEvent( QKeyEvent *e); | 87 | void keyReleaseEvent( QKeyEvent *e); |
88 | private slots: | 88 | private slots: |
89 | void skipFor(); | 89 | void skipFor(); |
90 | void skipBack(); | 90 | void skipBack(); |
91 | void stopSkip(); | 91 | void stopSkip(); |
92 | private: | 92 | private: |
93 | void setToggleButton( int, bool ); | ||
94 | int skipDirection; | 93 | int skipDirection; |
95 | QString skin; | 94 | QString skin; |
96 | QImage imgUp; | 95 | QImage imgUp; |
97 | QImage imgDn; | 96 | QImage imgDn; |
98 | 97 | ||
99 | OTicker songInfo; | 98 | OTicker songInfo; |
100 | QSlider slider; | 99 | QSlider slider; |
101 | QLineEdit time; | 100 | QLineEdit time; |
102 | bool isStreaming : 1; | 101 | bool isStreaming : 1; |
103 | bool audioSliderBeingMoved : 1; | 102 | bool audioSliderBeingMoved : 1; |
104 | }; | 103 | }; |
105 | 104 | ||
106 | 105 | ||
107 | #endif // AUDIO_WIDGET_H | 106 | #endif // AUDIO_WIDGET_H |
108 | 107 | ||
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp index 271f788..9c5291b 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.cpp +++ b/noncore/multimedia/opieplayer2/mediawidget.cpp | |||
@@ -84,44 +84,54 @@ void MediaWidget::handleCommand( Command command, bool buttonDown ) | |||
84 | case Back: emit backReleased(); return; | 84 | case Back: emit backReleased(); return; |
85 | } | 85 | } |
86 | } | 86 | } |
87 | 87 | ||
88 | bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const | 88 | bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const |
89 | { | 89 | { |
90 | return ( position.x() > 0 && position.y() > 0 && | 90 | return ( position.x() > 0 && position.y() > 0 && |
91 | position.x() < buttonMask.width() && | 91 | position.x() < buttonMask.width() && |
92 | position.y() < buttonMask.height() && | 92 | position.y() < buttonMask.height() && |
93 | buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); | 93 | buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); |
94 | } | 94 | } |
95 | 95 | ||
96 | void MediaWidget::paintAllButtons( QPainter &p ) | 96 | void MediaWidget::paintAllButtons( QPainter &p ) |
97 | { | 97 | { |
98 | for ( ButtonMap::ConstIterator it = buttons.begin(); | 98 | for ( ButtonMap::ConstIterator it = buttons.begin(); |
99 | it != buttons.end(); ++it ) | 99 | it != buttons.end(); ++it ) |
100 | paintButton( *it ); | 100 | paintButton( p, *it ); |
101 | } | 101 | } |
102 | 102 | ||
103 | void MediaWidget::paintButton( const Button &button ) | 103 | void MediaWidget::paintButton( const Button &button ) |
104 | { | 104 | { |
105 | QPainter p( this ); | 105 | QPainter p( this ); |
106 | paintButton( p, button ); | 106 | paintButton( p, button ); |
107 | } | 107 | } |
108 | 108 | ||
109 | void MediaWidget::paintButton( QPainter &p, const Button &button ) | 109 | void MediaWidget::paintButton( QPainter &p, const Button &button ) |
110 | { | 110 | { |
111 | if ( button.isDown ) | 111 | if ( button.isDown ) |
112 | p.drawPixmap( upperLeftOfButtonMask, button.pixDown ); | 112 | p.drawPixmap( upperLeftOfButtonMask, button.pixDown ); |
113 | else | 113 | else |
114 | p.drawPixmap( upperLeftOfButtonMask, button.pixUp ); | 114 | p.drawPixmap( upperLeftOfButtonMask, button.pixUp ); |
115 | } | 115 | } |
116 | 116 | ||
117 | void MediaWidget::setToggleButton( int buttonId, bool down ) | ||
118 | { | ||
119 | qDebug("setToggleButton %d", buttonId ); | ||
120 | |||
121 | Button &button = buttons[ buttonId ]; | ||
122 | |||
123 | if ( down != button.isDown ) | ||
124 | toggleButton( buttonId ); | ||
125 | } | ||
126 | |||
117 | void MediaWidget::toggleButton( int buttonId ) | 127 | void MediaWidget::toggleButton( int buttonId ) |
118 | { | 128 | { |
119 | Button &button = buttons[ buttonId ]; | 129 | Button &button = buttons[ buttonId ]; |
120 | 130 | ||
121 | button.isDown = !button.isDown; | 131 | button.isDown = !button.isDown; |
122 | 132 | ||
123 | paintButton( button ); | 133 | paintButton( button ); |
124 | } | 134 | } |
125 | 135 | ||
126 | /* vim: et sw=4 ts=4 | 136 | /* vim: et sw=4 ts=4 |
127 | */ | 137 | */ |
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h index 34910fb..b7860dc 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.h +++ b/noncore/multimedia/opieplayer2/mediawidget.h | |||
@@ -78,32 +78,33 @@ signals: | |||
78 | void forwardReleased(); | 78 | void forwardReleased(); |
79 | void backReleased(); | 79 | void backReleased(); |
80 | 80 | ||
81 | protected: | 81 | protected: |
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 | void handleCommand( Command command, bool buttonDown ); | 86 | void handleCommand( Command command, bool buttonDown ); |
87 | 87 | ||
88 | bool isOverButton( const QPoint &position, int buttonId ) const; | 88 | bool isOverButton( const QPoint &position, int buttonId ) const; |
89 | 89 | ||
90 | void paintAllButtons( QPainter &p ); | 90 | void paintAllButtons( QPainter &p ); |
91 | void paintButton( const Button &button ); | 91 | void paintButton( const Button &button ); |
92 | void paintButton( QPainter &p, const Button &button ); | 92 | void paintButton( QPainter &p, const Button &button ); |
93 | 93 | ||
94 | void setToggleButton( int buttonId, bool down ); | ||
94 | void toggleButton( int buttonId ); | 95 | void toggleButton( int buttonId ); |
95 | 96 | ||
96 | MediaPlayerState &mediaPlayerState; | 97 | MediaPlayerState &mediaPlayerState; |
97 | PlayListWidget &playList; | 98 | PlayListWidget &playList; |
98 | 99 | ||
99 | ButtonMap buttons; | 100 | ButtonMap buttons; |
100 | 101 | ||
101 | QImage buttonMask; | 102 | QImage buttonMask; |
102 | 103 | ||
103 | QPoint upperLeftOfButtonMask; | 104 | QPoint upperLeftOfButtonMask; |
104 | 105 | ||
105 | QPixmap backgroundPixmap; | 106 | QPixmap backgroundPixmap; |
106 | }; | 107 | }; |
107 | 108 | ||
108 | #endif // MEDIAWIDGET_H | 109 | #endif // MEDIAWIDGET_H |
109 | /* vim: et sw=4 ts=4 | 110 | /* vim: et sw=4 ts=4 |
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 8f6a8a9..db4a396 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -229,38 +229,32 @@ void VideoWidget::updateSlider( long i, long max ) { | |||
229 | // Will flicker too much if we don't do this | 229 | // Will flicker too much if we don't do this |
230 | if ( max == 0 ) { | 230 | if ( max == 0 ) { |
231 | return; | 231 | return; |
232 | } | 232 | } |
233 | int width = slider->width(); | 233 | int width = slider->width(); |
234 | int val = int((double)i * width / max); | 234 | int val = int((double)i * width / max); |
235 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { | 235 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { |
236 | if ( slider->value() != val ) { | 236 | if ( slider->value() != val ) { |
237 | slider->setValue( val ); | 237 | slider->setValue( val ); |
238 | } | 238 | } |
239 | if ( slider->maxValue() != width ) { | 239 | if ( slider->maxValue() != width ) { |
240 | slider->setMaxValue( width ); | 240 | slider->setMaxValue( width ); |
241 | } | 241 | } |
242 | } | 242 | } |
243 | } | 243 | } |
244 | 244 | ||
245 | void VideoWidget::setToggleButton( int i, bool down ) { | ||
246 | if ( down != buttons[i].isDown ) { | ||
247 | toggleButton( i ); | ||
248 | } | ||
249 | } | ||
250 | |||
251 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 245 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
252 | for ( unsigned int i = 0; i < buttons.count(); i++ ) { | 246 | for ( unsigned int i = 0; i < buttons.count(); i++ ) { |
253 | if ( event->state() == QMouseEvent::LeftButton ) { | 247 | if ( event->state() == QMouseEvent::LeftButton ) { |
254 | // The test to see if the mouse click is inside the button or not | 248 | // The test to see if the mouse click is inside the button or not |
255 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); | 249 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); |
256 | 250 | ||
257 | if ( isOnButton && !buttons[i].isHeld ) { | 251 | if ( isOnButton && !buttons[i].isHeld ) { |
258 | buttons[i].isHeld = TRUE; | 252 | buttons[i].isHeld = TRUE; |
259 | toggleButton(i); | 253 | toggleButton(i); |
260 | 254 | ||
261 | switch (i) { | 255 | switch (i) { |
262 | case VideoVolUp: | 256 | case VideoVolUp: |
263 | emit moreClicked(); | 257 | emit moreClicked(); |
264 | return; | 258 | return; |
265 | case VideoVolDown: | 259 | case VideoVolDown: |
266 | emit lessClicked(); | 260 | emit lessClicked(); |
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index 45279d7..915e9cc 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h | |||
@@ -88,30 +88,29 @@ signals: | |||
88 | protected: | 88 | protected: |
89 | 89 | ||
90 | void resizeEvent( QResizeEvent * ); | 90 | void resizeEvent( QResizeEvent * ); |
91 | void showEvent( QShowEvent *se ); | 91 | void showEvent( QShowEvent *se ); |
92 | void mouseMoveEvent( QMouseEvent *event ); | 92 | void mouseMoveEvent( QMouseEvent *event ); |
93 | void mousePressEvent( QMouseEvent *event ); | 93 | void mousePressEvent( QMouseEvent *event ); |
94 | void mouseReleaseEvent( QMouseEvent *event ); | 94 | void mouseReleaseEvent( QMouseEvent *event ); |
95 | void keyReleaseEvent( QKeyEvent *e); | 95 | void keyReleaseEvent( QKeyEvent *e); |
96 | 96 | ||
97 | private: | 97 | private: |
98 | // Ticker songInfo; | 98 | // Ticker songInfo; |
99 | QImage imgUp; | 99 | QImage imgUp; |
100 | QImage imgDn; | 100 | QImage imgDn; |
101 | QString skin; | 101 | QString skin; |
102 | 102 | ||
103 | 103 | ||
104 | void setToggleButton( int, bool ); | ||
105 | 104 | ||
106 | QString backgroundPix; | 105 | QString backgroundPix; |
107 | QSlider *slider; | 106 | QSlider *slider; |
108 | QImage *currentFrame; | 107 | QImage *currentFrame; |
109 | int scaledWidth; | 108 | int scaledWidth; |
110 | int scaledHeight; | 109 | int scaledHeight; |
111 | XineVideoWidget* videoFrame; | 110 | XineVideoWidget* videoFrame; |
112 | }; | 111 | }; |
113 | 112 | ||
114 | #endif // VIDEO_WIDGET_H | 113 | #endif // VIDEO_WIDGET_H |
115 | 114 | ||
116 | 115 | ||
117 | 116 | ||