summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-09-05 12:34:07 (UTC)
committer llornkcor <llornkcor>2002-09-05 12:34:07 (UTC)
commit4daacd5aa7494e02df2afd245f22fbb59f8e19d9 (patch) (unidiff)
treef832d2156302fc53d63c647a55193808f89d0912
parente2186a49cb5cbdf01b56f57818a15a760ff25b2e (diff)
downloadopie-4daacd5aa7494e02df2afd245f22fbb59f8e19d9.zip
opie-4daacd5aa7494e02df2afd245f22fbb59f8e19d9.tar.gz
opie-4daacd5aa7494e02df2afd245f22fbb59f8e19d9.tar.bz2
ignore next and prev buttons when playing from filelist, for now
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp7
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp6
2 files changed, 9 insertions, 4 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 446fa45..7c49733 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -2,98 +2,100 @@
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#include <qpe/qpeapplication.h> 34#include <qpe/qpeapplication.h>
35#include <qpe/resource.h> 35#include <qpe/resource.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37 37
38#include <qwidget.h> 38#include <qwidget.h>
39#include <qpixmap.h> 39#include <qpixmap.h>
40#include <qbutton.h> 40#include <qbutton.h>
41#include <qpainter.h> 41#include <qpainter.h>
42#include <qframe.h> 42#include <qframe.h>
43#include <qlayout.h> 43#include <qlayout.h>
44 44
45#include <stdlib.h> 45#include <stdlib.h>
46#include <stdio.h> 46#include <stdio.h>
47 47
48#include "audiowidget.h" 48#include "audiowidget.h"
49#include "mediaplayerstate.h" 49#include "mediaplayerstate.h"
50#include "playlistwidget.h"
50 51
51extern MediaPlayerState *mediaPlayerState; 52extern MediaPlayerState *mediaPlayerState;
53extern PlayListWidget *playList;
52 54
53static const int xo = -2; // movable x offset 55static const int xo = -2; // movable x offset
54static const int yo = 22; // movable y offset 56static const int yo = 22; // movable y offset
55 57
56 58
57Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { 59Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) {
58 setFrameStyle( WinPanel | Sunken ); 60 setFrameStyle( WinPanel | Sunken );
59 setText( "No Song" ); 61 setText( "No Song" );
60} 62}
61 63
62Ticker::~Ticker() { 64Ticker::~Ticker() {
63} 65}
64 66
65void Ticker::setText( const QString& text ) { 67void Ticker::setText( const QString& text ) {
66 pos = 0; // reset it everytime the text is changed 68 pos = 0; // reset it everytime the text is changed
67 scrollText = text; 69 scrollText = text;
68 pixelLen = fontMetrics().width( scrollText ); 70 pixelLen = fontMetrics().width( scrollText );
69 killTimers(); 71 killTimers();
70 if ( pixelLen > width() ) { 72 if ( pixelLen > width() ) {
71 startTimer( 50 ); 73 startTimer( 50 );
72 } 74 }
73 update(); 75 update();
74} 76}
75 77
76 78
77void Ticker::timerEvent( QTimerEvent * ) { 79void Ticker::timerEvent( QTimerEvent * ) {
78 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; 80 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1;
79 scroll( -1, 0, contentsRect() ); 81 scroll( -1, 0, contentsRect() );
80 repaint( FALSE ); 82 repaint( FALSE );
81} 83}
82 84
83void Ticker::drawContents( QPainter *p ) { 85void Ticker::drawContents( QPainter *p ) {
84 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { 86 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) {
85 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); 87 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
86 } 88 }
87 QPixmap pm( width(), height() ); 89 QPixmap pm( width(), height() );
88 pm.fill( colorGroup().base() ); 90 pm.fill( colorGroup().base() );
89 QPainter pmp( &pm ); 91 QPainter pmp( &pm );
90 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { 92 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) {
91 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); 93 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
92 } 94 }
93 p->drawPixmap( 0, 0, pm ); 95 p->drawPixmap( 0, 0, pm );
94} 96}
95 97
96struct MediaButton { 98struct MediaButton {
97 bool isToggle, isHeld, isDown; 99 bool isToggle, isHeld, isDown;
98}; 100};
99 101
@@ -180,96 +182,97 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
180 slider.setFocusPolicy( QWidget::NoFocus ); 182 slider.setFocusPolicy( QWidget::NoFocus );
181 slider.setBackgroundPixmap( *pixBg ); 183 slider.setBackgroundPixmap( *pixBg );
182 184
183 time.setFocusPolicy( QWidget::NoFocus ); 185 time.setFocusPolicy( QWidget::NoFocus );
184 time.setAlignment( Qt::AlignCenter ); 186 time.setAlignment( Qt::AlignCenter );
185 time.setFrame(FALSE); 187 time.setFrame(FALSE);
186 changeTextColor( &time ); 188 changeTextColor( &time );
187 189
188 resizeEvent( NULL ); 190 resizeEvent( NULL );
189 191
190 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 192 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
191 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 193 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
192 194
193 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 195 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
194 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 196 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
195 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 197 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
196 // connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 198 // connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
197 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 199 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
198 200
199 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); 201 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) );
200 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); 202 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) );
201 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); 203 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) );
202 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); 204 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) );
203 205
204 206
205 207
206 // Intialise state 208 // Intialise state
207 setLength( mediaPlayerState->length() ); 209 setLength( mediaPlayerState->length() );
208 setPosition( mediaPlayerState->position() ); 210 setPosition( mediaPlayerState->position() );
209 setLooping( mediaPlayerState->fullscreen() ); 211 setLooping( mediaPlayerState->fullscreen() );
210 // setPaused( mediaPlayerState->paused() ); 212 // setPaused( mediaPlayerState->paused() );
211 setPlaying( mediaPlayerState->playing() ); 213 setPlaying( mediaPlayerState->playing() );
212 214
213} 215}
214 216
215AudioWidget::~AudioWidget() { 217AudioWidget::~AudioWidget() {
216 218
217 for ( int i = 0; i < 10; i++ ) { 219 for ( int i = 0; i < 10; i++ ) {
218 delete buttonPixUp[i]; 220 delete buttonPixUp[i];
219 delete buttonPixDown[i]; 221 delete buttonPixDown[i];
220 } 222 }
221 delete pixBg; 223 delete pixBg;
222 delete imgUp; 224 delete imgUp;
223 delete imgDn; 225 delete imgDn;
224 delete imgButtonMask; 226 delete imgButtonMask;
225 for ( int i = 0; i < 10; i++ ) { 227 for ( int i = 0; i < 10; i++ ) {
226 delete masks[i]; 228 delete masks[i];
227 } 229 }
230// mediaPlayerState->setPlaying(false);
228} 231}
229 232
230namespace { 233namespace {
231 234
232QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 235QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
233 QPixmap pix( img.width(), img.height() ); 236 QPixmap pix( img.width(), img.height() );
234 QPainter p( &pix ); 237 QPainter p( &pix );
235 p.drawTiledPixmap( pix.rect(), bg, offset ); 238 p.drawTiledPixmap( pix.rect(), bg, offset );
236 p.drawImage( 0, 0, img ); 239 p.drawImage( 0, 0, img );
237 return new QPixmap( pix ); 240 return new QPixmap( pix );
238} 241}
239 242
240 243
241QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { 244QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) {
242 QPixmap *pixmap = new QPixmap( pix ); 245 QPixmap *pixmap = new QPixmap( pix );
243 pixmap->setMask( mask ); 246 pixmap->setMask( mask );
244 return pixmap; 247 return pixmap;
245} 248}
246 249
247}; 250};
248 251
249void AudioWidget::resizeEvent( QResizeEvent * ) { 252void AudioWidget::resizeEvent( QResizeEvent * ) {
250 int h = height(); 253 int h = height();
251 int w = width(); 254 int w = width();
252 255
253 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); 256 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) );
254 slider.setFixedWidth( w - 110 ); 257 slider.setFixedWidth( w - 110 );
255 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); 258 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) );
256 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 259 slider.setBackgroundOrigin( QWidget::ParentOrigin );
257 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 260 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
258 261
259 xoff = ( w - imgUp->width() ) / 2; 262 xoff = ( w - imgUp->width() ) / 2;
260 yoff = (( h - imgUp->height() ) / 2) - 10; 263 yoff = (( h - imgUp->height() ) / 2) - 10;
261 QPoint p( xoff, yoff ); 264 QPoint p( xoff, yoff );
262 265
263 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); 266 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p );
264 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); 267 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p );
265 268
266 for ( int i = 0; i < 10; i++ ) { 269 for ( int i = 0; i < 10; i++ ) {
267 if ( !masks[i]->isNull() ) { 270 if ( !masks[i]->isNull() ) {
268 delete buttonPixUp[i]; 271 delete buttonPixUp[i];
269 delete buttonPixDown[i]; 272 delete buttonPixDown[i];
270 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); 273 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] );
271 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); 274 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] );
272 } 275 }
273 } 276 }
274 277
275 delete pixUp; 278 delete pixUp;
@@ -424,98 +427,98 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
424 427
425 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 428 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
426 && y < imgButtonMask->height() 429 && y < imgButtonMask->height()
427 && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 430 && imgButtonMask->pixelIndex( x, y ) == i + 1 );
428 431
429 if ( isOnButton && !audioButtons[i].isHeld ) { 432 if ( isOnButton && !audioButtons[i].isHeld ) {
430 audioButtons[i].isHeld = TRUE; 433 audioButtons[i].isHeld = TRUE;
431 toggleButton(i); 434 toggleButton(i);
432 switch (i) { 435 switch (i) {
433 case AudioVolumeUp: 436 case AudioVolumeUp:
434 emit moreClicked(); 437 emit moreClicked();
435 return; 438 return;
436 case AudioVolumeDown: 439 case AudioVolumeDown:
437 emit lessClicked(); 440 emit lessClicked();
438 return; 441 return;
439 case AudioForward: 442 case AudioForward:
440 emit forwardClicked(); 443 emit forwardClicked();
441 return; 444 return;
442 case AudioBack: 445 case AudioBack:
443 emit backClicked(); 446 emit backClicked();
444 return; 447 return;
445 } 448 }
446 } else if ( !isOnButton && audioButtons[i].isHeld ) { 449 } else if ( !isOnButton && audioButtons[i].isHeld ) {
447 audioButtons[i].isHeld = FALSE; 450 audioButtons[i].isHeld = FALSE;
448 toggleButton(i); 451 toggleButton(i);
449 } 452 }
450 } else { 453 } else {
451 if ( audioButtons[i].isHeld ) { 454 if ( audioButtons[i].isHeld ) {
452 audioButtons[i].isHeld = FALSE; 455 audioButtons[i].isHeld = FALSE;
453 if ( !audioButtons[i].isToggle ) { 456 if ( !audioButtons[i].isToggle ) {
454 setToggleButton( i, FALSE ); 457 setToggleButton( i, FALSE );
455 } 458 }
456 qDebug("mouseEvent %d", i); 459 qDebug("mouseEvent %d", i);
457 switch (i) { 460 switch (i) {
458 case AudioPlay: 461 case AudioPlay:
459 if( mediaPlayerState->isPaused ) { 462 if( mediaPlayerState->isPaused ) {
460// setToggleButton( i, FALSE ); 463// setToggleButton( i, FALSE );
461 mediaPlayerState->setPaused( FALSE ); 464 mediaPlayerState->setPaused( FALSE );
462 return; 465 return;
463 } else if( !mediaPlayerState->isPaused ) { 466 } else if( !mediaPlayerState->isPaused ) {
464// setToggleButton( i, TRUE ); 467// setToggleButton( i, TRUE );
465 mediaPlayerState->setPaused( TRUE ); 468 mediaPlayerState->setPaused( TRUE );
466 return; 469 return;
467 } else { 470 } else {
468 // setToggleButton( i, TRUE ); 471 // setToggleButton( i, TRUE );
469 // mediaPlayerState->setPlaying( videoButtons[i].isDown ); 472 // mediaPlayerState->setPlaying( videoButtons[i].isDown );
470 } 473 }
471 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 474 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
472 case AudioNext: mediaPlayerState->setNext(); return; 475 case AudioNext: if(playList->whichList() ==0) mediaPlayerState->setNext(); return;
473 case AudioPrevious: mediaPlayerState->setPrev(); return; 476 case AudioPrevious: if(playList->whichList() ==0) mediaPlayerState->setPrev(); return;
474 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; 477 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
475 case AudioVolumeUp: emit moreReleased(); return; 478 case AudioVolumeUp: emit moreReleased(); return;
476 case AudioVolumeDown: emit lessReleased(); return; 479 case AudioVolumeDown: emit lessReleased(); return;
477 case AudioPlayList: mediaPlayerState->setList(); return; 480 case AudioPlayList: mediaPlayerState->setList(); return;
478 case AudioForward: emit forwardReleased(); return; 481 case AudioForward: emit forwardReleased(); return;
479 case AudioBack: emit backReleased(); return; 482 case AudioBack: emit backReleased(); return;
480 } 483 }
481 } 484 }
482 } 485 }
483 } 486 }
484} 487}
485 488
486 489
487void AudioWidget::mousePressEvent( QMouseEvent *event ) { 490void AudioWidget::mousePressEvent( QMouseEvent *event ) {
488 mouseMoveEvent( event ); 491 mouseMoveEvent( event );
489} 492}
490 493
491 494
492void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 495void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
493 mouseMoveEvent( event ); 496 mouseMoveEvent( event );
494} 497}
495 498
496 499
497void AudioWidget::showEvent( QShowEvent* ) { 500void AudioWidget::showEvent( QShowEvent* ) {
498 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 501 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
499 mouseMoveEvent( &event ); 502 mouseMoveEvent( &event );
500} 503}
501 504
502 505
503void AudioWidget::closeEvent( QCloseEvent* ) { 506void AudioWidget::closeEvent( QCloseEvent* ) {
504 mediaPlayerState->setList(); 507 mediaPlayerState->setList();
505} 508}
506 509
507 510
508void AudioWidget::paintEvent( QPaintEvent * pe) { 511void AudioWidget::paintEvent( QPaintEvent * pe) {
509 if ( !pe->erased() ) { 512 if ( !pe->erased() ) {
510 // Combine with background and double buffer 513 // Combine with background and double buffer
511 QPixmap pix( pe->rect().size() ); 514 QPixmap pix( pe->rect().size() );
512 QPainter p( &pix ); 515 QPainter p( &pix );
513 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 516 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
514 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 517 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
515 for ( int i = 0; i < numButtons; i++ ) 518 for ( int i = 0; i < numButtons; i++ )
516 paintButton( &p, i ); 519 paintButton( &p, i );
517 QPainter p2( this ); 520 QPainter p2( this );
518 p2.drawPixmap( pe->rect().topLeft(), pix ); 521 p2.drawPixmap( pe->rect().topLeft(), pix );
519 } else { 522 } else {
520 QPainter p( this ); 523 QPainter p( this );
521 for ( int i = 0; i < numButtons; i++ ) 524 for ( int i = 0; i < numButtons; i++ )
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index ffda2e4..8e3a365 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -1,104 +1,106 @@
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#include <qpe/qpeapplication.h> 34#include <qpe/qpeapplication.h>
35#include <qpe/resource.h> 35#include <qpe/resource.h>
36#include <qpe/mediaplayerplugininterface.h> 36#include <qpe/mediaplayerplugininterface.h>
37#include <qpe/config.h> 37#include <qpe/config.h>
38 38
39 39
40#include <qwidget.h> 40#include <qwidget.h>
41#include <qpainter.h> 41#include <qpainter.h>
42#include <qpixmap.h> 42#include <qpixmap.h>
43#include <qslider.h> 43#include <qslider.h>
44#include <qdrawutil.h> 44#include <qdrawutil.h>
45#include "videowidget.h" 45#include "videowidget.h"
46#include "mediaplayerstate.h" 46#include "mediaplayerstate.h"
47#include "playlistwidget.h"
47 48
48 49
49#ifdef Q_WS_QWS 50#ifdef Q_WS_QWS
50# define USE_DIRECT_PAINTER 51# define USE_DIRECT_PAINTER
51# include <qdirectpainter_qws.h> 52# include <qdirectpainter_qws.h>
52# include <qgfxraster_qws.h> 53# include <qgfxraster_qws.h>
53#endif 54#endif
54 55
55 56
56extern MediaPlayerState *mediaPlayerState; 57extern MediaPlayerState *mediaPlayerState;
58extern PlayListWidget *playList;
57 59
58 60
59static const int xo = 2; // movable x offset 61static const int xo = 2; // movable x offset
60static const int yo = 0; // movable y offset 62static const int yo = 0; // movable y offset
61 63
62 64
63struct MediaButton { 65struct MediaButton {
64 bool isToggle, isHeld, isDown; 66 bool isToggle, isHeld, isDown;
65}; 67};
66 68
67MediaButton videoButtons[] = { 69MediaButton videoButtons[] = {
68 { FALSE, FALSE, FALSE }, // stop 70 { FALSE, FALSE, FALSE }, // stop
69 { TRUE, FALSE, FALSE }, // play 71 { TRUE, FALSE, FALSE }, // play
70 { FALSE, FALSE, FALSE }, // previous 72 { FALSE, FALSE, FALSE }, // previous
71 { FALSE, FALSE, FALSE }, // next 73 { FALSE, FALSE, FALSE }, // next
72 { FALSE, FALSE, FALSE }, // volUp 74 { FALSE, FALSE, FALSE }, // volUp
73 { FALSE, FALSE, FALSE }, // volDown 75 { FALSE, FALSE, FALSE }, // volDown
74 { TRUE, FALSE, FALSE } // fullscreen 76 { TRUE, FALSE, FALSE } // fullscreen
75}; 77};
76 78
77const char *skinV_mask_file_names[7] = { 79const char *skinV_mask_file_names[7] = {
78"stop","play","back","fwd","up","down","full" 80"stop","play","back","fwd","up","down","full"
79}; 81};
80 82
81static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 83static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton));
82 84
83 85
84VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : 86VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
85QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { 87QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) {
86 88
87 89
88 setCaption( tr("OpiePlayer - Video") ); 90 setCaption( tr("OpiePlayer - Video") );
89 91
90 videoFrame = new XineVideoWidget ( this, "Video frame" ); 92 videoFrame = new XineVideoWidget ( this, "Video frame" );
91 93
92 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); 94 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
93 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); 95 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
94 96
95 Config cfg("OpiePlayer"); 97 Config cfg("OpiePlayer");
96 cfg.setGroup("Options"); 98 cfg.setGroup("Options");
97 skin = cfg.readEntry("Skin","default"); 99 skin = cfg.readEntry("Skin","default");
98 100
99 QString skinPath = "opieplayer2/skins/" + skin; 101 QString skinPath = "opieplayer2/skins/" + skin;
100 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 102 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
101 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); 103 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
102 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); 104 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
103 105
104 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 106 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
@@ -293,98 +295,98 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
293 int x = event->pos().x() - xoff; 295 int x = event->pos().x() - xoff;
294 int y = event->pos().y() - yoff; 296 int y = event->pos().y() - yoff;
295 297
296 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 298 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
297 && y < imgButtonMask->height() 299 && y < imgButtonMask->height()
298 && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 300 && imgButtonMask->pixelIndex( x, y ) == i + 1 );
299 301
300 if ( isOnButton && !videoButtons[i].isHeld ) { 302 if ( isOnButton && !videoButtons[i].isHeld ) {
301 videoButtons[i].isHeld = TRUE; 303 videoButtons[i].isHeld = TRUE;
302 toggleButton(i); 304 toggleButton(i);
303 305
304 switch (i) { 306 switch (i) {
305 case VideoVolUp: 307 case VideoVolUp:
306 emit moreClicked(); 308 emit moreClicked();
307 return; 309 return;
308 case VideoVolDown: 310 case VideoVolDown:
309 emit lessClicked(); 311 emit lessClicked();
310 return; 312 return;
311 } 313 }
312 } else if ( !isOnButton && videoButtons[i].isHeld ) { 314 } else if ( !isOnButton && videoButtons[i].isHeld ) {
313 videoButtons[i].isHeld = FALSE; 315 videoButtons[i].isHeld = FALSE;
314 toggleButton(i); 316 toggleButton(i);
315 } 317 }
316 } else { 318 } else {
317 319
318 if ( videoButtons[i].isHeld ) { 320 if ( videoButtons[i].isHeld ) {
319 videoButtons[i].isHeld = FALSE; 321 videoButtons[i].isHeld = FALSE;
320 if ( !videoButtons[i].isToggle ) { 322 if ( !videoButtons[i].isToggle ) {
321 setToggleButton( i, FALSE ); 323 setToggleButton( i, FALSE );
322 } 324 }
323 325
324 switch(i) { 326 switch(i) {
325 327
326 case VideoPlay: { 328 case VideoPlay: {
327 if( mediaPlayerState->isPaused ) { 329 if( mediaPlayerState->isPaused ) {
328 setToggleButton( i, FALSE ); 330 setToggleButton( i, FALSE );
329 mediaPlayerState->setPaused( FALSE ); 331 mediaPlayerState->setPaused( FALSE );
330 return; 332 return;
331 } else if( !mediaPlayerState->isPaused ) { 333 } else if( !mediaPlayerState->isPaused ) {
332 setToggleButton( i, TRUE ); 334 setToggleButton( i, TRUE );
333 mediaPlayerState->setPaused( TRUE ); 335 mediaPlayerState->setPaused( TRUE );
334 return; 336 return;
335 } else { 337 } else {
336 return; 338 return;
337 } 339 }
338 } 340 }
339 341
340 case VideoStop: mediaPlayerState->setPlaying( FALSE ); return; 342 case VideoStop: mediaPlayerState->setPlaying( FALSE ); return;
341 case VideoNext: mediaPlayerState->setNext(); return; 343 case VideoNext: if(playList->whichList() ==0) mediaPlayerState->setNext(); return;
342 case VideoPrevious: mediaPlayerState->setPrev(); return; 344 case VideoPrevious: if(playList->whichList() ==0) mediaPlayerState->setPrev(); return;
343 case VideoVolUp: emit moreReleased(); return; 345 case VideoVolUp: emit moreReleased(); return;
344 case VideoVolDown: emit lessReleased(); return; 346 case VideoVolDown: emit lessReleased(); return;
345 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; 347 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
346 } 348 }
347 } 349 }
348 } 350 }
349 } 351 }
350} 352}
351 353
352void VideoWidget::mousePressEvent( QMouseEvent *event ) { 354void VideoWidget::mousePressEvent( QMouseEvent *event ) {
353 mouseMoveEvent( event ); 355 mouseMoveEvent( event );
354} 356}
355 357
356void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 358void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
357 if ( mediaPlayerState->fullscreen() ) { 359 if ( mediaPlayerState->fullscreen() ) {
358 mediaPlayerState->setFullscreen( FALSE ); 360 mediaPlayerState->setFullscreen( FALSE );
359 makeVisible(); 361 makeVisible();
360 } 362 }
361 mouseMoveEvent( event ); 363 mouseMoveEvent( event );
362} 364}
363 365
364void VideoWidget::showEvent( QShowEvent* ) { 366void VideoWidget::showEvent( QShowEvent* ) {
365 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 367 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
366 mouseMoveEvent( &event ); 368 mouseMoveEvent( &event );
367} 369}
368 370
369 371
370 void VideoWidget::backToNormal() { 372 void VideoWidget::backToNormal() {
371 mediaPlayerState->setFullscreen( FALSE ); 373 mediaPlayerState->setFullscreen( FALSE );
372 makeVisible(); 374 makeVisible();
373 } 375 }
374 376
375void VideoWidget::makeVisible() { 377void VideoWidget::makeVisible() {
376 if ( mediaPlayerState->fullscreen() ) { 378 if ( mediaPlayerState->fullscreen() ) {
377 setBackgroundMode( QWidget::NoBackground ); 379 setBackgroundMode( QWidget::NoBackground );
378 showFullScreen(); 380 showFullScreen();
379 resize( qApp->desktop()->size() ); 381 resize( qApp->desktop()->size() );
380 slider->hide(); 382 slider->hide();
381 videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); 383 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
382 qApp->processEvents(); 384 qApp->processEvents();
383 } else { 385 } else {
384 showNormal(); 386 showNormal();
385 showMaximized(); 387 showMaximized();
386 setBackgroundPixmap( *pixBg ); 388 setBackgroundPixmap( *pixBg );
387 if ( mediaPlayerState->streaming() ) { 389 if ( mediaPlayerState->streaming() ) {
388 slider->hide(); 390 slider->hide();
389 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 391 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
390 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 392 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );