Skip to content

Commit ebea35d

Browse files
committedJul 8, 2018
Make it possible to enable/disable playback in loop
1 parent da5f354 commit ebea35d

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed
 

‎src/app/3d/qgs3danimationwidget.cpp

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Qgs3DAnimationWidget::Qgs3DAnimationWidget( QWidget *parent )
3333
btnEditKeyframe->setIcon( QIcon( QgsApplication::iconPath( "symbologyEdit.svg" ) ) );
3434
btnPlayPause->setIcon( QIcon( QgsApplication::iconPath( "mTaskRunning.svg" ) ) );
3535
btnDuplicateKeyframe->setIcon( QIcon( QgsApplication::iconPath( "mActionEditCopy.svg" ) ) );
36+
btnRepeat->setIcon( QIcon( QgsApplication::iconPath( "mActionRefresh.svg" ) ) );
3637

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

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

52+
btnRepeat->setCheckable( true );
53+
5154
connect( sliderTime, &QSlider::valueChanged, this, &Qgs3DAnimationWidget::onSliderValueChanged );
5255

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

140143
void Qgs3DAnimationWidget::onAnimationTimer()
141144
{
142-
float duration = sliderTime->maximum();
143-
sliderTime->setValue( sliderTime->value() >= duration ? 0 : sliderTime->value() + 1 );
145+
if ( sliderTime->value() >= sliderTime->maximum() )
146+
{
147+
if ( btnRepeat->isChecked() )
148+
sliderTime->setValue( 0 );
149+
else
150+
{
151+
// stop playback
152+
onPlayPause();
153+
btnPlayPause->setChecked( false );
154+
}
155+
}
156+
else
157+
{
158+
sliderTime->setValue( sliderTime->value() + 1 );
159+
}
144160
}
145161

146162

@@ -173,7 +189,12 @@ void Qgs3DAnimationWidget::onCameraChanged()
173189

174190
void Qgs3DAnimationWidget::onKeyframeChanged()
175191
{
176-
if ( cboKeyframe->currentIndex() <= 0 )
192+
bool hasKeyframe = cboKeyframe->currentIndex() > 0;
193+
btnRemoveKeyframe->setEnabled( hasKeyframe );
194+
btnEditKeyframe->setEnabled( hasKeyframe );
195+
btnDuplicateKeyframe->setEnabled( hasKeyframe );
196+
197+
if ( !hasKeyframe )
177198
return;
178199

179200
// jump to the camera view of the keyframe

‎src/ui/3d/animation3dwidget.ui

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,16 @@
106106
</property>
107107
</widget>
108108
</item>
109+
<item>
110+
<widget class="QToolButton" name="btnRepeat">
111+
<property name="toolTip">
112+
<string>Repeat</string>
113+
</property>
114+
<property name="text">
115+
<string>...</string>
116+
</property>
117+
</widget>
118+
</item>
109119
</layout>
110120
</item>
111121
</layout>

0 commit comments

Comments
 (0)
Please sign in to comment.