summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp105
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.h51
2 files changed, 134 insertions, 22 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 955169c..6b656ee 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -1,12 +1,44 @@
1/*
2                This file is part of the Opie Project
3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =.
8 .=l.
9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details.
24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA.
31
32*/
1 33
2#include <qpe/qpeapplication.h> 34#include <qpe/qpeapplication.h>
3#include <qpe/resource.h> 35#include <qpe/resource.h>
4#include <qpe/config.h> 36#include <qpe/config.h>
5 37
6#include <qwidget.h> 38#include <qwidget.h>
7#include <qpixmap.h> 39#include <qpixmap.h>
8#include <qbutton.h> 40#include <qbutton.h>
9#include <qpainter.h> 41#include <qpainter.h>
10#include <qframe.h> 42#include <qframe.h>
11#include <qlayout.h> 43#include <qlayout.h>
12 44
@@ -153,24 +185,31 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
153 185
154 resizeEvent( NULL ); 186 resizeEvent( NULL );
155 187
156 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 188 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
157 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 189 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
158 190
159 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 191 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
160 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 192 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
161 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 193 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
162 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 194 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
163 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 195 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
164 196
197 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) );
198 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) );
199 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) );
200 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) );
201
202
203
165 // Intialise state 204 // Intialise state
166 setLength( mediaPlayerState->length() ); 205 setLength( mediaPlayerState->length() );
167 setPosition( mediaPlayerState->position() ); 206 setPosition( mediaPlayerState->position() );
168 setLooping( mediaPlayerState->fullscreen() ); 207 setLooping( mediaPlayerState->fullscreen() );
169 setPaused( mediaPlayerState->paused() ); 208 setPaused( mediaPlayerState->paused() );
170 setPlaying( mediaPlayerState->playing() ); 209 setPlaying( mediaPlayerState->playing() );
171 210
172} 211}
173 212
174AudioWidget::~AudioWidget() { 213AudioWidget::~AudioWidget() {
175 214
176 for ( int i = 0; i < 11; i++ ) { 215 for ( int i = 0; i < 11; i++ ) {
@@ -332,75 +371,107 @@ void AudioWidget::toggleButton( int i ) {
332 paintButton ( &p, i ); 371 paintButton ( &p, i );
333} 372}
334 373
335 374
336void AudioWidget::paintButton( QPainter *p, int i ) { 375void AudioWidget::paintButton( QPainter *p, int i ) {
337 if ( audioButtons[i].isDown ) 376 if ( audioButtons[i].isDown )
338 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 377 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
339 else 378 else
340 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 379 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
341} 380}
342 381
343 382
383void AudioWidget::skipFor() {
384 skipDirection = +1;
385 startTimer( 50 );
386 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 );
387}
388
389void AudioWidget::skipBack() {
390 skipDirection = -1;
391 startTimer( 50 );
392 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 );
393}
394
395
396
397void AudioWidget::stopSkip() {
398 killTimers();
399}
400
401
344void AudioWidget::timerEvent( QTimerEvent * ) { 402void AudioWidget::timerEvent( QTimerEvent * ) {
403 if ( skipDirection == +1 ) {
404 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 );
405 } else if ( skipDirection == -1 ) {
406 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 );
407 }
345} 408}
346 409
347 410
348void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 411void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
349 for ( int i = 0; i < numButtons; i++ ) { 412 for ( int i = 0; i < numButtons; i++ ) {
350 if ( event->state() == QMouseEvent::LeftButton ) { 413 if ( event->state() == QMouseEvent::LeftButton ) {
351 414
352 // The test to see if the mouse click is inside the button or not 415 // The test to see if the mouse click is inside the button or not
353 int x = event->pos().x() - xoff; 416 int x = event->pos().x() - xoff;
354 int y = event->pos().y() - yoff; 417 int y = event->pos().y() - yoff;
355 418
356 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 419 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
357 && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 420 && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 );
358 421
359 if ( isOnButton && i == AudioVolumeUp ) 422 if ( isOnButton && i == AudioVolumeUp )
360 qDebug("on up"); 423 qDebug("on up");
361 424
362 if ( isOnButton && !audioButtons[i].isHeld ) { 425 if ( isOnButton && !audioButtons[i].isHeld ) {
363 audioButtons[i].isHeld = TRUE; 426 audioButtons[i].isHeld = TRUE;
364 toggleButton(i); 427 toggleButton(i);
365 switch (i) { 428 switch (i) {
366 case AudioVolumeUp: 429 case AudioVolumeUp:
367 qDebug("more clicked"); 430 qDebug("more clicked");
368 emit moreClicked(); 431 emit moreClicked();
369 return; 432 return;
370 case AudioVolumeDown: 433 case AudioVolumeDown:
371 emit lessClicked(); 434 emit lessClicked();
372 return; 435 return;
436 case AudioForward:
437 emit forwardClicked();
438 return;
439 case AudioBack:
440 emit backClicked();
441 return;
373 } 442 }
374 } else if ( !isOnButton && audioButtons[i].isHeld ) { 443 } else if ( !isOnButton && audioButtons[i].isHeld ) {
375 audioButtons[i].isHeld = FALSE; 444 audioButtons[i].isHeld = FALSE;
376 toggleButton(i); 445 toggleButton(i);
377 } 446 }
378 } else { 447 } else {
379 if ( audioButtons[i].isHeld ) { 448 if ( audioButtons[i].isHeld ) {
380 audioButtons[i].isHeld = FALSE; 449 audioButtons[i].isHeld = FALSE;
381 if ( !audioButtons[i].isToggle ) { 450 if ( !audioButtons[i].isToggle ) {
382 setToggleButton( i, FALSE ); 451 setToggleButton( i, FALSE );
383 qDebug("button toggled3 %d",i); 452 qDebug("button toggled3 %d",i);
384 } 453 }
385 switch (i) { 454 switch (i) {
386 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; 455 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return;
387 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 456 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
388 case AudioPause: mediaPlayerState->setPaused( audioButtons[i].isDown); return; 457 case AudioPause: mediaPlayerState->setPaused( audioButtons[i].isDown); return;
389 case AudioNext: mediaPlayerState->setNext(); return; 458 case AudioNext: mediaPlayerState->setNext(); return;
390 case AudioPrevious: mediaPlayerState->setPrev(); return; 459 case AudioPrevious: mediaPlayerState->setPrev(); return;
391 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; 460 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
392 case AudioVolumeUp: emit moreReleased(); return; 461 case AudioVolumeUp: emit moreReleased(); return;
393 case AudioVolumeDown: emit lessReleased(); return; 462 case AudioVolumeDown: emit lessReleased(); return;
394 case AudioPlayList: mediaPlayerState->setList(); return; 463 case AudioPlayList: mediaPlayerState->setList(); return;
464 case AudioForward: emit forwardReleased(); return;
465 case AudioBack: emit backReleased(); return;
395 } 466 }
396 } 467 }
397 } 468 }
398 } 469 }
399} 470}
400 471
401 472
402void AudioWidget::mousePressEvent( QMouseEvent *event ) { 473void AudioWidget::mousePressEvent( QMouseEvent *event ) {
403 mouseMoveEvent( event ); 474 mouseMoveEvent( event );
404} 475}
405 476
406 477
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h
index 2b892be..e05188e 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.h
+++ b/noncore/multimedia/opieplayer2/audiowidget.h
@@ -1,43 +1,75 @@
1/*
2                This file is part of the Opie Project
3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =.
8 .=l.
9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details.
24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA.
31
32*/
33
1#ifndef AUDIO_WIDGET_H 34#ifndef AUDIO_WIDGET_H
2#define AUDIO_WIDGET_H 35#define AUDIO_WIDGET_H
3 36
4#include <qwidget.h> 37#include <qwidget.h>
5#include <qpainter.h> 38#include <qpainter.h>
6#include <qdrawutil.h> 39#include <qdrawutil.h>
7#include <qpixmap.h> 40#include <qpixmap.h>
8#include <qstring.h> 41#include <qstring.h>
9#include <qslider.h> 42#include <qslider.h>
10#include <qframe.h> 43#include <qframe.h>
11#include <qlineedit.h> 44#include <qlineedit.h>
12 45
13 46
14class QPixmap; 47class QPixmap;
15 48
16enum AudioButtons { 49enum AudioButtons {
17 AudioPlay=0, 50 AudioPlay=0,
18 AudioStop, 51 AudioStop,
19 AudioPause, 52 AudioPause,
20 AudioNext, 53 AudioNext,
21 AudioPrevious, 54 AudioPrevious,
22 AudioVolumeUp, 55 AudioVolumeUp,
23 AudioVolumeDown, 56 AudioVolumeDown,
24 AudioLoop, 57 AudioLoop,
25 AudioPlayList 58 AudioPlayList,
59 AudioForward,
60 AudioBack
26}; 61};
27 62
28 63
29//#define USE_DBLBUF
30
31
32class Ticker : public QFrame { 64class Ticker : public QFrame {
33 Q_OBJECT 65 Q_OBJECT
34 66
35public: 67public:
36 Ticker( QWidget* parent=0 ); 68 Ticker( QWidget* parent=0 );
37 ~Ticker(); 69 ~Ticker();
38 void setText( const QString& text ) ; 70 void setText( const QString& text ) ;
39 71
40protected: 72protected:
41 void timerEvent( QTimerEvent * ); 73 void timerEvent( QTimerEvent * );
42 void drawContents( QPainter *p ); 74 void drawContents( QPainter *p );
43private: 75private:
@@ -60,49 +92,58 @@ public slots:
60 void setPaused( bool b) { setToggleButton( AudioPause, b ); } 92 void setPaused( bool b) { setToggleButton( AudioPause, b ); }
61 void setLooping( bool b) { setToggleButton( AudioLoop, b ); } 93 void setLooping( bool b) { setToggleButton( AudioLoop, b ); }
62 void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } 94 void setPlaying( bool b) { setToggleButton( AudioPlay, b ); }
63 void setPosition( long ); 95 void setPosition( long );
64 void setLength( long ); 96 void setLength( long );
65 void setView( char ); 97 void setView( char );
66 98
67signals: 99signals:
68 void moreClicked(); 100 void moreClicked();
69 void lessClicked(); 101 void lessClicked();
70 void moreReleased(); 102 void moreReleased();
71 void lessReleased(); 103 void lessReleased();
104 void forwardClicked();
105 void backClicked();
106 void forwardReleased();
107 void backReleased();
72 void sliderMoved(long); 108 void sliderMoved(long);
73 109
74protected: 110protected:
75 void doBlank(); 111 void doBlank();
76 void doUnblank(); 112 void doUnblank();
77 void paintEvent( QPaintEvent *pe ); 113 void paintEvent( QPaintEvent *pe );
78 void showEvent( QShowEvent *se ); 114 void showEvent( QShowEvent *se );
79 void resizeEvent( QResizeEvent *re ); 115 void resizeEvent( QResizeEvent *re );
80 void mouseMoveEvent( QMouseEvent *event ); 116 void mouseMoveEvent( QMouseEvent *event );
81 void mousePressEvent( QMouseEvent *event ); 117 void mousePressEvent( QMouseEvent *event );
82 void mouseReleaseEvent( QMouseEvent *event ); 118 void mouseReleaseEvent( QMouseEvent *event );
83 void timerEvent( QTimerEvent *event ); 119 void timerEvent( QTimerEvent *event );
84 void closeEvent( QCloseEvent *event ); 120 void closeEvent( QCloseEvent *event );
85 void keyReleaseEvent( QKeyEvent *e); 121 void keyReleaseEvent( QKeyEvent *e);
122private slots:
123 void skipFor();
124 void skipBack();
125 void stopSkip();
86private: 126private:
87 void toggleButton( int ); 127 void toggleButton( int );
88 void setToggleButton( int, bool ); 128 void setToggleButton( int, bool );
89 void paintButton( QPainter *p, int i ); 129 void paintButton( QPainter *p, int i );
130 int skipDirection;
90 QString skin; 131 QString skin;
91 QPixmap *pixBg; 132 QPixmap *pixBg;
92 QImage *imgUp; 133 QImage *imgUp;
93 QImage *imgDn; 134 QImage *imgDn;
94 QImage *imgButtonMask; 135 QImage *imgButtonMask;
95 QBitmap *masks[11]; 136 QBitmap *masks[11];
96 QPixmap *buttonPixUp[11]; 137 QPixmap *buttonPixUp[11];
97 QPixmap *buttonPixDown[11]; 138 QPixmap *buttonPixDown[11];
98 139
99 QPixmap *pixmaps[4]; 140 QPixmap *pixmaps[4];
100 Ticker songInfo; 141 Ticker songInfo;
101 QSlider slider; 142 QSlider slider;
102 QLineEdit time; 143 QLineEdit time;
103 int xoff, yoff; 144 int xoff, yoff;
104}; 145};
105 146
106 147
107#endif // AUDIO_WIDGET_H 148#endif // AUDIO_WIDGET_H
108 149