Diffstat (limited to 'noncore/multimedia/opieplayer2/audiowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 43 |
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 | |||
@@ -17,3 +17,2 @@ extern MediaPlayerState *mediaPlayerState; | |||
17 | 17 | ||
18 | |||
19 | static const int xo = -2; // movable x offset | 18 | static const int xo = -2; // movable x offset |
@@ -22,2 +21,40 @@ static const int yo = 22; // movable y offset | |||
22 | 21 | ||
22 | Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { | ||
23 | setFrameStyle( WinPanel | Sunken ); | ||
24 | setText( "No Song" ); | ||
25 | } | ||
26 | |||
27 | Ticker::~Ticker() { | ||
28 | } | ||
29 | |||
30 | void 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 | |||
42 | void Ticker::timerEvent( QTimerEvent * ) { | ||
43 | pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; | ||
44 | repaint( FALSE ); | ||
45 | } | ||
46 | |||
47 | void 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 | |||
23 | struct MediaButton { | 60 | struct MediaButton { |
@@ -29,2 +66,4 @@ struct MediaButton { | |||
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) |
@@ -42,3 +81,2 @@ MediaButton audioButtons[] = { | |||
42 | 81 | ||
43 | |||
44 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 82 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
@@ -147,3 +185,2 @@ void AudioWidget::setView( char view ) { | |||
147 | startTimer( 150 ); | 185 | startTimer( 150 ); |
148 | // show(); | ||
149 | showMaximized(); | 186 | showMaximized(); |