From a20f4643997e583f7c04422b004cea37afca3759 Mon Sep 17 00:00:00 2001 From: apo Date: Mon, 16 Jun 2008 08:37:34 +0000 Subject: [PATCH] To introduce "cycling" feature for "slider" functionality --- src/VISUGUI/VisuGUI_Slider.cxx | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/VISUGUI/VisuGUI_Slider.cxx b/src/VISUGUI/VisuGUI_Slider.cxx index aed93da6..d7be50ca 100644 --- a/src/VISUGUI/VisuGUI_Slider.cxx +++ b/src/VISUGUI/VisuGUI_Slider.cxx @@ -154,7 +154,7 @@ VisuGUI_Slider::VisuGUI_Slider( VisuGUI* theModule, myIsCycled->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); myIsCycled->setLayoutDirection( Qt::LeftToRight ); myIsCycled->setCheckable( true ); - myIsCycled->setEnabled( false ); + //myIsCycled->setEnabled( false ); aGridLayout->addWidget( myIsCycled, 2, 2, 1, 1 ); myTimeStampStrings = new QComboBox( aParent ); @@ -228,12 +228,13 @@ VisuGUI_Slider::VisuGUI_Slider( VisuGUI* theModule, aHBoxLayout->addWidget( aLabel ); mySpeedSlider = new QSlider( aParent ); - mySpeedSlider->setLayoutDirection( Qt::RightToLeft ); + mySpeedSlider->setMinimum( 1 ); mySpeedSlider->setMaximum( 100 ); - mySpeedSlider->setValue( 55 ); + mySpeedSlider->setValue( mySpeedSlider->maximum() / 2 ); + mySpeedSlider->setPageStep( mySpeedSlider->maximum() / 5 ); + mySpeedSlider->setTickInterval( mySpeedSlider->pageStep() ); mySpeedSlider->setOrientation( Qt::Horizontal ); mySpeedSlider->setTickPosition( QSlider::TicksBelow ); - mySpeedSlider->setTickInterval( 20 ); aHBoxLayout->addWidget( mySpeedSlider ); aVBoxLayout->addLayout( aHBoxLayout ); @@ -540,15 +541,15 @@ void VisuGUI_Slider::onPlay( bool on ) { if( on ) { - myPlayButton->setIcon( myPlayPixmap ); + myPlayButton->setIcon( myPausePixmap ); - int delay = int(5000.0 / double(mySpeedSlider->value())); + int delay = int( 50.0 * mySpeedSlider->maximum() / mySpeedSlider->value() ); myTimer->start( delay ); } else { myTimer->stop(); - myPlayButton->setIcon( myPausePixmap ); + myPlayButton->setIcon( myPlayPixmap ); } } @@ -638,7 +639,7 @@ void VisuGUI_Slider::onValueChanged( int value ) void VisuGUI_Slider::onSpeedChanged( int value ) { if(myPlayButton->isChecked()){ - int delay = int(5000.0 / double(mySpeedSlider->value())); + int delay = int( 50.0 * mySpeedSlider->maximum() / mySpeedSlider->value() ); myTimer->start( delay ); } } @@ -648,10 +649,14 @@ void VisuGUI_Slider::onSpeedChanged( int value ) void VisuGUI_Slider::onTimeout() { int value = mySlider->value(); - if( value < mySlider->maximum() ) + if ( value < mySlider->maximum() ) { onNext(); - else - myPlayButton->setChecked( false ); + } else { + if ( myIsCycled->isChecked() ) + onFirst(); + else + myPlayButton->setChecked( false ); + } } -- 2.39.2