Skip to content
Permalink
Browse files

Merge pull request #5037 from nyalldawson/render_progress_bar

Avoid 'flashy' status bar progress widget when map renders are fast
  • Loading branch information
nyalldawson committed Aug 18, 2017
2 parents 0c46ac4 + 7a314f3 commit 86949cb2fad90df9aeb1ae444d317f322470e7c1
Showing with 27 additions and 1 deletion.
  1. +22 −1 src/app/qgisapp.cpp
  2. +5 −0 src/app/qgisapp.h
@@ -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
}

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

0 comments on commit 86949cb

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