From: apo Date: Mon, 16 Jun 2008 08:37:34 +0000 (+0000) Subject: To introduce "cycling" feature for "slider" functionality X-Git-Tag: TG_VISU_2008_2008-06-26~15 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a20f4643997e583f7c04422b004cea37afca3759;p=modules%2Fvisu.git To introduce "cycling" feature for "slider" functionality --- 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 ); + } }