summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2
Unidiff
Diffstat (limited to 'noncore/multimedia/opieplayer2') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp13
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.h1
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp10
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h2
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp15
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h1
6 files changed, 14 insertions, 28 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 12f91a9..5cc2814 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -304,33 +304,24 @@ void AudioWidget::updateSlider( long i, long max ) {
304 } 304 }
305 } 305 }
306} 306}
307 307
308 308
309void AudioWidget::setToggleButton( int i, bool down ) { 309void AudioWidget::setToggleButton( int i, bool down ) {
310 qDebug("setToggleButton %d", i); 310 qDebug("setToggleButton %d", i);
311 if ( down != buttons[i].isDown ) { 311 if ( down != buttons[i].isDown ) {
312 toggleButton( i ); 312 toggleButton( i );
313 } 313 }
314} 314}
315 315
316void AudioWidget::paintButton( QPainter &p, int i ) {
317 if ( buttons[i].isDown ) {
318 p.drawPixmap( upperLeftOfButtonMask, buttons[i].pixDown );
319 } else {
320 p.drawPixmap( upperLeftOfButtonMask, buttons[i].pixUp );
321 }
322}
323
324
325void AudioWidget::skipFor() { 316void AudioWidget::skipFor() {
326 skipDirection = +1; 317 skipDirection = +1;
327 startTimer( 50 ); 318 startTimer( 50 );
328 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); 319 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
329} 320}
330 321
331void AudioWidget::skipBack() { 322void AudioWidget::skipBack() {
332 skipDirection = -1; 323 skipDirection = -1;
333 startTimer( 50 ); 324 startTimer( 50 );
334 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); 325 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
335} 326}
336 327
@@ -406,31 +397,31 @@ void AudioWidget::showEvent( QShowEvent* ) {
406 mouseMoveEvent( &event ); 397 mouseMoveEvent( &event );
407} 398}
408 399
409 400
410void AudioWidget::paintEvent( QPaintEvent * pe ) { 401void AudioWidget::paintEvent( QPaintEvent * pe ) {
411 if ( !pe->erased() ) { 402 if ( !pe->erased() ) {
412 // Combine with background and double buffer 403 // Combine with background and double buffer
413 QPixmap pix( pe->rect().size() ); 404 QPixmap pix( pe->rect().size() );
414 QPainter p( &pix ); 405 QPainter p( &pix );
415 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 406 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
416 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); 407 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() );
417 for ( unsigned int i = 0; i < buttons.count(); i++ ) 408 for ( unsigned int i = 0; i < buttons.count(); i++ )
418 paintButton( p, i ); 409 paintButton( p, buttons[ i ] );
419 QPainter p2( this ); 410 QPainter p2( this );
420 p2.drawPixmap( pe->rect().topLeft(), pix ); 411 p2.drawPixmap( pe->rect().topLeft(), pix );
421 } else { 412 } else {
422 QPainter p( this ); 413 QPainter p( this );
423 for ( unsigned int i = 0; i < buttons.count(); i++ ) 414 for ( unsigned int i = 0; i < buttons.count(); i++ )
424 paintButton( p, i ); 415 paintButton( p, buttons[ i ] );
425 } 416 }
426} 417}
427 418
428void AudioWidget::keyReleaseEvent( QKeyEvent *e) { 419void AudioWidget::keyReleaseEvent( QKeyEvent *e) {
429 switch ( e->key() ) { 420 switch ( e->key() ) {
430 ////////////////////////////// Zaurus keys 421 ////////////////////////////// Zaurus keys
431 case Key_Home: 422 case Key_Home:
432 break; 423 break;
433 case Key_F9: //activity 424 case Key_F9: //activity
434 hide(); 425 hide();
435 // qDebug("Audio F9"); 426 // qDebug("Audio F9");
436 break; 427 break;
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h
index 332fb4b..7a775cd 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.h
+++ b/noncore/multimedia/opieplayer2/audiowidget.h
@@ -83,25 +83,24 @@ protected:
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 setToggleButton( int, bool ); 94 void setToggleButton( int, bool );
95 virtual void paintButton( QPainter &p, int i );
96 int skipDirection; 95 int skipDirection;
97 QString skin; 96 QString skin;
98 QPixmap pixBg; 97 QPixmap pixBg;
99 QImage imgUp; 98 QImage imgUp;
100 QImage imgDn; 99 QImage imgDn;
101 100
102 OTicker songInfo; 101 OTicker songInfo;
103 QSlider slider; 102 QSlider slider;
104 QLineEdit time; 103 QLineEdit time;
105 bool isStreaming : 1; 104 bool isStreaming : 1;
106 bool audioSliderBeingMoved : 1; 105 bool audioSliderBeingMoved : 1;
107}; 106};
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index 62266ad..f977b61 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -62,23 +62,31 @@ void MediaWidget::handleCommand( Command command, bool buttonDown )
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::paintButton( int buttonId ) 71void MediaWidget::paintButton( int buttonId )
72{ 72{
73 QPainter p( this ); 73 QPainter p( this );
74 paintButton( p, buttonId ); 74 paintButton( p, buttons[ buttonId ] );
75}
76
77void MediaWidget::paintButton( QPainter &p, const Button &button )
78{
79 if ( button.isDown )
80 p.drawPixmap( upperLeftOfButtonMask, button.pixDown );
81 else
82 p.drawPixmap( upperLeftOfButtonMask, button.pixUp );
75} 83}
76 84
77void MediaWidget::toggleButton( int buttonId ) 85void MediaWidget::toggleButton( int buttonId )
78{ 86{
79 buttons[ buttonId ].isDown = !buttons[ buttonId ].isDown; 87 buttons[ buttonId ].isDown = !buttons[ buttonId ].isDown;
80 paintButton( buttonId ); 88 paintButton( buttonId );
81} 89}
82 90
83/* vim: et sw=4 ts=4 91/* vim: et sw=4 ts=4
84 */ 92 */
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index 49bf024..163f449 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -77,25 +77,25 @@ signals:
77 void lessReleased(); 77 void lessReleased();
78 void forwardReleased(); 78 void forwardReleased();
79 void backReleased(); 79 void backReleased();
80 80
81protected: 81protected:
82 virtual void closeEvent( QCloseEvent * ); 82 virtual void closeEvent( QCloseEvent * );
83 83
84 void handleCommand( Command command, bool buttonDown ); 84 void handleCommand( Command command, bool buttonDown );
85 85
86 bool isOverButton( const QPoint &position, int buttonId ) const; 86 bool isOverButton( const QPoint &position, int buttonId ) const;
87 87
88 void paintButton( int buttonId ); 88 void paintButton( int buttonId );
89 virtual void paintButton( QPainter &p, int i ) = 0; 89 void paintButton( QPainter &p, const Button &button );
90 90
91 void toggleButton( int buttonId ); 91 void toggleButton( int buttonId );
92 92
93 MediaPlayerState &mediaPlayerState; 93 MediaPlayerState &mediaPlayerState;
94 PlayListWidget &playList; 94 PlayListWidget &playList;
95 95
96 ButtonMap buttons; 96 ButtonMap buttons;
97 97
98 QImage buttonMask; 98 QImage buttonMask;
99 99
100 QPoint upperLeftOfButtonMask; 100 QPoint upperLeftOfButtonMask;
101}; 101};
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 3baa087..a483434 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -239,35 +239,24 @@ void VideoWidget::updateSlider( long i, long max ) {
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
245void VideoWidget::setToggleButton( int i, bool down ) { 245void VideoWidget::setToggleButton( int i, bool down ) {
246 if ( down != buttons[i].isDown ) { 246 if ( down != buttons[i].isDown ) {
247 toggleButton( i ); 247 toggleButton( i );
248 } 248 }
249} 249}
250 250
251void VideoWidget::paintButton( QPainter &p, int i ) {
252
253 Button &button = buttons[ i ];
254
255 if ( button.isDown ) {
256 p.drawPixmap( upperLeftOfButtonMask, button.pixDown );
257 } else {
258 p.drawPixmap( upperLeftOfButtonMask, button.pixUp );
259 }
260}
261
262void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 251void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
263 for ( unsigned int i = 0; i < buttons.count(); i++ ) { 252 for ( unsigned int i = 0; i < buttons.count(); i++ ) {
264 if ( event->state() == QMouseEvent::LeftButton ) { 253 if ( event->state() == QMouseEvent::LeftButton ) {
265 // The test to see if the mouse click is inside the button or not 254 // The test to see if the mouse click is inside the button or not
266 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); 255 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i );
267 256
268 if ( isOnButton && !buttons[i].isHeld ) { 257 if ( isOnButton && !buttons[i].isHeld ) {
269 buttons[i].isHeld = TRUE; 258 buttons[i].isHeld = TRUE;
270 toggleButton(i); 259 toggleButton(i);
271 260
272 switch (i) { 261 switch (i) {
273 case VideoVolUp: 262 case VideoVolUp:
@@ -394,32 +383,32 @@ void VideoWidget::paintEvent( QPaintEvent * pe) {
394 383
395 if ( mediaPlayerState.isFullscreen() ) { 384 if ( mediaPlayerState.isFullscreen() ) {
396 // Clear the background 385 // Clear the background
397 p.setBrush( QBrush( Qt::black ) ); 386 p.setBrush( QBrush( Qt::black ) );
398 } else { 387 } else {
399 if ( !pe->erased() ) { 388 if ( !pe->erased() ) {
400 // Combine with background and double buffer 389 // Combine with background and double buffer
401 QPixmap pix( pe->rect().size() ); 390 QPixmap pix( pe->rect().size() );
402 QPainter p( &pix ); 391 QPainter p( &pix );
403 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 392 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
404 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); 393 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() );
405 for ( unsigned int i = 0; i < buttons.count(); i++ ) { 394 for ( unsigned int i = 0; i < buttons.count(); i++ ) {
406 paintButton( p, i ); 395 paintButton( p, buttons[ i ] );
407 } 396 }
408 QPainter p2( this ); 397 QPainter p2( this );
409 p2.drawPixmap( pe->rect().topLeft(), pix ); 398 p2.drawPixmap( pe->rect().topLeft(), pix );
410 } else { 399 } else {
411 QPainter p( this ); 400 QPainter p( this );
412 for ( unsigned int i = 0; i < buttons.count(); i++ ) 401 for ( unsigned int i = 0; i < buttons.count(); i++ )
413 paintButton( p, i ); 402 paintButton( p, buttons[ i ] );
414 } 403 }
415 //slider->repaint( TRUE ); 404 //slider->repaint( TRUE );
416 } 405 }
417} 406}
418 407
419 408
420void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 409void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
421 switch ( e->key() ) { 410 switch ( e->key() ) {
422////////////////////////////// Zaurus keys 411////////////////////////////// Zaurus keys
423 case Key_Home: 412 case Key_Home:
424 break; 413 break;
425 case Key_F9: //activity 414 case Key_F9: //activity
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index 937feac..a271120 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -94,25 +94,24 @@ protected:
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 QString skin; 103 QString skin;
104 104
105 105
106 virtual void paintButton( QPainter &p, int i );
107 void setToggleButton( int, bool ); 106 void setToggleButton( int, bool );
108 107
109 QString backgroundPix; 108 QString backgroundPix;
110 QSlider *slider; 109 QSlider *slider;
111 QImage *currentFrame; 110 QImage *currentFrame;
112 int scaledWidth; 111 int scaledWidth;
113 int scaledHeight; 112 int scaledHeight;
114 XineVideoWidget* videoFrame; 113 XineVideoWidget* videoFrame;
115}; 114};
116 115
117#endif // VIDEO_WIDGET_H 116#endif // VIDEO_WIDGET_H
118 117