Skip to content
Permalink
Browse files

Avoid 'flashy' status bar progress widget when map renders are fast

If previous canvas render took less than 0.5 seconds, delay the appearance of the
'render in progress' status bar widget by a short amount - this avoids the
status bar rapidly appearing and then disappearing for very fast renders
  • Loading branch information
nyalldawson committed Aug 17, 2017
1 parent 26a911c commit 7a314f3cb256da52517f821192d61a5d25f69640
Showing with 27 additions and 1 deletion.
  1. +22 −1 src/app/qgisapp.cpp
  2. +5 −0 src/app/qgisapp.h
@@ -8282,11 +8282,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 7a314f3

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