Skip to content

Commit

Permalink
Make play/rewind/pause buttons show animation state, and add explicit
Browse files Browse the repository at this point in the history
buttons to fast forward to end or rewind to start of animation
  • Loading branch information
nyalldawson committed Mar 12, 2020
1 parent 6eaefb6 commit 2328902
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 62 deletions.
47 changes: 16 additions & 31 deletions src/gui/qgstemporalcontrollerdockwidget.cpp
Expand Up @@ -32,11 +32,20 @@ QgsTemporalControllerDockWidget::QgsTemporalControllerDockWidget( const QString

mNavigationObject = new QgsTemporalNavigationObject( this );

connect( mForwardButton, &QPushButton::clicked, this, &QgsTemporalControllerDockWidget::forwardButton_clicked );
connect( mBackButton, &QPushButton::clicked, this, &QgsTemporalControllerDockWidget::backButton_clicked );
connect( mNextButton, &QPushButton::clicked, this, &QgsTemporalControllerDockWidget::nextButton_clicked );
connect( mPreviousButton, &QPushButton::clicked, this, &QgsTemporalControllerDockWidget::previousButton_clicked );
connect( mStopButton, &QPushButton::clicked, this, &QgsTemporalControllerDockWidget::stopButton_clicked );
connect( mForwardButton, &QPushButton::clicked, mNavigationObject, &QgsTemporalNavigationObject::playForward );
connect( mBackButton, &QPushButton::clicked, mNavigationObject, &QgsTemporalNavigationObject::playBackward );
connect( mNextButton, &QPushButton::clicked, mNavigationObject, &QgsTemporalNavigationObject::next );
connect( mPreviousButton, &QPushButton::clicked, mNavigationObject, &QgsTemporalNavigationObject::previous );
connect( mStopButton, &QPushButton::clicked, mNavigationObject, &QgsTemporalNavigationObject::pause );
connect( mFastForwardButton, &QPushButton::clicked, mNavigationObject, &QgsTemporalNavigationObject::skipToEnd );
connect( mRewindButton, &QPushButton::clicked, mNavigationObject, &QgsTemporalNavigationObject::rewindToStart );

connect( mNavigationObject, &QgsTemporalNavigationObject::stateChanged, this, [ = ]( QgsTemporalNavigationObject::AnimationState state )
{
mForwardButton->setChecked( state == QgsTemporalNavigationObject::Forward );
mBackButton->setChecked( state == QgsTemporalNavigationObject::Reverse );
mStopButton->setChecked( state == QgsTemporalNavigationObject::Idle );
} );

connect( mStartDateTime, &QDateTimeEdit::dateTimeChanged, this, &QgsTemporalControllerDockWidget::updateTemporalExtent );
connect( mEndDateTime, &QDateTimeEdit::dateTimeChanged, this, &QgsTemporalControllerDockWidget::updateTemporalExtent );
Expand Down Expand Up @@ -95,6 +104,8 @@ QgsTemporalControllerDockWidget::QgsTemporalControllerDockWidget( const QString
mNextButton->setToolTip( tr( "Go to next frame" ) );
mPreviousButton->setToolTip( tr( "Go to previous frame" ) );
mStopButton->setToolTip( tr( "Pause" ) );
mRewindButton->setToolTip( tr( "Rewind to start" ) );
mFastForwardButton->setToolTip( tr( "Fast forward to end" ) );

updateFrameDuration();
}
Expand Down Expand Up @@ -162,32 +173,6 @@ void QgsTemporalControllerDockWidget::setDatesToProjectTime()
}
}

void QgsTemporalControllerDockWidget::stopButton_clicked()
{
updateButtonsEnable( true );
mNavigationObject->pause();
}

void QgsTemporalControllerDockWidget::forwardButton_clicked()
{
mNavigationObject->playForward();
}

void QgsTemporalControllerDockWidget::backButton_clicked()
{
mNavigationObject->playBackward();
}

void QgsTemporalControllerDockWidget::nextButton_clicked()
{
mNavigationObject->next();
}

void QgsTemporalControllerDockWidget::previousButton_clicked()
{
mNavigationObject->previous();
}

void QgsTemporalControllerDockWidget::setDateInputsEnable( bool enabled )
{
mStartDateTime->setEnabled( enabled );
Expand Down
30 changes: 0 additions & 30 deletions src/gui/qgstemporalcontrollerdockwidget.h
Expand Up @@ -71,36 +71,6 @@ class GUI_EXPORT QgsTemporalControllerDockWidget : public QgsDockWidget, private

private slots:

/**
* Handles the action to be done when the
* previous button on the widget is clicked.
**/
void previousButton_clicked();

/**
* Handles the action to be done when the
* next button on the widget is clicked.
**/
void nextButton_clicked();

/**
* Handles the action to be done when the
* stop button on the widget is clicked.
**/
void stopButton_clicked();

/**
* Handles the action to be done when the
* back button on the widget is clicked.
**/
void backButton_clicked();

/**
* Handles the action to be done when the
* forward button on the widget is clicked.
**/
void forwardButton_clicked();

/**
* Handles the action to be done when the
* time slider value has changed.
Expand Down
35 changes: 34 additions & 1 deletion src/ui/qgstemporalcontrollerdockwidgetbase.ui
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>1205</width>
<height>134</height>
<height>136</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -52,6 +52,17 @@
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QPushButton" name="mRewindButton">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/temporal_navigation/previous.svg</normaloff>:/images/themes/default/temporal_navigation/previous.svg</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mPreviousButton">
<property name="text">
Expand All @@ -72,6 +83,9 @@
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/temporal_navigation/back.svg</normaloff>:/images/themes/default/temporal_navigation/back.svg</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
Expand All @@ -83,6 +97,9 @@
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/temporal_navigation/stop.svg</normaloff>:/images/themes/default/temporal_navigation/stop.svg</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
Expand All @@ -94,6 +111,9 @@
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/temporal_navigation/forward.svg</normaloff>:/images/themes/default/temporal_navigation/forward.svg</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
Expand All @@ -107,6 +127,17 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mFastForwardButton">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/temporal_navigation/next.svg</normaloff>:/images/themes/default/temporal_navigation/next.svg</iconset>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
Expand Down Expand Up @@ -229,6 +260,8 @@
</customwidgets>
<resources>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
</resources>
<connections/>
</ui>

0 comments on commit 2328902

Please sign in to comment.