summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/audiowidget.cpp
Side-by-side diff
Diffstat (limited to 'noncore/multimedia/opieplayer2/audiowidget.cpp') (more/less context) (show 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
@@ -6,50 +6,88 @@
#include <qwidget.h>
#include <qpixmap.h>
#include <qbutton.h>
#include <qpainter.h>
#include <qframe.h>
#include <qlayout.h>
#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
{ 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous
{ 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 )
{
setCaption( tr("OpiePlayer - Audio") );
Config cfg("OpiePlayer");
cfg.setGroup("AudioWidget");
QString backgroundPix, buttonsAllPix, buttonsBigPix, controlsPix, animatedPix;
backgroundPix=cfg.readEntry( " backgroundPix", "opieplayer/metalFinish");
@@ -136,25 +174,24 @@ void AudioWidget::setView( char view ) {
disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
} else {
// this stops the slider from being moved, thus
// does not stop stream when it reaches the end
slider->show();
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();
}
}
void AudioWidget::updateSlider( long i, long max ) {
if ( max == 0 ) {
return;
}