summaryrefslogtreecommitdiff
Unidiff
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.cpp12
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h1
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp6
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h1
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
@@ -244,136 +244,128 @@ void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) {
244 if ( mediaType == MediaPlayerState::Audio ) { 244 if ( mediaType == MediaPlayerState::Audio ) {
245 // startTimer( 150 ); 245 // startTimer( 150 );
246 showMaximized(); 246 showMaximized();
247 return; 247 return;
248 } 248 }
249 249
250 killTimers(); 250 killTimers();
251 hide(); 251 hide();
252} 252}
253 253
254 254
255void AudioWidget::setSeekable( bool isSeekable ) { 255void AudioWidget::setSeekable( bool isSeekable ) {
256 256
257 if ( !isSeekable ) { 257 if ( !isSeekable ) {
258 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); 258 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
259 if( !slider.isHidden()) { 259 if( !slider.isHidden()) {
260 slider.hide(); 260 slider.hide();
261 } 261 }
262 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 262 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
263 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 263 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
264 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 264 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
265 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 265 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
266 } else { 266 } else {
267 // this stops the slider from being moved, thus 267 // this stops the slider from being moved, thus
268 // does not stop stream when it reaches the end 268 // does not stop stream when it reaches the end
269 slider.show(); 269 slider.show();
270 qDebug( " CONNECT SET POSTION " ); 270 qDebug( " CONNECT SET POSTION " );
271 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 271 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
272 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 272 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
273 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 273 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
274 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 274 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
275 } 275 }
276} 276}
277 277
278 278
279static QString timeAsString( long length ) { 279static QString timeAsString( long length ) {
280 int minutes = length / 60; 280 int minutes = length / 60;
281 int seconds = length % 60; 281 int seconds = length % 60;
282 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 282 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
283} 283}
284 284
285void AudioWidget::updateSlider( long i, long max ) { 285void AudioWidget::updateSlider( long i, long max ) {
286 286
287 time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); 287 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
288// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; 288// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ;
289 289
290 if ( max == 0 ) { 290 if ( max == 0 ) {
291 return; 291 return;
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
309void AudioWidget::setToggleButton( int i, bool down ) {
310 qDebug("setToggleButton %d", i);
311 if ( down != buttons[i].isDown ) {
312 toggleButton( i );
313 }
314}
315
316void AudioWidget::skipFor() { 308void 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
322void AudioWidget::skipBack() { 314void 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
330void AudioWidget::stopSkip() { 322void AudioWidget::stopSkip() {
331 killTimers(); 323 killTimers();
332} 324}
333 325
334 326
335void AudioWidget::timerEvent( QTimerEvent * ) { 327void AudioWidget::timerEvent( QTimerEvent * ) {
336 if ( skipDirection == +1 ) { 328 if ( skipDirection == +1 ) {
337 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); 329 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
338 } else if ( skipDirection == -1 ) { 330 } else if ( skipDirection == -1 ) {
339 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); 331 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
340 } 332 }
341} 333}
342 334
343 335
344void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 336void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
345 for ( unsigned int i = 0; i < buttons.count(); i++ ) { 337 for ( unsigned int i = 0; i < buttons.count(); i++ ) {
346 if ( event->state() == QMouseEvent::LeftButton ) { 338 if ( event->state() == QMouseEvent::LeftButton ) {
347 // The test to see if the mouse click is inside the button or not 339 // The test to see if the mouse click is inside the button or not
348 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); 340 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i );
349 341
350 if ( isOnButton && !buttons[i].isHeld ) { 342 if ( isOnButton && !buttons[i].isHeld ) {
351 buttons[i].isHeld = TRUE; 343 buttons[i].isHeld = TRUE;
352 toggleButton(i); 344 toggleButton(i);
353 switch (i) { 345 switch (i) {
354 case VolumeUp: 346 case VolumeUp:
355 emit moreClicked(); 347 emit moreClicked();
356 return; 348 return;
357 case VolumeDown: 349 case VolumeDown:
358 emit lessClicked(); 350 emit lessClicked();
359 return; 351 return;
360 case Forward: 352 case Forward:
361 emit forwardClicked(); 353 emit forwardClicked();
362 return; 354 return;
363 case Back: 355 case Back:
364 emit backClicked(); 356 emit backClicked();
365 return; 357 return;
366 } 358 }
367 } else if ( !isOnButton && buttons[i].isHeld ) { 359 } else if ( !isOnButton && buttons[i].isHeld ) {
368 buttons[i].isHeld = FALSE; 360 buttons[i].isHeld = FALSE;
369 toggleButton(i); 361 toggleButton(i);
370 } 362 }
371 } else { 363 } else {
372 if ( buttons[i].isHeld ) { 364 if ( buttons[i].isHeld ) {
373 buttons[i].isHeld = FALSE; 365 buttons[i].isHeld = FALSE;
374 if ( buttons[i].type != ToggleButton ) { 366 if ( buttons[i].type != ToggleButton ) {
375 setToggleButton( i, FALSE ); 367 setToggleButton( i, FALSE );
376 } 368 }
377 qDebug("mouseEvent %d", i); 369 qDebug("mouseEvent %d", i);
378 handleCommand( static_cast<Command>( i ), buttons[ i ].isDown ); 370 handleCommand( static_cast<Command>( i ), buttons[ i ].isDown );
379 } 371 }
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
@@ -29,80 +29,79 @@
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef AUDIO_WIDGET_H 34#ifndef AUDIO_WIDGET_H
35#define AUDIO_WIDGET_H 35#define AUDIO_WIDGET_H
36 36
37#include <qpainter.h> 37#include <qpainter.h>
38#include <qdrawutil.h> 38#include <qdrawutil.h>
39#include <qpixmap.h> 39#include <qpixmap.h>
40#include <qstring.h> 40#include <qstring.h>
41#include <qslider.h> 41#include <qslider.h>
42#include <qframe.h> 42#include <qframe.h>
43#include <qlineedit.h> 43#include <qlineedit.h>
44#include <qimage.h> 44#include <qimage.h>
45 45
46#include <opie/oticker.h> 46#include <opie/oticker.h>
47 47
48#include "mediawidget.h" 48#include "mediawidget.h"
49 49
50class QPixmap; 50class QPixmap;
51 51
52class AudioWidget : public MediaWidget { 52class AudioWidget : public MediaWidget {
53 Q_OBJECT 53 Q_OBJECT
54public: 54public:
55 AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); 55 AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 );
56 ~AudioWidget(); 56 ~AudioWidget();
57 void setTickerText( const QString &text ) { songInfo.setText( text ); } 57 void setTickerText( const QString &text ) { songInfo.setText( text ); }
58public slots: 58public slots:
59 void updateSlider( long, long ); 59 void updateSlider( long, long );
60 void sliderPressed( ); 60 void sliderPressed( );
61 void sliderReleased( ); 61 void sliderReleased( );
62 void setLooping( bool b) { setToggleButton( Loop, b ); } 62 void setLooping( bool b) { setToggleButton( Loop, b ); }
63 void setPosition( long ); 63 void setPosition( long );
64 void setSeekable( bool ); 64 void setSeekable( bool );
65 65
66public: 66public:
67 virtual void setLength( long ); 67 virtual void setLength( long );
68 virtual void setPlaying( bool b) { setToggleButton( Play, b ); } 68 virtual void setPlaying( bool b) { setToggleButton( Play, b ); }
69 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); 69 virtual void setDisplayType( MediaPlayerState::DisplayType displayType );
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 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);
88private slots: 88private slots:
89 void skipFor(); 89 void skipFor();
90 void skipBack(); 90 void skipBack();
91 void stopSkip(); 91 void stopSkip();
92private: 92private:
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
@@ -36,92 +36,102 @@ MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPla
36} 36}
37 37
38MediaWidget::~MediaWidget() 38MediaWidget::~MediaWidget()
39{ 39{
40} 40}
41 41
42void MediaWidget::closeEvent( QCloseEvent * ) 42void MediaWidget::closeEvent( QCloseEvent * )
43{ 43{
44 mediaPlayerState.setList(); 44 mediaPlayerState.setList();
45} 45}
46 46
47void MediaWidget::paintEvent( QPaintEvent *pe ) 47void MediaWidget::paintEvent( QPaintEvent *pe )
48{ 48{
49 QPainter p( this ); 49 QPainter p( this );
50 50
51 if ( mediaPlayerState.isFullscreen() ) { 51 if ( mediaPlayerState.isFullscreen() ) {
52 // Clear the background 52 // Clear the background
53 p.setBrush( QBrush( Qt::black ) ); 53 p.setBrush( QBrush( Qt::black ) );
54 return; 54 return;
55 } 55 }
56 56
57 if ( !pe->erased() ) { 57 if ( !pe->erased() ) {
58 // Combine with background and double buffer 58 // Combine with background and double buffer
59 QPixmap pix( pe->rect().size() ); 59 QPixmap pix( pe->rect().size() );
60 QPainter p( &pix ); 60 QPainter p( &pix );
61 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 61 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
62 p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() ); 62 p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() );
63 paintAllButtons( p ); 63 paintAllButtons( p );
64 QPainter p2( this ); 64 QPainter p2( this );
65 p2.drawPixmap( pe->rect().topLeft(), pix ); 65 p2.drawPixmap( pe->rect().topLeft(), pix );
66 } else { 66 } else {
67 QPainter p( this ); 67 QPainter p( this );
68 paintAllButtons( p ); 68 paintAllButtons( p );
69 } 69 }
70} 70}
71 71
72void MediaWidget::handleCommand( Command command, bool buttonDown ) 72void MediaWidget::handleCommand( Command command, bool buttonDown )
73{ 73{
74 switch ( command ) { 74 switch ( command ) {
75 case Play: mediaPlayerState.togglePaused(); 75 case Play: mediaPlayerState.togglePaused();
76 case Stop: mediaPlayerState.setPlaying(FALSE); return; 76 case Stop: mediaPlayerState.setPlaying(FALSE); return;
77 case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; 77 case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
78 case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; 78 case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
79 case Loop: mediaPlayerState.setLooping( buttonDown ); return; 79 case Loop: mediaPlayerState.setLooping( buttonDown ); return;
80 case VolumeUp: emit moreReleased(); return; 80 case VolumeUp: emit moreReleased(); return;
81 case VolumeDown: emit lessReleased(); return; 81 case VolumeDown: emit lessReleased(); return;
82 case PlayList: mediaPlayerState.setList(); return; 82 case PlayList: mediaPlayerState.setList(); return;
83 case Forward: emit forwardReleased(); return; 83 case Forward: emit forwardReleased(); return;
84 case Back: emit backReleased(); return; 84 case Back: emit backReleased(); return;
85 } 85 }
86} 86}
87 87
88bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const 88bool 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
96void MediaWidget::paintAllButtons( QPainter &p ) 96void 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
103void MediaWidget::paintButton( const Button &button ) 103void 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
109void MediaWidget::paintButton( QPainter &p, const Button &button ) 109void 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
117void 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
117void MediaWidget::toggleButton( int buttonId ) 127void 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
@@ -30,81 +30,82 @@
30#include "playlistwidget.h" 30#include "playlistwidget.h"
31 31
32#include <vector> 32#include <vector>
33 33
34class MediaWidget : public QWidget 34class MediaWidget : public QWidget
35{ 35{
36 Q_OBJECT 36 Q_OBJECT
37public: 37public:
38 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back }; 38 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back };
39 enum ButtonType { NormalButton, ToggleButton }; 39 enum ButtonType { NormalButton, ToggleButton };
40 40
41 struct Button 41 struct Button
42 { 42 {
43 Button() : type( NormalButton ), isHeld( false ), isDown( false ) {} 43 Button() : type( NormalButton ), isHeld( false ), isDown( false ) {}
44 44
45 ButtonType type : 1; 45 ButtonType type : 1;
46 bool isHeld : 1; 46 bool isHeld : 1;
47 bool isDown : 1; 47 bool isDown : 1;
48 48
49 QBitmap mask; 49 QBitmap mask;
50 QPixmap pixUp; 50 QPixmap pixUp;
51 QPixmap pixDown; 51 QPixmap pixDown;
52 }; 52 };
53 typedef std::vector<Button> ButtonVector; 53 typedef std::vector<Button> ButtonVector;
54 // when the transition is done this should be Command -> Button 54 // when the transition is done this should be Command -> Button
55 typedef QMap<int, Button> ButtonMap; 55 typedef QMap<int, Button> ButtonMap;
56 56
57 struct SkinButtonInfo 57 struct SkinButtonInfo
58 { 58 {
59 Command command; 59 Command command;
60 const char *fileName; 60 const char *fileName;
61 ButtonType type; 61 ButtonType type;
62 }; 62 };
63 63
64 typedef std::vector<QBitmap> MaskVector; 64 typedef std::vector<QBitmap> MaskVector;
65 typedef std::vector<QPixmap> PixmapVector; 65 typedef std::vector<QPixmap> PixmapVector;
66 66
67 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); 67 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 );
68 virtual ~MediaWidget(); 68 virtual ~MediaWidget();
69 69
70public slots: 70public slots:
71 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; 71 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0;
72 virtual void setLength( long length ) = 0; 72 virtual void setLength( long length ) = 0;
73 virtual void setPlaying( bool playing ) = 0; 73 virtual void setPlaying( bool playing ) = 0;
74 74
75signals: 75signals:
76 void moreReleased(); 76 void moreReleased();
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 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
110 */ 111 */
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
@@ -181,134 +181,128 @@ void VideoWidget::resizeEvent( QResizeEvent * ) {
181 if ( !button.mask.isNull() ) { 181 if ( !button.mask.isNull() ) {
182 button.pixUp = maskVPixToMask( *pixUp, button.mask ); 182 button.pixUp = maskVPixToMask( *pixUp, button.mask );
183 button.pixDown = maskVPixToMask( *pixDn, button.mask ); 183 button.pixDown = maskVPixToMask( *pixDn, button.mask );
184 } 184 }
185 } 185 }
186 186
187 delete pixUp; 187 delete pixUp;
188 delete pixDn; 188 delete pixDn;
189} 189}
190 190
191static bool videoSliderBeingMoved = FALSE; 191static bool videoSliderBeingMoved = FALSE;
192 192
193void VideoWidget::sliderPressed() { 193void VideoWidget::sliderPressed() {
194 videoSliderBeingMoved = TRUE; 194 videoSliderBeingMoved = TRUE;
195} 195}
196 196
197void VideoWidget::sliderReleased() { 197void VideoWidget::sliderReleased() {
198 videoSliderBeingMoved = FALSE; 198 videoSliderBeingMoved = FALSE;
199 if ( slider->width() == 0 ) { 199 if ( slider->width() == 0 ) {
200 return; 200 return;
201 } 201 }
202 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); 202 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width());
203 mediaPlayerState.setPosition( val ); 203 mediaPlayerState.setPosition( val );
204} 204}
205 205
206void VideoWidget::setPosition( long i ) { 206void VideoWidget::setPosition( long i ) {
207 updateSlider( i, mediaPlayerState.length() ); 207 updateSlider( i, mediaPlayerState.length() );
208} 208}
209 209
210 210
211void VideoWidget::setLength( long max ) { 211void VideoWidget::setLength( long max ) {
212 updateSlider( mediaPlayerState.position(), max ); 212 updateSlider( mediaPlayerState.position(), max );
213} 213}
214 214
215void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) 215void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
216{ 216{
217 if ( displayType == MediaPlayerState::Video ) { 217 if ( displayType == MediaPlayerState::Video ) {
218 makeVisible(); 218 makeVisible();
219 return; 219 return;
220 } 220 }
221 221
222 // Effectively blank the view next time we show it so it looks nicer 222 // Effectively blank the view next time we show it so it looks nicer
223 scaledWidth = 0; 223 scaledWidth = 0;
224 scaledHeight = 0; 224 scaledHeight = 0;
225 hide(); 225 hide();
226} 226}
227 227
228void VideoWidget::updateSlider( long i, long max ) { 228void 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
245void VideoWidget::setToggleButton( int i, bool down ) {
246 if ( down != buttons[i].isDown ) {
247 toggleButton( i );
248 }
249}
250
251void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 245void 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();
267 return; 261 return;
268 } 262 }
269 } else if ( !isOnButton && buttons[i].isHeld ) { 263 } else if ( !isOnButton && buttons[i].isHeld ) {
270 buttons[i].isHeld = FALSE; 264 buttons[i].isHeld = FALSE;
271 toggleButton(i); 265 toggleButton(i);
272 } 266 }
273 } else { 267 } else {
274 268
275 if ( buttons[i].isHeld ) { 269 if ( buttons[i].isHeld ) {
276 buttons[i].isHeld = FALSE; 270 buttons[i].isHeld = FALSE;
277 if ( buttons[i].type != ToggleButton ) { 271 if ( buttons[i].type != ToggleButton ) {
278 setToggleButton( i, FALSE ); 272 setToggleButton( i, FALSE );
279 } 273 }
280 274
281 switch(i) { 275 switch(i) {
282 276
283 case VideoPlay: { 277 case VideoPlay: {
284 if( mediaPlayerState.isPaused() ) { 278 if( mediaPlayerState.isPaused() ) {
285 setToggleButton( i, FALSE ); 279 setToggleButton( i, FALSE );
286 mediaPlayerState.setPaused( FALSE ); 280 mediaPlayerState.setPaused( FALSE );
287 return; 281 return;
288 } else if( !mediaPlayerState.isPaused() ) { 282 } else if( !mediaPlayerState.isPaused() ) {
289 setToggleButton( i, TRUE ); 283 setToggleButton( i, TRUE );
290 mediaPlayerState.setPaused( TRUE ); 284 mediaPlayerState.setPaused( TRUE );
291 return; 285 return;
292 } else { 286 } else {
293 return; 287 return;
294 } 288 }
295 } 289 }
296 290
297 case VideoStop: mediaPlayerState.setPlaying( FALSE ); return; 291 case VideoStop: mediaPlayerState.setPlaying( FALSE ); return;
298 case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; 292 case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
299 case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; 293 case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
300 case VideoVolUp: emit moreReleased(); return; 294 case VideoVolUp: emit moreReleased(); return;
301 case VideoVolDown: emit lessReleased(); return; 295 case VideoVolDown: emit lessReleased(); return;
302 case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return; 296 case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return;
303 } 297 }
304 } 298 }
305 } 299 }
306 } 300 }
307} 301}
308 302
309void VideoWidget::mousePressEvent( QMouseEvent *event ) { 303void VideoWidget::mousePressEvent( QMouseEvent *event ) {
310 mouseMoveEvent( event ); 304 mouseMoveEvent( event );
311} 305}
312 306
313void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 307void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
314 if ( mediaPlayerState.isFullscreen() ) { 308 if ( mediaPlayerState.isFullscreen() ) {
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
@@ -40,78 +40,77 @@
40#include "xinevideowidget.h" 40#include "xinevideowidget.h"
41 41
42#include "mediawidget.h" 42#include "mediawidget.h"
43 43
44class QPixmap; 44class QPixmap;
45class QSlider; 45class QSlider;
46 46
47enum VideoButtons { 47enum VideoButtons {
48 VideoPlay = 0, 48 VideoPlay = 0,
49 VideoStop, 49 VideoStop,
50// VideoPause, 50// VideoPause,
51 VideoNext, 51 VideoNext,
52 VideoPrevious, 52 VideoPrevious,
53 VideoVolUp, 53 VideoVolUp,
54 VideoVolDown, 54 VideoVolDown,
55 VideoFullscreen 55 VideoFullscreen
56}; 56};
57 57
58class VideoWidget : public MediaWidget { 58class VideoWidget : public MediaWidget {
59 Q_OBJECT 59 Q_OBJECT
60public: 60public:
61 VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); 61 VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 );
62 ~VideoWidget(); 62 ~VideoWidget();
63 63
64 64
65 XineVideoWidget* vidWidget(); 65 XineVideoWidget* vidWidget();
66public slots: 66public slots:
67 void updateSlider( long, long ); 67 void updateSlider( long, long );
68 void sliderPressed( ); 68 void sliderPressed( );
69 void sliderReleased( ); 69 void sliderReleased( );
70 void setFullscreen( bool b ); 70 void setFullscreen( bool b );
71 void makeVisible(); 71 void makeVisible();
72 void backToNormal(); 72 void backToNormal();
73 void setPosition( long ); 73 void setPosition( long );
74 74
75public: 75public:
76 virtual void setPlaying( bool b); 76 virtual void setPlaying( bool b);
77 virtual void setLength( long ); 77 virtual void setLength( long );
78 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); 78 virtual void setDisplayType( MediaPlayerState::DisplayType displayType );
79 79
80signals: 80signals:
81 void moreClicked(); 81 void moreClicked();
82 void lessClicked(); 82 void lessClicked();
83 void moreReleased(); 83 void moreReleased();
84 void lessReleased(); 84 void lessReleased();
85 void sliderMoved( long ); 85 void sliderMoved( long );
86 void videoResized ( const QSize &s ); 86 void videoResized ( const QSize &s );
87 87
88protected: 88protected:
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
97private: 97private:
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