Diffstat (limited to 'noncore/multimedia/opieplayer2/audiowidget.h') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 44 |
1 files changed, 7 insertions, 37 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index eab5df4..441eb6e 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h | |||
@@ -30,45 +30,15 @@ enum AudioButtons { | |||
30 | 30 | ||
31 | class Ticker : public QFrame { | 31 | class Ticker : public QFrame { |
32 | Q_OBJECT | 32 | Q_OBJECT |
33 | |||
33 | public: | 34 | public: |
34 | Ticker( QWidget* parent=0 ) : QFrame( parent ) { | 35 | Ticker( QWidget* parent=0 ); |
35 | setFrameStyle( WinPanel | Sunken ); | 36 | ~Ticker(); |
36 | setText( "No Song" ); | 37 | void setText( const QString& text ) ; |
37 | } | 38 | |
38 | ~Ticker() { } | ||
39 | void setText( const QString& text ) { | ||
40 | pos = 0; // reset it everytime the text is changed | ||
41 | scrollText = text; | ||
42 | pixelLen = fontMetrics().width( scrollText ); | ||
43 | killTimers(); | ||
44 | if ( pixelLen > width() ) | ||
45 | startTimer( 50 ); | ||
46 | update(); | ||
47 | } | ||
48 | protected: | 39 | protected: |
49 | void timerEvent( QTimerEvent * ) { | 40 | void timerEvent( QTimerEvent * ); |
50 | pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; | 41 | void drawContents( QPainter *p ); |
51 | #ifndef USE_DBLBUF | ||
52 | scroll( -1, 0, contentsRect() ); | ||
53 | #else | ||
54 | repaint( FALSE ); | ||
55 | #endif | ||
56 | } | ||
57 | void drawContents( QPainter *p ) { | ||
58 | #ifndef USE_DBLBUF | ||
59 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) | ||
60 | p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | ||
61 | #else | ||
62 | // Double buffering code. | ||
63 | // Looks like qvfb makes it look like it flickers but I don't think it really is | ||
64 | QPixmap pm( width(), height() ); | ||
65 | pm.fill( colorGroup().base() ); | ||
66 | QPainter pmp( &pm ); | ||
67 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) | ||
68 | pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | ||
69 | p->drawPixmap( 0, 0, pm ); | ||
70 | #endif | ||
71 | } | ||
72 | private: | 42 | private: |
73 | QString scrollText; | 43 | QString scrollText; |
74 | int pos, pixelLen; | 44 | int pos, pixelLen; |