author | llornkcor <llornkcor> | 2002-04-21 14:06:57 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-21 14:06:57 (UTC) |
commit | 05158fd95b12800666a7a0620a32390e61979385 (patch) (side-by-side diff) | |
tree | 5b62d42fada3eda8a518389fc04d3aaf2f02aefd | |
parent | 2da038246124a92248add8195126ac7bd21512f6 (diff) | |
download | opie-05158fd95b12800666a7a0620a32390e61979385.zip opie-05158fd95b12800666a7a0620a32390e61979385.tar.gz opie-05158fd95b12800666a7a0620a32390e61979385.tar.bz2 |
really fixed slider
-rw-r--r-- | core/multimedia/opieplayer/audiowidget.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp index b9561d5..e2e3603 100644 --- a/core/multimedia/opieplayer/audiowidget.cpp +++ b/core/multimedia/opieplayer/audiowidget.cpp @@ -72,98 +72,104 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : pixmaps[3] = new QPixmap( Resource::loadPixmap( "opieplayer/animatedButton" ) ); songInfo = new Ticker( this ); songInfo->setFocusPolicy( QWidget::NoFocus ); songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); slider = new QSlider( Qt::Horizontal, this ); slider->setFixedWidth( 220 ); slider->setFixedHeight( 20 ); slider->setMinValue( 0 ); slider->setMaxValue( 1 ); slider->setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); slider->setFocusPolicy( QWidget::NoFocus ); slider->setGeometry( QRect( 7, 262, 220, 20 ) ); connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); - if( !mediaPlayerState->isStreaming) { // this stops the slider from being moved, thus - // does not stop stream when it reaches the end - connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); - connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); - } // Intialise state setLength( mediaPlayerState->length() ); setPosition( mediaPlayerState->position() ); setLooping( mediaPlayerState->fullscreen() ); setPaused( mediaPlayerState->paused() ); setPlaying( mediaPlayerState->playing() ); - if (mediaPlayerState->isStreaming) slider->hide(); } AudioWidget::~AudioWidget() { for ( int i = 0; i < 4; i++ ) delete pixmaps[i]; } static bool audioSliderBeingMoved = FALSE; void AudioWidget::sliderPressed() { audioSliderBeingMoved = TRUE; } void AudioWidget::sliderReleased() { audioSliderBeingMoved = FALSE; if ( slider->width() == 0 ) return; long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); mediaPlayerState->setPosition( val ); } void AudioWidget::setPosition( long i ) { updateSlider( i, mediaPlayerState->length() ); } void AudioWidget::setLength( long max ) { updateSlider( mediaPlayerState->position(), max ); } void AudioWidget::setView( char view ) { + if (mediaPlayerState->isStreaming) { + if( !slider->isHidden()) slider->hide(); + 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 + if( slider->isHidden()) 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 ); showMaximized(); } else { killTimers(); hide(); } } void AudioWidget::updateSlider( long i, long max ) { if ( max == 0 ) return; // Will flicker too much if we don't do this // Scale to something reasonable int width = slider->width(); int val = int((double)i * width / max); if ( !audioSliderBeingMoved ) { if ( slider->value() != val ) slider->setValue( val ); if ( slider->maxValue() != width ) slider->setMaxValue( width ); } } |