summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/audiowidget.cpp
Unidiff
Diffstat (limited to 'noncore/multimedia/opieplayer2/audiowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp43
1 files changed, 40 insertions, 3 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 8d3963a..1b0de5d 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -12,24 +12,63 @@
12 12
13#include "audiowidget.h" 13#include "audiowidget.h"
14#include "mediaplayerstate.h" 14#include "mediaplayerstate.h"
15 15
16extern MediaPlayerState *mediaPlayerState; 16extern MediaPlayerState *mediaPlayerState;
17 17
18
19static const int xo = -2; // movable x offset 18static const int xo = -2; // movable x offset
20static const int yo = 22; // movable y offset 19static const int yo = 22; // movable y offset
21 20
22 21
22Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) {
23 setFrameStyle( WinPanel | Sunken );
24 setText( "No Song" );
25}
26
27Ticker::~Ticker() {
28}
29
30void Ticker::setText( const QString& text ) {
31 pos = 0; // reset it everytime the text is changed
32 scrollText = text;
33 pixelLen = fontMetrics().width( scrollText );
34 killTimers();
35 if ( pixelLen > width() ) {
36 startTimer( 50 );
37 }
38 update();
39}
40
41
42void Ticker::timerEvent( QTimerEvent * ) {
43 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1;
44 repaint( FALSE );
45}
46
47void Ticker::drawContents( QPainter *p ) {
48 QPixmap pm( width(), height() );
49 pm.fill( colorGroup().base() );
50 QPainter pmp( &pm );
51 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) {
52 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
53 }
54 p->drawPixmap( 0, 0, pm );
55}
56
57
58
59
23struct MediaButton { 60struct MediaButton {
24 int xPos, yPos; 61 int xPos, yPos;
25 int color; 62 int color;
26 bool isToggle, isBig, isHeld, isDown; 63 bool isToggle, isBig, isHeld, isDown;
27}; 64};
28 65
29 66
67
68
30// Layout information for the audioButtons (and if it is a toggle button or not) 69// Layout information for the audioButtons (and if it is a toggle button or not)
31MediaButton audioButtons[] = { 70MediaButton audioButtons[] = {
32 { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play 71 { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play
33 { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop 72 { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop
34 { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause 73 { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause
35 { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next 74 { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next
@@ -37,13 +76,12 @@ MediaButton audioButtons[] = {
37 { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up 76 { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up
38 { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down 77 { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down
39 { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop 78 { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop
40 { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist 79 { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist
41}; 80};
42 81
43
44static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 82static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
45 83
46 84
47AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 85AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
48 QWidget( parent, name, f ) 86 QWidget( parent, name, f )
49{ 87{
@@ -142,13 +180,12 @@ void AudioWidget::setView( char view ) {
142 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 180 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
143 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 181 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
144 } 182 }
145 183
146 if ( view == 'a' ) { 184 if ( view == 'a' ) {
147 startTimer( 150 ); 185 startTimer( 150 );
148 // show();
149 showMaximized(); 186 showMaximized();
150 } else { 187 } else {
151 killTimers(); 188 killTimers();
152 hide(); 189 hide();
153 } 190 }
154} 191}