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
@@ -6,50 +6,88 @@
6#include <qwidget.h> 6#include <qwidget.h>
7#include <qpixmap.h> 7#include <qpixmap.h>
8#include <qbutton.h> 8#include <qbutton.h>
9#include <qpainter.h> 9#include <qpainter.h>
10#include <qframe.h> 10#include <qframe.h>
11#include <qlayout.h> 11#include <qlayout.h>
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
36 { 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous 75 { 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous
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{
50 setCaption( tr("OpiePlayer - Audio") ); 88 setCaption( tr("OpiePlayer - Audio") );
51 Config cfg("OpiePlayer"); 89 Config cfg("OpiePlayer");
52 cfg.setGroup("AudioWidget"); 90 cfg.setGroup("AudioWidget");
53 91
54 QString backgroundPix, buttonsAllPix, buttonsBigPix, controlsPix, animatedPix; 92 QString backgroundPix, buttonsAllPix, buttonsBigPix, controlsPix, animatedPix;
55 backgroundPix=cfg.readEntry( " backgroundPix", "opieplayer/metalFinish"); 93 backgroundPix=cfg.readEntry( " backgroundPix", "opieplayer/metalFinish");
@@ -136,25 +174,24 @@ void AudioWidget::setView( char view ) {
136 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 174 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
137 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 175 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
138 } else { 176 } else {
139 // this stops the slider from being moved, thus 177 // this stops the slider from being moved, thus
140 // does not stop stream when it reaches the end 178 // does not stop stream when it reaches the end
141 slider->show(); 179 slider->show();
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}
155 192
156 193
157void AudioWidget::updateSlider( long i, long max ) { 194void AudioWidget::updateSlider( long i, long max ) {
158 if ( max == 0 ) { 195 if ( max == 0 ) {
159 return; 196 return;
160 } 197 }