summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-08-09 19:16:11 (UTC)
committer harlekin <harlekin>2002-08-09 19:16:11 (UTC)
commitd8e5c405aa6bf33b8b1d59443926876e8f056e5b (patch) (unidiff)
tree6b901dc26eef008f3c2797e1022b51d9bb2a569b
parentf0d1b8604699b964303288877db7b85a24222f5c (diff)
downloadopie-d8e5c405aa6bf33b8b1d59443926876e8f056e5b.zip
opie-d8e5c405aa6bf33b8b1d59443926876e8f056e5b.tar.gz
opie-d8e5c405aa6bf33b8b1d59443926876e8f056e5b.tar.bz2
skip buttons connected
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,4 +1,36 @@
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>
@@ -161,8 +193,15 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
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() );
@@ -340,9 +379,33 @@ void AudioWidget::paintButton( QPainter *p, int i ) {
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 ) {
@@ -362,15 +425,21 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
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);
@@ -379,20 +448,22 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
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 }
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,4 +1,37 @@
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>
@@ -21,15 +54,14 @@ enum AudioButtons {
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:
@@ -68,8 +100,12 @@ signals:
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();
@@ -82,21 +118,26 @@ protected:
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;