summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-08 22:58:45 (UTC)
committer simon <simon>2002-12-08 22:58:45 (UTC)
commit7b38c0424eca2f49a0c9a931766c816e21f1d86b (patch) (unidiff)
treee310c27ad3592e46fc1a46d963ae24b2f299c949
parentdf6b6a0222e99736284ed8ebb9a7d8068751339b (diff)
downloadopie-7b38c0424eca2f49a0c9a931766c816e21f1d86b.zip
opie-7b38c0424eca2f49a0c9a931766c816e21f1d86b.tar.gz
opie-7b38c0424eca2f49a0c9a931766c816e21f1d86b.tar.bz2
- merged the two duplicated toggleButton methods into a shared one
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp8
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.h1
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp8
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h2
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp6
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h1
6 files changed, 9 insertions, 17 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 10b1e58..2a158a8 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -311,56 +311,48 @@ void AudioWidget::updateSlider( long i, long max ) {
311 } 311 }
312 // Will flicker too much if we don't do this 312 // Will flicker too much if we don't do this
313 // Scale to something reasonable 313 // Scale to something reasonable
314 int width = slider.width(); 314 int width = slider.width();
315 int val = int((double)i * width / max); 315 int val = int((double)i * width / max);
316 if ( !audioSliderBeingMoved ) { 316 if ( !audioSliderBeingMoved ) {
317 if ( slider.value() != val ) { 317 if ( slider.value() != val ) {
318 slider.setValue( val ); 318 slider.setValue( val );
319 } 319 }
320 320
321 if ( slider.maxValue() != width ) { 321 if ( slider.maxValue() != width ) {
322 slider.setMaxValue( width ); 322 slider.setMaxValue( width );
323 } 323 }
324 } 324 }
325} 325}
326 326
327 327
328void AudioWidget::setToggleButton( int i, bool down ) { 328void AudioWidget::setToggleButton( int i, bool down ) {
329 qDebug("setToggleButton %d", i); 329 qDebug("setToggleButton %d", i);
330 if ( down != buttons[i].isDown ) { 330 if ( down != buttons[i].isDown ) {
331 toggleButton( i ); 331 toggleButton( i );
332 } 332 }
333} 333}
334 334
335
336void AudioWidget::toggleButton( int i ) {
337 buttons[i].isDown = !buttons[i].isDown;
338 QPainter p(this);
339 paintButton ( p, i );
340}
341
342
343void AudioWidget::paintButton( QPainter &p, int i ) { 335void AudioWidget::paintButton( QPainter &p, int i ) {
344 if ( buttons[i].isDown ) { 336 if ( buttons[i].isDown ) {
345 p.drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] ); 337 p.drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] );
346 } else { 338 } else {
347 p.drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] ); 339 p.drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] );
348 } 340 }
349} 341}
350 342
351 343
352void AudioWidget::skipFor() { 344void AudioWidget::skipFor() {
353 skipDirection = +1; 345 skipDirection = +1;
354 startTimer( 50 ); 346 startTimer( 50 );
355 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); 347 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
356} 348}
357 349
358void AudioWidget::skipBack() { 350void AudioWidget::skipBack() {
359 skipDirection = -1; 351 skipDirection = -1;
360 startTimer( 50 ); 352 startTimer( 50 );
361 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); 353 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
362} 354}
363 355
364 356
365 357
366void AudioWidget::stopSkip() { 358void AudioWidget::stopSkip() {
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h
index a1a839c..4598d51 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.h
+++ b/noncore/multimedia/opieplayer2/audiowidget.h
@@ -70,46 +70,45 @@ public:
70 70
71signals: 71signals:
72 void moreClicked(); 72 void moreClicked();
73 void lessClicked(); 73 void lessClicked();
74 void forwardClicked(); 74 void forwardClicked();
75 void backClicked(); 75 void backClicked();
76 void sliderMoved(long); 76 void sliderMoved(long);
77 77
78protected: 78protected:
79 void doBlank(); 79 void doBlank();
80 void doUnblank(); 80 void doUnblank();
81 void paintEvent( QPaintEvent *pe ); 81 void paintEvent( QPaintEvent *pe );
82 void showEvent( QShowEvent *se ); 82 void showEvent( QShowEvent *se );
83 void resizeEvent( QResizeEvent *re ); 83 void resizeEvent( QResizeEvent *re );
84 void mouseMoveEvent( QMouseEvent *event ); 84 void mouseMoveEvent( QMouseEvent *event );
85 void mousePressEvent( QMouseEvent *event ); 85 void mousePressEvent( QMouseEvent *event );
86 void mouseReleaseEvent( QMouseEvent *event ); 86 void mouseReleaseEvent( QMouseEvent *event );
87 void timerEvent( QTimerEvent *event ); 87 void timerEvent( QTimerEvent *event );
88 void keyReleaseEvent( QKeyEvent *e); 88 void keyReleaseEvent( QKeyEvent *e);
89private slots: 89private slots:
90 void skipFor(); 90 void skipFor();
91 void skipBack(); 91 void skipBack();
92 void stopSkip(); 92 void stopSkip();
93private: 93private:
94 void toggleButton( int );
95 void setToggleButton( int, bool ); 94 void setToggleButton( int, bool );
96 virtual void paintButton( QPainter &p, int i ); 95 virtual void paintButton( QPainter &p, int i );
97 int skipDirection; 96 int skipDirection;
98 QString skin; 97 QString skin;
99 QPixmap pixBg; 98 QPixmap pixBg;
100 QImage imgUp; 99 QImage imgUp;
101 QImage imgDn; 100 QImage imgDn;
102 QBitmap *masks[10]; 101 QBitmap *masks[10];
103 QPixmap *buttonPixUp[10]; 102 QPixmap *buttonPixUp[10];
104 QPixmap *buttonPixDown[10]; 103 QPixmap *buttonPixDown[10];
105 104
106 QPixmap *pixmaps[4]; 105 QPixmap *pixmaps[4];
107 OTicker songInfo; 106 OTicker songInfo;
108 QSlider slider; 107 QSlider slider;
109 QLineEdit time; 108 QLineEdit time;
110 bool isStreaming : 1; 109 bool isStreaming : 1;
111}; 110};
112 111
113 112
114#endif // AUDIO_WIDGET_H 113#endif // AUDIO_WIDGET_H
115 114
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index ca84019..62266ad 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -47,32 +47,38 @@ void MediaWidget::closeEvent( QCloseEvent * )
47void MediaWidget::handleCommand( Command command, bool buttonDown ) 47void MediaWidget::handleCommand( Command command, bool buttonDown )
48{ 48{
49 switch ( command ) { 49 switch ( command ) {
50 case Play: mediaPlayerState.togglePaused(); 50 case Play: mediaPlayerState.togglePaused();
51 case Stop: mediaPlayerState.setPlaying(FALSE); return; 51 case Stop: mediaPlayerState.setPlaying(FALSE); return;
52 case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; 52 case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
53 case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; 53 case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
54 case Loop: mediaPlayerState.setLooping( buttonDown ); return; 54 case Loop: mediaPlayerState.setLooping( buttonDown ); return;
55 case VolumeUp: emit moreReleased(); return; 55 case VolumeUp: emit moreReleased(); return;
56 case VolumeDown: emit lessReleased(); return; 56 case VolumeDown: emit lessReleased(); return;
57 case PlayList: mediaPlayerState.setList(); return; 57 case PlayList: mediaPlayerState.setList(); return;
58 case Forward: emit forwardReleased(); return; 58 case Forward: emit forwardReleased(); return;
59 case Back: emit backReleased(); return; 59 case Back: emit backReleased(); return;
60 } 60 }
61} 61}
62 62
63bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const 63bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const
64{ 64{
65 return ( position.x() > 0 && position.y() > 0 && 65 return ( position.x() > 0 && position.y() > 0 &&
66 position.x() < buttonMask.width() && 66 position.x() < buttonMask.width() &&
67 position.y() < buttonMask.height() && 67 position.y() < buttonMask.height() &&
68 buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); 68 buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 );
69} 69}
70 70
71void MediaWidget::repaintButton( int buttonId ) 71void MediaWidget::paintButton( int buttonId )
72{ 72{
73 QPainter p( this ); 73 QPainter p( this );
74 paintButton( p, buttonId ); 74 paintButton( p, buttonId );
75} 75}
76 76
77void MediaWidget::toggleButton( int buttonId )
78{
79 buttons[ buttonId ].isDown = !buttons[ buttonId ].isDown;
80 paintButton( buttonId );
81}
82
77/* vim: et sw=4 ts=4 83/* vim: et sw=4 ts=4
78 */ 84 */
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index 066d2ac..46c304d 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -49,37 +49,39 @@ public:
49 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); 49 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 );
50 virtual ~MediaWidget(); 50 virtual ~MediaWidget();
51 51
52public slots: 52public slots:
53 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; 53 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0;
54 virtual void setLength( long length ) = 0; 54 virtual void setLength( long length ) = 0;
55 virtual void setPlaying( bool playing ) = 0; 55 virtual void setPlaying( bool playing ) = 0;
56 56
57signals: 57signals:
58 void moreReleased(); 58 void moreReleased();
59 void lessReleased(); 59 void lessReleased();
60 void forwardReleased(); 60 void forwardReleased();
61 void backReleased(); 61 void backReleased();
62 62
63protected: 63protected:
64 virtual void closeEvent( QCloseEvent * ); 64 virtual void closeEvent( QCloseEvent * );
65 65
66 void handleCommand( Command command, bool buttonDown ); 66 void handleCommand( Command command, bool buttonDown );
67 67
68 bool isOverButton( const QPoint &position, int buttonId ) const; 68 bool isOverButton( const QPoint &position, int buttonId ) const;
69 69
70 void paintButton( int buttonId ); 70 void paintButton( int buttonId );
71 virtual void paintButton( QPainter &p, int i ) = 0; 71 virtual void paintButton( QPainter &p, int i ) = 0;
72 72
73 void toggleButton( int buttonId );
74
73 MediaPlayerState &mediaPlayerState; 75 MediaPlayerState &mediaPlayerState;
74 PlayListWidget &playList; 76 PlayListWidget &playList;
75 77
76 ButtonVector buttons; 78 ButtonVector buttons;
77 79
78 QImage buttonMask; 80 QImage buttonMask;
79 81
80 QPoint upperLeftOfButtonMask; 82 QPoint upperLeftOfButtonMask;
81}; 83};
82 84
83#endif // MEDIAWIDGET_H 85#endif // MEDIAWIDGET_H
84/* vim: et sw=4 ts=4 86/* vim: et sw=4 ts=4
85 */ 87 */
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 3e677c6..77eab71 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -242,54 +242,48 @@ void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
242 242
243void VideoWidget::updateSlider( long i, long max ) { 243void VideoWidget::updateSlider( long i, long max ) {
244 // Will flicker too much if we don't do this 244 // Will flicker too much if we don't do this
245 if ( max == 0 ) { 245 if ( max == 0 ) {
246 return; 246 return;
247 } 247 }
248 int width = slider->width(); 248 int width = slider->width();
249 int val = int((double)i * width / max); 249 int val = int((double)i * width / max);
250 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { 250 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) {
251 if ( slider->value() != val ) { 251 if ( slider->value() != val ) {
252 slider->setValue( val ); 252 slider->setValue( val );
253 } 253 }
254 if ( slider->maxValue() != width ) { 254 if ( slider->maxValue() != width ) {
255 slider->setMaxValue( width ); 255 slider->setMaxValue( width );
256 } 256 }
257 } 257 }
258} 258}
259 259
260void VideoWidget::setToggleButton( int i, bool down ) { 260void VideoWidget::setToggleButton( int i, bool down ) {
261 if ( down != buttons[i].isDown ) { 261 if ( down != buttons[i].isDown ) {
262 toggleButton( i ); 262 toggleButton( i );
263 } 263 }
264} 264}
265 265
266void VideoWidget::toggleButton( int i ) {
267 buttons[i].isDown = !buttons[i].isDown;
268 QPainter p(this);
269 paintButton ( p, i );
270}
271
272void VideoWidget::paintButton( QPainter &p, int i ) { 266void VideoWidget::paintButton( QPainter &p, int i ) {
273 267
274 if ( buttons[i].isDown ) { 268 if ( buttons[i].isDown ) {
275 p.drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] ); 269 p.drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] );
276 } else { 270 } else {
277 p.drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] ); 271 p.drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] );
278 } 272 }
279} 273}
280 274
281void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 275void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
282 for ( unsigned int i = 0; i < buttons.size(); i++ ) { 276 for ( unsigned int i = 0; i < buttons.size(); i++ ) {
283 if ( event->state() == QMouseEvent::LeftButton ) { 277 if ( event->state() == QMouseEvent::LeftButton ) {
284 // The test to see if the mouse click is inside the button or not 278 // The test to see if the mouse click is inside the button or not
285 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); 279 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i );
286 280
287 if ( isOnButton && !buttons[i].isHeld ) { 281 if ( isOnButton && !buttons[i].isHeld ) {
288 buttons[i].isHeld = TRUE; 282 buttons[i].isHeld = TRUE;
289 toggleButton(i); 283 toggleButton(i);
290 284
291 switch (i) { 285 switch (i) {
292 case VideoVolUp: 286 case VideoVolUp:
293 emit moreClicked(); 287 emit moreClicked();
294 return; 288 return;
295 case VideoVolDown: 289 case VideoVolDown:
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index 28f720b..24e8741 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -87,40 +87,39 @@ signals:
87 87
88protected: 88protected:
89 89
90 void resizeEvent( QResizeEvent * ); 90 void resizeEvent( QResizeEvent * );
91 void paintEvent( QPaintEvent *pe ); 91 void paintEvent( QPaintEvent *pe );
92 void showEvent( QShowEvent *se ); 92 void showEvent( QShowEvent *se );
93 void mouseMoveEvent( QMouseEvent *event ); 93 void mouseMoveEvent( QMouseEvent *event );
94 void mousePressEvent( QMouseEvent *event ); 94 void mousePressEvent( QMouseEvent *event );
95 void mouseReleaseEvent( QMouseEvent *event ); 95 void mouseReleaseEvent( QMouseEvent *event );
96 void keyReleaseEvent( QKeyEvent *e); 96 void keyReleaseEvent( QKeyEvent *e);
97 97
98private: 98private:
99// Ticker songInfo; 99// Ticker songInfo;
100 QPixmap pixBg; 100 QPixmap pixBg;
101 QImage imgUp; 101 QImage imgUp;
102 QImage imgDn; 102 QImage imgDn;
103 QBitmap *masks[7]; 103 QBitmap *masks[7];
104 QPixmap *buttonPixUp[7]; 104 QPixmap *buttonPixUp[7];
105 QPixmap *buttonPixDown[7]; 105 QPixmap *buttonPixDown[7];
106 QString skin; 106 QString skin;
107// QPixmap *pixmaps[4]; 107// QPixmap *pixmaps[4];
108 108
109 109
110 virtual void paintButton( QPainter &p, int i ); 110 virtual void paintButton( QPainter &p, int i );
111 void toggleButton( int );
112 void setToggleButton( int, bool ); 111 void setToggleButton( int, bool );
113 112
114 QString backgroundPix; 113 QString backgroundPix;
115 QSlider *slider; 114 QSlider *slider;
116 QPixmap *pixmaps[3]; 115 QPixmap *pixmaps[3];
117 QImage *currentFrame; 116 QImage *currentFrame;
118 int scaledWidth; 117 int scaledWidth;
119 int scaledHeight; 118 int scaledHeight;
120 XineVideoWidget* videoFrame; 119 XineVideoWidget* videoFrame;
121}; 120};
122 121
123#endif // VIDEO_WIDGET_H 122#endif // VIDEO_WIDGET_H
124 123
125 124
126 125