Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make it possible to enable/disable playback in loop
  • Loading branch information
wonder-sk committed Jul 8, 2018
1 parent da5f354 commit ebea35d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/app/3d/qgs3danimationwidget.cpp
Expand Up @@ -33,6 +33,7 @@ Qgs3DAnimationWidget::Qgs3DAnimationWidget( QWidget *parent )
btnEditKeyframe->setIcon( QIcon( QgsApplication::iconPath( "symbologyEdit.svg" ) ) );
btnPlayPause->setIcon( QIcon( QgsApplication::iconPath( "mTaskRunning.svg" ) ) );
btnDuplicateKeyframe->setIcon( QIcon( QgsApplication::iconPath( "mActionEditCopy.svg" ) ) );
btnRepeat->setIcon( QIcon( QgsApplication::iconPath( "mActionRefresh.svg" ) ) );

cboKeyframe->addItem( tr( "<none>" ) );

Expand All @@ -48,6 +49,8 @@ Qgs3DAnimationWidget::Qgs3DAnimationWidget( QWidget *parent )
btnPlayPause->setCheckable( true );
connect( btnPlayPause, &QToolButton::clicked, this, &Qgs3DAnimationWidget::onPlayPause );

btnRepeat->setCheckable( true );

connect( sliderTime, &QSlider::valueChanged, this, &Qgs3DAnimationWidget::onSliderValueChanged );

connect( cboKeyframe, qgis::overload<int>::of( &QComboBox::currentIndexChanged ), this, &Qgs3DAnimationWidget::onKeyframeChanged );
Expand Down Expand Up @@ -139,8 +142,21 @@ void Qgs3DAnimationWidget::onPlayPause()

void Qgs3DAnimationWidget::onAnimationTimer()
{
float duration = sliderTime->maximum();
sliderTime->setValue( sliderTime->value() >= duration ? 0 : sliderTime->value() + 1 );
if ( sliderTime->value() >= sliderTime->maximum() )
{
if ( btnRepeat->isChecked() )
sliderTime->setValue( 0 );
else
{
// stop playback
onPlayPause();
btnPlayPause->setChecked( false );
}
}
else
{
sliderTime->setValue( sliderTime->value() + 1 );
}
}


Expand Down Expand Up @@ -173,7 +189,12 @@ void Qgs3DAnimationWidget::onCameraChanged()

void Qgs3DAnimationWidget::onKeyframeChanged()
{
if ( cboKeyframe->currentIndex() <= 0 )
bool hasKeyframe = cboKeyframe->currentIndex() > 0;
btnRemoveKeyframe->setEnabled( hasKeyframe );
btnEditKeyframe->setEnabled( hasKeyframe );
btnDuplicateKeyframe->setEnabled( hasKeyframe );

if ( !hasKeyframe )
return;

// jump to the camera view of the keyframe
Expand Down
10 changes: 10 additions & 0 deletions src/ui/3d/animation3dwidget.ui
Expand Up @@ -106,6 +106,16 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnRepeat">
<property name="toolTip">
<string>Repeat</string>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
Expand Down

0 comments on commit ebea35d

Please sign in to comment.