mirror of
https://github.com/qgis/QGIS.git
synced 2025-06-20 00:03:07 -04:00
Show busy indicator while rendering in map canvas
This commit is contained in:
parent
5852c8e8ed
commit
1c0ccb7e72
@ -363,15 +363,15 @@ class QgsMapCanvas : QGraphicsView
|
||||
//! - additional drawing shall be done directly within the renderer job or independently as a map canvas item
|
||||
void renderComplete( QPainter * );
|
||||
|
||||
// ### QGIS 3: renamte to mapRefreshFinished()
|
||||
/** Emitted when canvas finished a refresh request.
|
||||
\note Added in 2.0 */
|
||||
//! @deprecated since 2.4 - anything related to rendering progress is not visible outside of map canvas
|
||||
void mapCanvasRefreshed() /Deprecated/;
|
||||
void mapCanvasRefreshed();
|
||||
|
||||
// ### QGIS 3: rename to mapRefreshStarted()
|
||||
/** Emitted when the canvas is about to be rendered.
|
||||
\note Added in 1.5 */
|
||||
//! @deprecated since 2.4 - anything related to rendering progress is not visible outside of map canvas
|
||||
void renderStarting() /Deprecated/;
|
||||
void renderStarting();
|
||||
|
||||
//! Emitted when a new set of layers has been received
|
||||
void layersChanged();
|
||||
|
@ -1670,6 +1670,10 @@ void QgisApp::createStatusBar()
|
||||
mProgressBar->setWhatsThis( tr( "Progress bar that displays the status "
|
||||
"of rendering layers and other time-intensive operations" ) );
|
||||
statusBar()->addPermanentWidget( mProgressBar, 1 );
|
||||
|
||||
connect( mMapCanvas, SIGNAL( renderStarting() ), this, SLOT( canvasRefreshStarted() ) );
|
||||
connect( mMapCanvas, SIGNAL( mapCanvasRefreshed() ), this, SLOT( canvasRefreshFinished() ) );
|
||||
|
||||
// Bumped the font up one point size since 8 was too
|
||||
// small on some platforms. A point size of 9 still provides
|
||||
// plenty of display space on 1024x768 resolutions
|
||||
@ -3196,11 +3200,6 @@ void QgisApp::addMssqlLayer()
|
||||
void QgisApp::addOracleLayer()
|
||||
{
|
||||
#ifdef HAVE_ORACLE
|
||||
if ( mMapCanvas && mMapCanvas->isDrawing() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// show the Oracle dialog
|
||||
QDialog *dbs = dynamic_cast<QDialog*>( QgsProviderRegistry::instance()->selectWidget( "oracle", this ) );
|
||||
if ( !dbs )
|
||||
@ -5730,10 +5729,6 @@ void QgisApp::addRing()
|
||||
|
||||
void QgisApp::fillRing()
|
||||
{
|
||||
if ( mMapCanvas && mMapCanvas->isDrawing() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
mMapCanvas->setMapTool( mMapTools.mFillRing );
|
||||
}
|
||||
|
||||
@ -6147,6 +6142,16 @@ void QgisApp::refreshMapCanvas()
|
||||
mMapCanvas->refresh();
|
||||
}
|
||||
|
||||
void QgisApp::canvasRefreshStarted()
|
||||
{
|
||||
showProgress( -1, 0 ); // trick to make progress bar show busy indicator
|
||||
}
|
||||
|
||||
void QgisApp::canvasRefreshFinished()
|
||||
{
|
||||
showProgress( 0, 0 ); // stop the busy indicator
|
||||
}
|
||||
|
||||
void QgisApp::toggleMapTips()
|
||||
{
|
||||
mMapTipsVisible = !mMapTipsVisible;
|
||||
@ -8342,6 +8347,23 @@ void QgisApp::showProgress( int theProgress, int theTotalSteps )
|
||||
}
|
||||
mProgressBar->setMaximum( theTotalSteps );
|
||||
mProgressBar->setValue( theProgress );
|
||||
|
||||
if ( mProgressBar->maximum() == 0 )
|
||||
{
|
||||
// for busy indicator (when minimum equals to maximum) the oxygen Qt style (used in KDE)
|
||||
// has some issues and does not start busy indicator animation. This is an ugly fix
|
||||
// that forces creation of a temporary progress bar that somehow resumes the animations.
|
||||
// Caution: looking at the code below may introduce mild pain in stomach.
|
||||
if ( strcmp( QApplication::style()->metaObject()->className(), "Oxygen::Style" ) == 0 )
|
||||
{
|
||||
QProgressBar pb;
|
||||
pb.setAttribute( Qt::WA_DontShowOnScreen ); // no visual annoyance
|
||||
pb.setMaximum( 0 );
|
||||
pb.show();
|
||||
qApp->processEvents();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1019,6 +1019,11 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
|
||||
//! refresh map canvas
|
||||
void refreshMapCanvas();
|
||||
|
||||
//! start "busy" progress bar
|
||||
void canvasRefreshStarted();
|
||||
//! stop "busy" progress bar
|
||||
void canvasRefreshFinished();
|
||||
|
||||
/** Dialog for verification of action on many edits
|
||||
* @note added in 1.9 */
|
||||
bool verifyEditsActionDialog( const QString& act, const QString& upon );
|
||||
|
@ -47,11 +47,6 @@ bool QgsMapToolAddFeature::addFeature( QgsVectorLayer *vlayer, QgsFeature *f )
|
||||
|
||||
void QgsMapToolAddFeature::activate()
|
||||
{
|
||||
if ( !mCanvas || mCanvas->isDrawing() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() );
|
||||
if ( vlayer && vlayer->geometryType() == QGis::NoGeometry )
|
||||
{
|
||||
|
@ -635,6 +635,8 @@ void QgsMapCanvas::refreshMap()
|
||||
mJob->start();
|
||||
|
||||
mMapUpdateTimer.start();
|
||||
|
||||
emit renderStarting();
|
||||
}
|
||||
|
||||
|
||||
@ -695,6 +697,8 @@ void QgsMapCanvas::rendererJobFinished()
|
||||
// so the class is still valid when the execution returns to the class
|
||||
mJob->deleteLater();
|
||||
mJob = 0;
|
||||
|
||||
emit mapCanvasRefreshed();
|
||||
}
|
||||
|
||||
void QgsMapCanvas::mapUpdateTimeout()
|
||||
|
@ -443,15 +443,15 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
|
||||
//! - additional drawing shall be done directly within the renderer job or independently as a map canvas item
|
||||
void renderComplete( QPainter * );
|
||||
|
||||
// ### QGIS 3: renamte to mapRefreshFinished()
|
||||
/** Emitted when canvas finished a refresh request.
|
||||
\note Added in 2.0 */
|
||||
//! @deprecated since 2.4 - anything related to rendering progress is not visible outside of map canvas
|
||||
Q_DECL_DEPRECATED void mapCanvasRefreshed();
|
||||
void mapCanvasRefreshed();
|
||||
|
||||
// ### QGIS 3: rename to mapRefreshStarted()
|
||||
/** Emitted when the canvas is about to be rendered.
|
||||
\note Added in 1.5 */
|
||||
//! @deprecated since 2.4 - anything related to rendering progress is not visible outside of map canvas
|
||||
Q_DECL_DEPRECATED void renderStarting();
|
||||
void renderStarting();
|
||||
|
||||
//! Emitted when a new set of layers has been received
|
||||
void layersChanged();
|
||||
|
Loading…
x
Reference in New Issue
Block a user