author | harlekin <harlekin> | 2002-07-03 14:44:22 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-07-03 14:44:22 (UTC) |
commit | e1e4956ec7ffa9a07f98b03e831f0f9627556a6c (patch) (side-by-side diff) | |
tree | c0545c6a22732f05804bda7704227132f64b7239 /noncore/multimedia/opieplayer2/audiowidget.cpp | |
parent | 61770de77f2abe8012d44cce49d04489e4187644 (diff) | |
download | opie-e1e4956ec7ffa9a07f98b03e831f0f9627556a6c.zip opie-e1e4956ec7ffa9a07f98b03e831f0f9627556a6c.tar.gz opie-e1e4956ec7ffa9a07f98b03e831f0f9627556a6c.tar.bz2 |
much more code cleanup, make if look more like c++ code
Diffstat (limited to 'noncore/multimedia/opieplayer2/audiowidget.cpp') (more/less context) (show 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 @@ -12,24 +12,63 @@ #include "audiowidget.h" #include "mediaplayerstate.h" extern MediaPlayerState *mediaPlayerState; - static const int xo = -2; // movable x offset static const int yo = 22; // movable y offset +Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { + setFrameStyle( WinPanel | Sunken ); + setText( "No Song" ); +} + +Ticker::~Ticker() { +} + +void Ticker::setText( const QString& text ) { + pos = 0; // reset it everytime the text is changed + scrollText = text; + pixelLen = fontMetrics().width( scrollText ); + killTimers(); + if ( pixelLen > width() ) { + startTimer( 50 ); + } + update(); +} + + +void Ticker::timerEvent( QTimerEvent * ) { + pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; + repaint( FALSE ); +} + +void Ticker::drawContents( QPainter *p ) { + QPixmap pm( width(), height() ); + pm.fill( colorGroup().base() ); + QPainter pmp( &pm ); + for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { + pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); + } + p->drawPixmap( 0, 0, pm ); +} + + + + struct MediaButton { int xPos, yPos; int color; bool isToggle, isBig, isHeld, isDown; }; + + // Layout information for the audioButtons (and if it is a toggle button or not) MediaButton audioButtons[] = { { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next @@ -37,13 +76,12 @@ MediaButton audioButtons[] = { { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist }; - static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : QWidget( parent, name, f ) { @@ -142,13 +180,12 @@ void AudioWidget::setView( char view ) { connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); } if ( view == 'a' ) { startTimer( 150 ); - // show(); showMaximized(); } else { killTimers(); hide(); } } |