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
@@ -207,264 +207,256 @@ QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) {
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 upperLeftOfButtonMask.rx() = ( w - imgUp.width() ) / 2; 218 upperLeftOfButtonMask.rx() = ( w - imgUp.width() ) / 2;
219 upperLeftOfButtonMask.ry() = (( h - imgUp.height() ) / 2) - 10; 219 upperLeftOfButtonMask.ry() = (( h - imgUp.height() ) / 2) - 10;
220 QPoint p = upperLeftOfButtonMask; 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
269 killTimers(); 269 killTimers();
270 hide(); 270 hide();
271} 271}
272 272
273 273
274void AudioWidget::setSeekable( bool isSeekable ) { 274void AudioWidget::setSeekable( bool isSeekable ) {
275 275
276 if ( !isSeekable ) { 276 if ( !isSeekable ) {
277 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); 277 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
278 if( !slider.isHidden()) { 278 if( !slider.isHidden()) {
279 slider.hide(); 279 slider.hide();
280 } 280 }
281 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 281 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
282 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 282 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
283 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 283 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
284 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 284 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
285 } else { 285 } else {
286 // this stops the slider from being moved, thus 286 // this stops the slider from being moved, thus
287 // does not stop stream when it reaches the end 287 // does not stop stream when it reaches the end
288 slider.show(); 288 slider.show();
289 qDebug( " CONNECT SET POSTION " ); 289 qDebug( " CONNECT SET POSTION " );
290 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 290 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
291 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 291 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
292 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 292 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
293 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 293 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
294 } 294 }
295} 295}
296 296
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
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() {
367 killTimers(); 359 killTimers();
368} 360}
369 361
370 362
371void AudioWidget::timerEvent( QTimerEvent * ) { 363void AudioWidget::timerEvent( QTimerEvent * ) {
372 if ( skipDirection == +1 ) { 364 if ( skipDirection == +1 ) {
373 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); 365 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
374 } else if ( skipDirection == -1 ) { 366 } else if ( skipDirection == -1 ) {
375 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); 367 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
376 } 368 }
377} 369}
378 370
379 371
380void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 372void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
381 for ( unsigned int i = 0; i < buttons.size(); i++ ) { 373 for ( unsigned int i = 0; i < buttons.size(); i++ ) {
382 if ( event->state() == QMouseEvent::LeftButton ) { 374 if ( event->state() == QMouseEvent::LeftButton ) {
383 // The test to see if the mouse click is inside the button or not 375 // The test to see if the mouse click is inside the button or not
384 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); 376 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i );
385 377
386 if ( isOnButton && !buttons[i].isHeld ) { 378 if ( isOnButton && !buttons[i].isHeld ) {
387 buttons[i].isHeld = TRUE; 379 buttons[i].isHeld = TRUE;
388 toggleButton(i); 380 toggleButton(i);
389 switch (i) { 381 switch (i) {
390 case VolumeUp: 382 case VolumeUp:
391 emit moreClicked(); 383 emit moreClicked();
392 return; 384 return;
393 case VolumeDown: 385 case VolumeDown:
394 emit lessClicked(); 386 emit lessClicked();
395 return; 387 return;
396 case Forward: 388 case Forward:
397 emit forwardClicked(); 389 emit forwardClicked();
398 return; 390 return;
399 case Back: 391 case Back:
400 emit backClicked(); 392 emit backClicked();
401 return; 393 return;
402 } 394 }
403 } else if ( !isOnButton && buttons[i].isHeld ) { 395 } else if ( !isOnButton && buttons[i].isHeld ) {
404 buttons[i].isHeld = FALSE; 396 buttons[i].isHeld = FALSE;
405 toggleButton(i); 397 toggleButton(i);
406 } 398 }
407 } else { 399 } else {
408 if ( buttons[i].isHeld ) { 400 if ( buttons[i].isHeld ) {
409 buttons[i].isHeld = FALSE; 401 buttons[i].isHeld = FALSE;
410 if ( !buttons[i].isToggle ) { 402 if ( !buttons[i].isToggle ) {
411 setToggleButton( i, FALSE ); 403 setToggleButton( i, FALSE );
412 } 404 }
413 qDebug("mouseEvent %d", i); 405 qDebug("mouseEvent %d", i);
414 handleCommand( static_cast<Command>( i ), buttons[ i ].isDown ); 406 handleCommand( static_cast<Command>( i ), buttons[ i ].isDown );
415 } 407 }
416 } 408 }
417 } 409 }
418} 410}
419 411
420 412
421void AudioWidget::mousePressEvent( QMouseEvent *event ) { 413void AudioWidget::mousePressEvent( QMouseEvent *event ) {
422 mouseMoveEvent( event ); 414 mouseMoveEvent( event );
423} 415}
424 416
425 417
426void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 418void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
427 mouseMoveEvent( event ); 419 mouseMoveEvent( event );
428} 420}
429 421
430 422
431void AudioWidget::showEvent( QShowEvent* ) { 423void AudioWidget::showEvent( QShowEvent* ) {
432 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 424 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
433 mouseMoveEvent( &event ); 425 mouseMoveEvent( &event );
434} 426}
435 427
436 428
437void AudioWidget::paintEvent( QPaintEvent * pe ) { 429void AudioWidget::paintEvent( QPaintEvent * pe ) {
438 if ( !pe->erased() ) { 430 if ( !pe->erased() ) {
439 // Combine with background and double buffer 431 // Combine with background and double buffer
440 QPixmap pix( pe->rect().size() ); 432 QPixmap pix( pe->rect().size() );
441 QPainter p( &pix ); 433 QPainter p( &pix );
442 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 434 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
443 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); 435 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() );
444 for ( unsigned int i = 0; i < buttons.size(); i++ ) 436 for ( unsigned int i = 0; i < buttons.size(); i++ )
445 paintButton( p, i ); 437 paintButton( p, i );
446 QPainter p2( this ); 438 QPainter p2( this );
447 p2.drawPixmap( pe->rect().topLeft(), pix ); 439 p2.drawPixmap( pe->rect().topLeft(), pix );
448 } else { 440 } else {
449 QPainter p( this ); 441 QPainter p( this );
450 for ( unsigned int i = 0; i < buttons.size(); i++ ) 442 for ( unsigned int i = 0; i < buttons.size(); i++ )
451 paintButton( p, i ); 443 paintButton( p, i );
452 } 444 }
453} 445}
454 446
455void AudioWidget::keyReleaseEvent( QKeyEvent *e) { 447void AudioWidget::keyReleaseEvent( QKeyEvent *e) {
456 switch ( e->key() ) { 448 switch ( e->key() ) {
457 ////////////////////////////// Zaurus keys 449 ////////////////////////////// Zaurus keys
458 case Key_Home: 450 case Key_Home:
459 break; 451 break;
460 case Key_F9: //activity 452 case Key_F9: //activity
461 hide(); 453 hide();
462 // qDebug("Audio F9"); 454 // qDebug("Audio F9");
463 break; 455 break;
464 case Key_F10: //contacts 456 case Key_F10: //contacts
465 break; 457 break;
466 case Key_F11: //menu 458 case Key_F11: //menu
467 mediaPlayerState.toggleBlank(); 459 mediaPlayerState.toggleBlank();
468 break; 460 break;
469 case Key_F12: //home 461 case Key_F12: //home
470 break; 462 break;
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
@@ -1,115 +1,114 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
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 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
@@ -1,78 +1,84 @@
1/* 1/*
2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> 2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org>
3 (C) 2002 Max Reiss <harlekin@handhelds.org> 3 (C) 2002 Max Reiss <harlekin@handhelds.org>
4 (C) 2002 L. Potter <ljp@llornkcor.com> 4 (C) 2002 L. Potter <ljp@llornkcor.com>
5 (C) 2002 Holger Freyther <zecke@handhelds.org> 5 (C) 2002 Holger Freyther <zecke@handhelds.org>
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23 23
24#include "mediawidget.h" 24#include "mediawidget.h"
25#include "playlistwidget.h" 25#include "playlistwidget.h"
26 26
27MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) 27MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name )
28 : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) 28 : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList )
29{ 29{
30 connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), 30 connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ),
31 this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); 31 this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) );
32 connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), 32 connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ),
33 this, SLOT( setLength( long ) ) ); 33 this, SLOT( setLength( long ) ) );
34 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), 34 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ),
35 this, SLOT( setPlaying( bool ) ) ); 35 this, SLOT( setPlaying( bool ) ) );
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::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
@@ -1,85 +1,87 @@
1/* 1/*
2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> 2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org>
3 (C) 2002 Max Reiss <harlekin@handhelds.org> 3 (C) 2002 Max Reiss <harlekin@handhelds.org>
4 (C) 2002 L. Potter <ljp@llornkcor.com> 4 (C) 2002 L. Potter <ljp@llornkcor.com>
5 (C) 2002 Holger Freyther <zecke@handhelds.org> 5 (C) 2002 Holger Freyther <zecke@handhelds.org>
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23#ifndef MEDIAWIDGET_H 23#ifndef MEDIAWIDGET_H
24#define MEDIAWIDGET_H 24#define MEDIAWIDGET_H
25 25
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 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
@@ -138,262 +138,256 @@ VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye
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 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; 183 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2;
184 if(w>h) 184 if(w>h)
185 upperLeftOfButtonMask.ry() = 0; 185 upperLeftOfButtonMask.ry() = 0;
186 else 186 else
187 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; 187 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10;
188 QPoint p = upperLeftOfButtonMask; 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 ) {
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:
296 emit lessClicked(); 290 emit lessClicked();
297 return; 291 return;
298 } 292 }
299 } else if ( !isOnButton && buttons[i].isHeld ) { 293 } else if ( !isOnButton && buttons[i].isHeld ) {
300 buttons[i].isHeld = FALSE; 294 buttons[i].isHeld = FALSE;
301 toggleButton(i); 295 toggleButton(i);
302 } 296 }
303 } else { 297 } else {
304 298
305 if ( buttons[i].isHeld ) { 299 if ( buttons[i].isHeld ) {
306 buttons[i].isHeld = FALSE; 300 buttons[i].isHeld = FALSE;
307 if ( !buttons[i].isToggle ) { 301 if ( !buttons[i].isToggle ) {
308 setToggleButton( i, FALSE ); 302 setToggleButton( i, FALSE );
309 } 303 }
310 304
311 switch(i) { 305 switch(i) {
312 306
313 case VideoPlay: { 307 case VideoPlay: {
314 if( mediaPlayerState.isPaused() ) { 308 if( mediaPlayerState.isPaused() ) {
315 setToggleButton( i, FALSE ); 309 setToggleButton( i, FALSE );
316 mediaPlayerState.setPaused( FALSE ); 310 mediaPlayerState.setPaused( FALSE );
317 return; 311 return;
318 } else if( !mediaPlayerState.isPaused() ) { 312 } else if( !mediaPlayerState.isPaused() ) {
319 setToggleButton( i, TRUE ); 313 setToggleButton( i, TRUE );
320 mediaPlayerState.setPaused( TRUE ); 314 mediaPlayerState.setPaused( TRUE );
321 return; 315 return;
322 } else { 316 } else {
323 return; 317 return;
324 } 318 }
325 } 319 }
326 320
327 case VideoStop: mediaPlayerState.setPlaying( FALSE ); return; 321 case VideoStop: mediaPlayerState.setPlaying( FALSE ); return;
328 case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; 322 case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
329 case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; 323 case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
330 case VideoVolUp: emit moreReleased(); return; 324 case VideoVolUp: emit moreReleased(); return;
331 case VideoVolDown: emit lessReleased(); return; 325 case VideoVolDown: emit lessReleased(); return;
332 case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return; 326 case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return;
333 } 327 }
334 } 328 }
335 } 329 }
336 } 330 }
337} 331}
338 332
339void VideoWidget::mousePressEvent( QMouseEvent *event ) { 333void VideoWidget::mousePressEvent( QMouseEvent *event ) {
340 mouseMoveEvent( event ); 334 mouseMoveEvent( event );
341} 335}
342 336
343void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 337void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
344 if ( mediaPlayerState.isFullscreen() ) { 338 if ( mediaPlayerState.isFullscreen() ) {
345 mediaPlayerState.setFullscreen( FALSE ); 339 mediaPlayerState.setFullscreen( FALSE );
346 makeVisible(); 340 makeVisible();
347 } 341 }
348 mouseMoveEvent( event ); 342 mouseMoveEvent( event );
349} 343}
350 344
351void VideoWidget::showEvent( QShowEvent* ) { 345void VideoWidget::showEvent( QShowEvent* ) {
352 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 346 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
353 mouseMoveEvent( &event ); 347 mouseMoveEvent( &event );
354} 348}
355 349
356 350
357 void VideoWidget::backToNormal() { 351 void VideoWidget::backToNormal() {
358 mediaPlayerState.setFullscreen( FALSE ); 352 mediaPlayerState.setFullscreen( FALSE );
359 makeVisible(); 353 makeVisible();
360 } 354 }
361 355
362void VideoWidget::makeVisible() { 356void VideoWidget::makeVisible() {
363 if ( mediaPlayerState.isFullscreen() ) { 357 if ( mediaPlayerState.isFullscreen() ) {
364 setBackgroundMode( QWidget::NoBackground ); 358 setBackgroundMode( QWidget::NoBackground );
365 showFullScreen(); 359 showFullScreen();
366 resize( qApp->desktop()->size() ); 360 resize( qApp->desktop()->size() );
367 videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); 361 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
368 362
369 slider->hide(); 363 slider->hide();
370 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 364 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
371 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 365 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
372 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 366 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
373 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 367 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
374 368
375 } else { 369 } else {
376 showNormal(); 370 showNormal();
377 showMaximized(); 371 showMaximized();
378 setBackgroundPixmap( pixBg ); 372 setBackgroundPixmap( pixBg );
379 QWidget *d = QApplication::desktop(); 373 QWidget *d = QApplication::desktop();
380 int w = d->width(); 374 int w = d->width();
381 int h = d->height(); 375 int h = d->height();
382 376
383 if(w>h) { 377 if(w>h) {
384 int newW=(w/2)-(246/2); //this will only work with 320x240 378 int newW=(w/2)-(246/2); //this will only work with 320x240
385 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); 379 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) );
386 } else { 380 } else {
387 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); 381 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) );
388 } 382 }
389 383
390 if ( !mediaPlayerState.isSeekable() ) { 384 if ( !mediaPlayerState.isSeekable() ) {
391 if( !slider->isHidden()) { 385 if( !slider->isHidden()) {
392 slider->hide(); 386 slider->hide();
393 } 387 }
394 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 388 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
395 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 389 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
396 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 390 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
397 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 391 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
398 } else { 392 } else {
399 slider->show(); 393 slider->show();
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
@@ -1,126 +1,125 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
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 VIDEO_WIDGET_H 34#ifndef VIDEO_WIDGET_H
35#define VIDEO_WIDGET_H 35#define VIDEO_WIDGET_H
36 36
37#include <qwidget.h> 37#include <qwidget.h>
38#include <qimage.h> 38#include <qimage.h>
39#include <qpixmap.h> 39#include <qpixmap.h>
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 VideoStop = 0, 48 VideoStop = 0,
49 VideoPlay, 49 VideoPlay,
50// VideoPause, 50// VideoPause,
51 VideoPrevious, 51 VideoPrevious,
52 VideoNext, 52 VideoNext,
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 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