Skip to content

Commit

Permalink
Merge pull request #5037 from nyalldawson/render_progress_bar
Browse files Browse the repository at this point in the history
Avoid 'flashy' status bar progress widget when map renders are fast
  • Loading branch information
nyalldawson committed Aug 18, 2017
2 parents 0c46ac4 + 7a314f3 commit 86949cb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -8283,11 +8283,32 @@ void QgisApp::refreshMapCanvas()

void QgisApp::canvasRefreshStarted()
{
showProgress( -1, 0 ); // trick to make progress bar show busy indicator
mLastRenderTime.restart();
// if previous render took less than 0.5 seconds, delay the appearance of the
// render in progress status bar by 0.5 seconds - this avoids the status bar
// rapidly appearing and then disappearing for very fast renders
if ( mLastRenderTimeSeconds > 0 && mLastRenderTimeSeconds < 0.5 )
{
mRenderProgressBarTimer.setSingleShot( true );
mRenderProgressBarTimer.setInterval( 500 );
disconnect( mRenderProgressBarTimerConnection );
mRenderProgressBarTimerConnection = connect( &mRenderProgressBarTimer, &QTimer::timeout, [ = ]()
{
showProgress( -1, 0 );
}
);
mRenderProgressBarTimer.start();
}
else
{
showProgress( -1, 0 ); // trick to make progress bar show busy indicator
}
}

void QgisApp::canvasRefreshFinished()
{
mRenderProgressBarTimer.stop();
mLastRenderTimeSeconds = mLastRenderTime.elapsed() / 1000.0;
showProgress( 0, 0 ); // stop the busy indicator
}

Expand Down
5 changes: 5 additions & 0 deletions src/app/qgisapp.h
Expand Up @@ -2067,6 +2067,11 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow

QgsStatusBar *mStatusBar = nullptr;

QTime mLastRenderTime;
double mLastRenderTimeSeconds = 0;
QTimer mRenderProgressBarTimer;
QMetaObject::Connection mRenderProgressBarTimerConnection;

friend class TestQgisAppPython;
};

Expand Down

0 comments on commit 86949cb

Please sign in to comment.