Skip to content
Permalink
Browse files

Make it possible to enable/disable playback in loop

  • Loading branch information
wonder-sk committed Jul 5, 2018
1 parent da5f354 commit ebea35d05f3cde14a22038e9c90f5f809a6d2f8c
Showing with 34 additions and 3 deletions.
  1. +24 −3 src/app/3d/qgs3danimationwidget.cpp
  2. +10 −0 src/ui/3d/animation3dwidget.ui
@@ -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>" ) );

@@ -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 );
@@ -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 );
}
}


@@ -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
@@ -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>

0 comments on commit ebea35d

Please sign in to comment.
You can’t perform that action at this time.