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,6 +1,38 @@
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>
@@ -159,12 +191,19 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
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() );
@@ -338,13 +377,37 @@ void AudioWidget::paintButton( QPainter *p, int i ) {
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 ) {
@@ -360,41 +423,49 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
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
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,6 +1,39 @@
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>
@@ -19,19 +52,18 @@ enum AudioButtons {
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();
@@ -66,12 +98,16 @@ public slots:
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 );
@@ -80,25 +116,30 @@ protected:
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};