Diffstat (limited to 'noncore/multimedia/opieplayer2/audiowidget.h') (more/less context) (ignore 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 | |||
@@ -21,63 +21,33 @@ enum AudioButtons { | |||
21 | AudioVolumeUp, | 21 | AudioVolumeUp, |
22 | AudioVolumeDown, | 22 | AudioVolumeDown, |
23 | AudioLoop, | 23 | AudioLoop, |
24 | AudioPlayList | 24 | AudioPlayList |
25 | }; | 25 | }; |
26 | 26 | ||
27 | 27 | ||
28 | #define USE_DBLBUF | 28 | #define USE_DBLBUF |
29 | 29 | ||
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; |
75 | }; | 45 | }; |
76 | 46 | ||
77 | 47 | ||
78 | class AudioWidget : public QWidget { | 48 | class AudioWidget : public QWidget { |
79 | Q_OBJECT | 49 | Q_OBJECT |
80 | public: | 50 | public: |
81 | AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); | 51 | AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); |
82 | ~AudioWidget(); | 52 | ~AudioWidget(); |
83 | void setTickerText( const QString &text ) { songInfo->setText( text ); } | 53 | void setTickerText( const QString &text ) { songInfo->setText( text ); } |