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
@@ -15,11 +15,48 @@
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;
@@ -27,6 +64,8 @@ struct MediaButton {
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
@@ -40,7 +79,6 @@ MediaButton audioButtons[] = {
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
@@ -145,7 +183,6 @@ void AudioWidget::setView( char view ) {
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();