Skip to content
Permalink
Browse files

Progress task on project load

  • Loading branch information
nyalldawson committed Aug 7, 2018
1 parent 37f3be6 commit 5d078ec22267a50aacd6a4bfc209a52bb8ec13b4
Showing with 20 additions and 2 deletions.
  1. +17 −1 src/app/qgisapp.cpp
  2. +3 −1 src/app/qgisapp.h
@@ -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"
@@ -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,
@@ -133,7 +133,7 @@ class QgsDataSourceManagerDialog;
class QgsBrowserModel;
class QgsGeoCmsProviderRegistry;
class QgsLayoutQptDropHandler;

class QgsProxyProgressTask;

#include <QMainWindow>
#include <QToolBar>
@@ -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;
};

0 comments on commit 5d078ec

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