Skip to content

Commit

Permalink
Progress task on project load
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 15, 2018
1 parent 37f3be6 commit 5d078ec
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
18 changes: 17 additions & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -257,6 +257,7 @@ Q_GUI_EXPORT extern int qt_defaultDpiX();
#include "qgsprojectstorageregistry.h"
#include "qgsproviderregistry.h"
#include "qgspythonrunner.h"
#include "qgsproxyprogresstask.h"
#include "qgsquerybuilder.h"
#include "qgsrastercalcdialog.h"
#include "qgsrasterfilewriter.h"
Expand Down Expand Up @@ -3378,7 +3379,22 @@ void QgisApp::setupConnections()
connect( QgsProject::instance(), &QgsProject::oldProjectVersionWarning,
this, &QgisApp::oldProjectVersionWarning );
connect( QgsProject::instance(), &QgsProject::layerLoaded,
this, &QgisApp::showProgress );
this, [this]( int i, int n )
{
if ( !mProjectLoadingProxyTask )
{
const QString name = QgsProject::instance()->title().isEmpty() ? QgsProject::instance()->fileName() : QgsProject::instance()->title();
mProjectLoadingProxyTask = new QgsProxyProgressTask( tr( "Loading “%1”" ).arg( name ) );
QgsApplication::taskManager()->addTask( mProjectLoadingProxyTask );
}

mProjectLoadingProxyTask->setProxyProgress( 100.0 * static_cast< double >( i ) / n );
if ( i == n )
{
mProjectLoadingProxyTask->finalize( true );
mProjectLoadingProxyTask = nullptr;
}
} );
connect( QgsProject::instance(), &QgsProject::loadingLayer,
this, &QgisApp::showStatusMessage );
connect( QgsProject::instance(), &QgsProject::loadingLayerMessageReceived,
Expand Down
4 changes: 3 additions & 1 deletion src/app/qgisapp.h
Expand Up @@ -133,7 +133,7 @@ class QgsDataSourceManagerDialog;
class QgsBrowserModel;
class QgsGeoCmsProviderRegistry;
class QgsLayoutQptDropHandler;

class QgsProxyProgressTask;

#include <QMainWindow>
#include <QToolBar>
Expand Down Expand Up @@ -2283,6 +2283,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
QMap< QString, QString > mProjectPropertiesPagesMap;
QMap< QString, QString > mSettingPagesMap;

QgsProxyProgressTask *mProjectLoadingProxyTask = nullptr;

friend class TestQgisAppPython;
};

Expand Down

0 comments on commit 5d078ec

Please sign in to comment.