summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp14
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.h1
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h2
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp16
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h1
5 files changed, 17 insertions, 17 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 022aa82..4301a67 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -170,99 +170,99 @@ AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye
170 setPosition( mediaPlayerState.position() ); 170 setPosition( mediaPlayerState.position() );
171 setLooping( mediaPlayerState.isFullscreen() ); 171 setLooping( mediaPlayerState.isFullscreen() );
172 // setPaused( mediaPlayerState->paused() ); 172 // setPaused( mediaPlayerState->paused() );
173 setPlaying( mediaPlayerState.isPlaying() ); 173 setPlaying( mediaPlayerState.isPlaying() );
174 174
175} 175}
176 176
177AudioWidget::~AudioWidget() { 177AudioWidget::~AudioWidget() {
178 178
179 for ( int i = 0; i < 10; i++ ) { 179 for ( int i = 0; i < 10; i++ ) {
180 delete buttonPixUp[i]; 180 delete buttonPixUp[i];
181 delete buttonPixDown[i]; 181 delete buttonPixDown[i];
182 } 182 }
183 for ( int i = 0; i < 10; i++ ) { 183 for ( int i = 0; i < 10; i++ ) {
184 delete masks[i]; 184 delete masks[i];
185 } 185 }
186// mediaPlayerState->setPlaying(false); 186// mediaPlayerState->setPlaying(false);
187} 187}
188 188
189namespace { 189namespace {
190 190
191QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 191QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
192 QPixmap pix( img.width(), img.height() ); 192 QPixmap pix( img.width(), img.height() );
193 QPainter p( &pix ); 193 QPainter p( &pix );
194 p.drawTiledPixmap( pix.rect(), bg, offset ); 194 p.drawTiledPixmap( pix.rect(), bg, offset );
195 p.drawImage( 0, 0, img ); 195 p.drawImage( 0, 0, img );
196 return pix; 196 return pix;
197} 197}
198 198
199 199
200QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { 200QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) {
201 QPixmap *pixmap = new QPixmap( pix ); 201 QPixmap *pixmap = new QPixmap( pix );
202 pixmap->setMask( mask ); 202 pixmap->setMask( mask );
203 return pixmap; 203 return pixmap;
204} 204}
205 205
206}; 206};
207 207
208void AudioWidget::resizeEvent( QResizeEvent * ) { 208void AudioWidget::resizeEvent( QResizeEvent * ) {
209 int h = height(); 209 int h = height();
210 int w = width(); 210 int w = width();
211 211
212 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); 212 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) );
213 slider.setFixedWidth( w - 110 ); 213 slider.setFixedWidth( w - 110 );
214 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 214 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
215 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 215 slider.setBackgroundOrigin( QWidget::ParentOrigin );
216 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 216 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
217 217
218 xoff = ( w - imgUp.width() ) / 2; 218 upperLeftOfButtonMask.rx() = ( w - imgUp.width() ) / 2;
219 yoff = (( h - imgUp.height() ) / 2) - 10; 219 upperLeftOfButtonMask.ry() = (( h - imgUp.height() ) / 2) - 10;
220 QPoint p( xoff, yoff ); 220 QPoint p = upperLeftOfButtonMask;
221 221
222 QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p ); 222 QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p );
223 QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p ); 223 QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p );
224 224
225 for ( int i = 0; i < 10; i++ ) { 225 for ( int i = 0; i < 10; i++ ) {
226 if ( !masks[i]->isNull() ) { 226 if ( !masks[i]->isNull() ) {
227 delete buttonPixUp[i]; 227 delete buttonPixUp[i];
228 delete buttonPixDown[i]; 228 delete buttonPixDown[i];
229 buttonPixUp[i] = maskPixToMask( pixUp, *masks[i] ); 229 buttonPixUp[i] = maskPixToMask( pixUp, *masks[i] );
230 buttonPixDown[i] = maskPixToMask( pixDn, *masks[i] ); 230 buttonPixDown[i] = maskPixToMask( pixDn, *masks[i] );
231 } 231 }
232 } 232 }
233} 233}
234 234
235static bool audioSliderBeingMoved = FALSE; 235static bool audioSliderBeingMoved = FALSE;
236 236
237 237
238void AudioWidget::sliderPressed() { 238void AudioWidget::sliderPressed() {
239 audioSliderBeingMoved = TRUE; 239 audioSliderBeingMoved = TRUE;
240} 240}
241 241
242 242
243void AudioWidget::sliderReleased() { 243void AudioWidget::sliderReleased() {
244 audioSliderBeingMoved = FALSE; 244 audioSliderBeingMoved = FALSE;
245 if ( slider.width() == 0 ) 245 if ( slider.width() == 0 )
246 return; 246 return;
247 long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); 247 long val = long((double)slider.value() * mediaPlayerState.length() / slider.width());
248 mediaPlayerState.setPosition( val ); 248 mediaPlayerState.setPosition( val );
249} 249}
250 250
251void AudioWidget::setPosition( long i ) { 251void AudioWidget::setPosition( long i ) {
252 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); 252 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i);
253 updateSlider( i, mediaPlayerState.length() ); 253 updateSlider( i, mediaPlayerState.length() );
254} 254}
255 255
256 256
257void AudioWidget::setLength( long max ) { 257void AudioWidget::setLength( long max ) {
258 updateSlider( mediaPlayerState.position(), max ); 258 updateSlider( mediaPlayerState.position(), max );
259} 259}
260 260
261 261
262void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { 262void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) {
263 if ( mediaType == MediaPlayerState::Audio ) { 263 if ( mediaType == MediaPlayerState::Audio ) {
264 // startTimer( 150 ); 264 // startTimer( 150 );
265 showMaximized(); 265 showMaximized();
266 return; 266 return;
267 } 267 }
268 268
@@ -297,137 +297,137 @@ void AudioWidget::setSeekable( bool isSeekable ) {
297 297
298static QString timeAsString( long length ) { 298static QString timeAsString( long length ) {
299 int minutes = length / 60; 299 int minutes = length / 60;
300 int seconds = length % 60; 300 int seconds = length % 60;
301 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 301 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
302} 302}
303 303
304void AudioWidget::updateSlider( long i, long max ) { 304void AudioWidget::updateSlider( long i, long max ) {
305 305
306 time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); 306 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
307// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; 307// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ;
308 308
309 if ( max == 0 ) { 309 if ( max == 0 ) {
310 return; 310 return;
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 335
336void AudioWidget::toggleButton( int i ) { 336void AudioWidget::toggleButton( int i ) {
337 buttons[i].isDown = !buttons[i].isDown; 337 buttons[i].isDown = !buttons[i].isDown;
338 QPainter p(this); 338 QPainter p(this);
339 paintButton ( &p, i ); 339 paintButton ( &p, i );
340} 340}
341 341
342 342
343void AudioWidget::paintButton( QPainter *p, int i ) { 343void AudioWidget::paintButton( QPainter *p, int i ) {
344 if ( buttons[i].isDown ) { 344 if ( buttons[i].isDown ) {
345 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 345 p->drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] );
346 } else { 346 } else {
347 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 347 p->drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] );
348 } 348 }
349} 349}
350 350
351 351
352void AudioWidget::skipFor() { 352void AudioWidget::skipFor() {
353 skipDirection = +1; 353 skipDirection = +1;
354 startTimer( 50 ); 354 startTimer( 50 );
355 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); 355 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
356} 356}
357 357
358void AudioWidget::skipBack() { 358void AudioWidget::skipBack() {
359 skipDirection = -1; 359 skipDirection = -1;
360 startTimer( 50 ); 360 startTimer( 50 );
361 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); 361 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
362} 362}
363 363
364 364
365 365
366void AudioWidget::stopSkip() { 366void AudioWidget::stopSkip() {
367 killTimers(); 367 killTimers();
368} 368}
369 369
370 370
371void AudioWidget::timerEvent( QTimerEvent * ) { 371void AudioWidget::timerEvent( QTimerEvent * ) {
372 if ( skipDirection == +1 ) { 372 if ( skipDirection == +1 ) {
373 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); 373 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
374 } else if ( skipDirection == -1 ) { 374 } else if ( skipDirection == -1 ) {
375 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); 375 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
376 } 376 }
377} 377}
378 378
379 379
380void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 380void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
381 for ( unsigned int i = 0; i < buttons.size(); i++ ) { 381 for ( unsigned int i = 0; i < buttons.size(); i++ ) {
382 if ( event->state() == QMouseEvent::LeftButton ) { 382 if ( event->state() == QMouseEvent::LeftButton ) {
383 // The test to see if the mouse click is inside the button or not 383 // The test to see if the mouse click is inside the button or not
384 int x = event->pos().x() - xoff; 384 int x = event->pos().x() - upperLeftOfButtonMask.x();
385 int y = event->pos().y() - yoff; 385 int y = event->pos().y() - upperLeftOfButtonMask.y();
386 386
387 bool isOnButton = ( x > 0 && y > 0 && x < buttonMask.width() 387 bool isOnButton = ( x > 0 && y > 0 && x < buttonMask.width()
388 && y < buttonMask.height() 388 && y < buttonMask.height()
389 && buttonMask.pixelIndex( x, y ) == i + 1 ); 389 && buttonMask.pixelIndex( x, y ) == i + 1 );
390 390
391 if ( isOnButton && !buttons[i].isHeld ) { 391 if ( isOnButton && !buttons[i].isHeld ) {
392 buttons[i].isHeld = TRUE; 392 buttons[i].isHeld = TRUE;
393 toggleButton(i); 393 toggleButton(i);
394 switch (i) { 394 switch (i) {
395 case VolumeUp: 395 case VolumeUp:
396 emit moreClicked(); 396 emit moreClicked();
397 return; 397 return;
398 case VolumeDown: 398 case VolumeDown:
399 emit lessClicked(); 399 emit lessClicked();
400 return; 400 return;
401 case Forward: 401 case Forward:
402 emit forwardClicked(); 402 emit forwardClicked();
403 return; 403 return;
404 case Back: 404 case Back:
405 emit backClicked(); 405 emit backClicked();
406 return; 406 return;
407 } 407 }
408 } else if ( !isOnButton && buttons[i].isHeld ) { 408 } else if ( !isOnButton && buttons[i].isHeld ) {
409 buttons[i].isHeld = FALSE; 409 buttons[i].isHeld = FALSE;
410 toggleButton(i); 410 toggleButton(i);
411 } 411 }
412 } else { 412 } else {
413 if ( buttons[i].isHeld ) { 413 if ( buttons[i].isHeld ) {
414 buttons[i].isHeld = FALSE; 414 buttons[i].isHeld = FALSE;
415 if ( !buttons[i].isToggle ) { 415 if ( !buttons[i].isToggle ) {
416 setToggleButton( i, FALSE ); 416 setToggleButton( i, FALSE );
417 } 417 }
418 qDebug("mouseEvent %d", i); 418 qDebug("mouseEvent %d", i);
419 handleCommand( static_cast<Command>( i ), buttons[ i ].isDown ); 419 handleCommand( static_cast<Command>( i ), buttons[ i ].isDown );
420 } 420 }
421 } 421 }
422 } 422 }
423} 423}
424 424
425 425
426void AudioWidget::mousePressEvent( QMouseEvent *event ) { 426void AudioWidget::mousePressEvent( QMouseEvent *event ) {
427 mouseMoveEvent( event ); 427 mouseMoveEvent( event );
428} 428}
429 429
430 430
431void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 431void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
432 mouseMoveEvent( event ); 432 mouseMoveEvent( event );
433} 433}
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h
index da22946..acf2dda 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.h
+++ b/noncore/multimedia/opieplayer2/audiowidget.h
@@ -62,55 +62,54 @@ public slots:
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 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 ); 94 void toggleButton( int );
95 void setToggleButton( int, bool ); 95 void setToggleButton( int, bool );
96 void paintButton( QPainter *p, int i ); 96 void paintButton( QPainter *p, int i );
97 int skipDirection; 97 int skipDirection;
98 QString skin; 98 QString skin;
99 QPixmap pixBg; 99 QPixmap pixBg;
100 QImage imgUp; 100 QImage imgUp;
101 QImage imgDn; 101 QImage imgDn;
102 QBitmap *masks[10]; 102 QBitmap *masks[10];
103 QPixmap *buttonPixUp[10]; 103 QPixmap *buttonPixUp[10];
104 QPixmap *buttonPixDown[10]; 104 QPixmap *buttonPixDown[10];
105 105
106 QPixmap *pixmaps[4]; 106 QPixmap *pixmaps[4];
107 OTicker songInfo; 107 OTicker songInfo;
108 QSlider slider; 108 QSlider slider;
109 QLineEdit time; 109 QLineEdit time;
110 int xoff, yoff;
111 bool isStreaming : 1; 110 bool isStreaming : 1;
112}; 111};
113 112
114 113
115#endif // AUDIO_WIDGET_H 114#endif // AUDIO_WIDGET_H
116 115
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index 044ab6c..7e6cb3b 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -26,53 +26,55 @@
26#include <qwidget.h> 26#include <qwidget.h>
27 27
28#include "mediaplayerstate.h" 28#include "mediaplayerstate.h"
29#include "playlistwidget.h" 29#include "playlistwidget.h"
30 30
31#include <vector> 31#include <vector>
32 32
33class MediaWidget : public QWidget 33class MediaWidget : public QWidget
34{ 34{
35 Q_OBJECT 35 Q_OBJECT
36public: 36public:
37 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back }; 37 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back };
38 38
39 struct Button 39 struct Button
40 { 40 {
41 Button() : isToggle( false ), isHeld( false ), isDown( false ) {} 41 Button() : isToggle( false ), isHeld( false ), isDown( false ) {}
42 42
43 bool isToggle : 1; 43 bool isToggle : 1;
44 bool isHeld : 1; 44 bool isHeld : 1;
45 bool isDown : 1; 45 bool isDown : 1;
46 }; 46 };
47 typedef std::vector<Button> ButtonVector; 47 typedef std::vector<Button> ButtonVector;
48 48
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 MediaPlayerState &mediaPlayerState; 68 MediaPlayerState &mediaPlayerState;
69 PlayListWidget &playList; 69 PlayListWidget &playList;
70 70
71 ButtonVector buttons; 71 ButtonVector buttons;
72 72
73 QImage buttonMask; 73 QImage buttonMask;
74
75 QPoint upperLeftOfButtonMask;
74}; 76};
75 77
76#endif // MEDIAWIDGET_H 78#endif // MEDIAWIDGET_H
77/* vim: et sw=4 ts=4 79/* vim: et sw=4 ts=4
78 */ 80 */
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 459f592..6ab6d7b 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -135,200 +135,200 @@ VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye
135 resizeEvent( NULL ); 135 resizeEvent( NULL );
136 136
137 setLength( mediaPlayerState.length() ); 137 setLength( mediaPlayerState.length() );
138 setPosition( mediaPlayerState.position() ); 138 setPosition( mediaPlayerState.position() );
139 setFullscreen( mediaPlayerState.isFullscreen() ); 139 setFullscreen( mediaPlayerState.isFullscreen() );
140 setPlaying( mediaPlayerState.isPlaying() ); 140 setPlaying( mediaPlayerState.isPlaying() );
141} 141}
142 142
143 143
144VideoWidget::~VideoWidget() { 144VideoWidget::~VideoWidget() {
145 145
146 for ( int i = 0; i < 7; i++ ) { 146 for ( int i = 0; i < 7; i++ ) {
147 delete buttonPixUp[i]; 147 delete buttonPixUp[i];
148 delete buttonPixDown[i]; 148 delete buttonPixDown[i];
149 } 149 }
150 150
151 for ( int i = 0; i < 7; i++ ) { 151 for ( int i = 0; i < 7; i++ ) {
152 delete masks[i]; 152 delete masks[i];
153 } 153 }
154 154
155} 155}
156 156
157QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 157QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
158 QPixmap pix( img.width(), img.height() ); 158 QPixmap pix( img.width(), img.height() );
159 QPainter p( &pix ); 159 QPainter p( &pix );
160 p.drawTiledPixmap( pix.rect(), bg, offset ); 160 p.drawTiledPixmap( pix.rect(), bg, offset );
161 p.drawImage( 0, 0, img ); 161 p.drawImage( 0, 0, img );
162 return new QPixmap( pix ); 162 return new QPixmap( pix );
163} 163}
164 164
165QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { 165QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) {
166 QPixmap *pixmap = new QPixmap( pix ); 166 QPixmap *pixmap = new QPixmap( pix );
167 pixmap->setMask( mask ); 167 pixmap->setMask( mask );
168 return pixmap; 168 return pixmap;
169} 169}
170 170
171void VideoWidget::resizeEvent( QResizeEvent * ) { 171void VideoWidget::resizeEvent( QResizeEvent * ) {
172 int h = height(); 172 int h = height();
173 int w = width(); 173 int w = width();
174 //int Vh = 160; 174 //int Vh = 160;
175 //int Vw = 220; 175 //int Vw = 220;
176 176
177 slider->setFixedWidth( w - 20 ); 177 slider->setFixedWidth( w - 20 );
178 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 178 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
179 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 179 slider->setBackgroundOrigin( QWidget::ParentOrigin );
180 slider->setFocusPolicy( QWidget::NoFocus ); 180 slider->setFocusPolicy( QWidget::NoFocus );
181 slider->setBackgroundPixmap( pixBg ); 181 slider->setBackgroundPixmap( pixBg );
182 182
183 xoff = 0;// ( imgUp->width() ) / 2; 183 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2;
184 if(w>h) 184 if(w>h)
185 yoff = 0; 185 upperLeftOfButtonMask.ry() = 0;
186 else 186 else
187 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; 187 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10;
188 QPoint p( xoff, yoff ); 188 QPoint p = upperLeftOfButtonMask;
189 189
190 QPixmap *pixUp = combineVImageWithBackground( imgUp, pixBg, p ); 190 QPixmap *pixUp = combineVImageWithBackground( imgUp, pixBg, p );
191 QPixmap *pixDn = combineVImageWithBackground( imgDn, pixBg, p ); 191 QPixmap *pixDn = combineVImageWithBackground( imgDn, pixBg, p );
192 192
193 for ( int i = 0; i < 7; i++ ) { 193 for ( int i = 0; i < 7; i++ ) {
194 if ( !masks[i]->isNull() ) { 194 if ( !masks[i]->isNull() ) {
195 delete buttonPixUp[i]; 195 delete buttonPixUp[i];
196 delete buttonPixDown[i]; 196 delete buttonPixDown[i];
197 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); 197 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] );
198 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); 198 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] );
199 } 199 }
200 } 200 }
201 201
202 delete pixUp; 202 delete pixUp;
203 delete pixDn; 203 delete pixDn;
204} 204}
205 205
206static bool videoSliderBeingMoved = FALSE; 206static bool videoSliderBeingMoved = FALSE;
207 207
208void VideoWidget::sliderPressed() { 208void VideoWidget::sliderPressed() {
209 videoSliderBeingMoved = TRUE; 209 videoSliderBeingMoved = TRUE;
210} 210}
211 211
212void VideoWidget::sliderReleased() { 212void VideoWidget::sliderReleased() {
213 videoSliderBeingMoved = FALSE; 213 videoSliderBeingMoved = FALSE;
214 if ( slider->width() == 0 ) { 214 if ( slider->width() == 0 ) {
215 return; 215 return;
216 } 216 }
217 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); 217 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width());
218 mediaPlayerState.setPosition( val ); 218 mediaPlayerState.setPosition( val );
219} 219}
220 220
221void VideoWidget::setPosition( long i ) { 221void VideoWidget::setPosition( long i ) {
222 updateSlider( i, mediaPlayerState.length() ); 222 updateSlider( i, mediaPlayerState.length() );
223} 223}
224 224
225 225
226void VideoWidget::setLength( long max ) { 226void VideoWidget::setLength( long max ) {
227 updateSlider( mediaPlayerState.position(), max ); 227 updateSlider( mediaPlayerState.position(), max );
228} 228}
229 229
230void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) 230void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
231{ 231{
232 if ( displayType == MediaPlayerState::Video ) { 232 if ( displayType == MediaPlayerState::Video ) {
233 makeVisible(); 233 makeVisible();
234 return; 234 return;
235 } 235 }
236 236
237 // Effectively blank the view next time we show it so it looks nicer 237 // Effectively blank the view next time we show it so it looks nicer
238 scaledWidth = 0; 238 scaledWidth = 0;
239 scaledHeight = 0; 239 scaledHeight = 0;
240 hide(); 240 hide();
241} 241}
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 ) { 266void VideoWidget::toggleButton( int i ) {
267 buttons[i].isDown = !buttons[i].isDown; 267 buttons[i].isDown = !buttons[i].isDown;
268 QPainter p(this); 268 QPainter p(this);
269 paintButton ( &p, i ); 269 paintButton ( &p, i );
270} 270}
271 271
272void VideoWidget::paintButton( QPainter *p, int i ) { 272void VideoWidget::paintButton( QPainter *p, int i ) {
273 273
274 if ( buttons[i].isDown ) { 274 if ( buttons[i].isDown ) {
275 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 275 p->drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] );
276 } else { 276 } else {
277 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 277 p->drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] );
278 } 278 }
279} 279}
280 280
281void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 281void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
282 for ( unsigned int i = 0; i < buttons.size(); i++ ) { 282 for ( unsigned int i = 0; i < buttons.size(); i++ ) {
283 if ( event->state() == QMouseEvent::LeftButton ) { 283 if ( event->state() == QMouseEvent::LeftButton ) {
284 // The test to see if the mouse click is inside the button or not 284 // The test to see if the mouse click is inside the button or not
285 int x = event->pos().x() - xoff; 285 int x = event->pos().x() - upperLeftOfButtonMask.x();
286 int y = event->pos().y() - yoff; 286 int y = event->pos().y() - upperLeftOfButtonMask.y();
287 287
288 bool isOnButton = ( x > 0 && y > 0 && x < buttonMask.width() 288 bool isOnButton = ( x > 0 && y > 0 && x < buttonMask.width()
289 && y < buttonMask.height() 289 && y < buttonMask.height()
290 && buttonMask.pixelIndex( x, y ) == i + 1 ); 290 && buttonMask.pixelIndex( x, y ) == i + 1 );
291 291
292 if ( isOnButton && !buttons[i].isHeld ) { 292 if ( isOnButton && !buttons[i].isHeld ) {
293 buttons[i].isHeld = TRUE; 293 buttons[i].isHeld = TRUE;
294 toggleButton(i); 294 toggleButton(i);
295 295
296 switch (i) { 296 switch (i) {
297 case VideoVolUp: 297 case VideoVolUp:
298 emit moreClicked(); 298 emit moreClicked();
299 return; 299 return;
300 case VideoVolDown: 300 case VideoVolDown:
301 emit lessClicked(); 301 emit lessClicked();
302 return; 302 return;
303 } 303 }
304 } else if ( !isOnButton && buttons[i].isHeld ) { 304 } else if ( !isOnButton && buttons[i].isHeld ) {
305 buttons[i].isHeld = FALSE; 305 buttons[i].isHeld = FALSE;
306 toggleButton(i); 306 toggleButton(i);
307 } 307 }
308 } else { 308 } else {
309 309
310 if ( buttons[i].isHeld ) { 310 if ( buttons[i].isHeld ) {
311 buttons[i].isHeld = FALSE; 311 buttons[i].isHeld = FALSE;
312 if ( !buttons[i].isToggle ) { 312 if ( !buttons[i].isToggle ) {
313 setToggleButton( i, FALSE ); 313 setToggleButton( i, FALSE );
314 } 314 }
315 315
316 switch(i) { 316 switch(i) {
317 317
318 case VideoPlay: { 318 case VideoPlay: {
319 if( mediaPlayerState.isPaused() ) { 319 if( mediaPlayerState.isPaused() ) {
320 setToggleButton( i, FALSE ); 320 setToggleButton( i, FALSE );
321 mediaPlayerState.setPaused( FALSE ); 321 mediaPlayerState.setPaused( FALSE );
322 return; 322 return;
323 } else if( !mediaPlayerState.isPaused() ) { 323 } else if( !mediaPlayerState.isPaused() ) {
324 setToggleButton( i, TRUE ); 324 setToggleButton( i, TRUE );
325 mediaPlayerState.setPaused( TRUE ); 325 mediaPlayerState.setPaused( TRUE );
326 return; 326 return;
327 } else { 327 } else {
328 return; 328 return;
329 } 329 }
330 } 330 }
331 331
332 case VideoStop: mediaPlayerState.setPlaying( FALSE ); return; 332 case VideoStop: mediaPlayerState.setPlaying( FALSE ); return;
333 case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; 333 case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
334 case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; 334 case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index a5500d7..2a9f1e0 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -60,68 +60,67 @@ class VideoWidget : public MediaWidget {
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 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 int xoff, yoff;
109 108
110 109
111 void paintButton( QPainter *p, int i ); 110 void paintButton( QPainter *p, int i );
112 void toggleButton( int ); 111 void toggleButton( int );
113 void setToggleButton( int, bool ); 112 void setToggleButton( int, bool );
114 113
115 QString backgroundPix; 114 QString backgroundPix;
116 QSlider *slider; 115 QSlider *slider;
117 QPixmap *pixmaps[3]; 116 QPixmap *pixmaps[3];
118 QImage *currentFrame; 117 QImage *currentFrame;
119 int scaledWidth; 118 int scaledWidth;
120 int scaledHeight; 119 int scaledHeight;
121 XineVideoWidget* videoFrame; 120 XineVideoWidget* videoFrame;
122}; 121};
123 122
124#endif // VIDEO_WIDGET_H 123#endif // VIDEO_WIDGET_H
125 124
126 125
127 126