Skip to content

Commit

Permalink
Fix progress bar with report export
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 5, 2018
1 parent 8eb6aa9 commit 17292c1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
18 changes: 9 additions & 9 deletions src/app/layout/qgslayoutdesignerdialog.cpp
Expand Up @@ -2631,11 +2631,11 @@ void QgsLayoutDesignerDialog::exportReportToRaster()

QString error;
std::unique_ptr< QgsFeedback > feedback = qgis::make_unique< QgsFeedback >();
std::unique_ptr< QProgressDialog > progressDialog = qgis::make_unique< QProgressDialog >( tr( "Rendering report..." ), tr( "Abort" ), 0, 100, this );
std::unique_ptr< QProgressDialog > progressDialog = qgis::make_unique< QProgressDialog >( tr( "Rendering report..." ), tr( "Abort" ), 0, 0, this );
progressDialog->setWindowTitle( tr( "Exporting Report" ) );
connect( feedback.get(), &QgsFeedback::progressChanged, this, [ & ]( double progress )
connect( feedback.get(), &QgsFeedback::progressChanged, this, [ & ]( double )
{
progressDialog->setValue( progress );
//progressDialog->setValue( progress );
progressDialog->setLabelText( feedback->property( "progress" ).toString() ) ;

#ifdef Q_OS_LINUX
Expand Down Expand Up @@ -2746,11 +2746,11 @@ void QgsLayoutDesignerDialog::exportReportToSvg()

QString error;
std::unique_ptr< QgsFeedback > feedback = qgis::make_unique< QgsFeedback >();
std::unique_ptr< QProgressDialog > progressDialog = qgis::make_unique< QProgressDialog >( tr( "Rendering maps..." ), tr( "Abort" ), 0, 100, this );
std::unique_ptr< QProgressDialog > progressDialog = qgis::make_unique< QProgressDialog >( tr( "Rendering maps..." ), tr( "Abort" ), 0, 0, this );
progressDialog->setWindowTitle( tr( "Exporting Report" ) );
connect( feedback.get(), &QgsFeedback::progressChanged, this, [ & ]( double progress )
connect( feedback.get(), &QgsFeedback::progressChanged, this, [ & ]( double )
{
progressDialog->setValue( progress );
//progressDialog->setValue( progress );
progressDialog->setLabelText( feedback->property( "progress" ).toString() ) ;

#ifdef Q_OS_LINUX
Expand Down Expand Up @@ -2880,11 +2880,11 @@ void QgsLayoutDesignerDialog::exportReportToPdf()

QString error;
std::unique_ptr< QgsFeedback > feedback = qgis::make_unique< QgsFeedback >();
std::unique_ptr< QProgressDialog > progressDialog = qgis::make_unique< QProgressDialog >( tr( "Rendering maps..." ), tr( "Abort" ), 0, 100, this );
std::unique_ptr< QProgressDialog > progressDialog = qgis::make_unique< QProgressDialog >( tr( "Rendering maps..." ), tr( "Abort" ), 0, 0, this );
progressDialog->setWindowTitle( tr( "Exporting Report" ) );
connect( feedback.get(), &QgsFeedback::progressChanged, this, [ & ]( double progress )
connect( feedback.get(), &QgsFeedback::progressChanged, this, [ & ]( double )
{
progressDialog->setValue( progress );
//progressDialog->setValue( progress );
progressDialog->setLabelText( feedback->property( "progress" ).toString() ) ;

#ifdef Q_OS_LINUX
Expand Down
21 changes: 17 additions & 4 deletions src/core/layout/qgslayoutexporter.cpp
Expand Up @@ -410,7 +410,10 @@ QgsLayoutExporter::ExportResult QgsLayoutExporter::exportToImage( QgsAbstractLay
{
if ( feedback )
{
feedback->setProperty( "progress", QObject::tr( "Exporting %1 of %2" ).arg( i + 1 ).arg( total ) );
if ( total > 0 )
feedback->setProperty( "progress", QObject::tr( "Exporting %1 of %2" ).arg( i + 1 ).arg( total ) );
else
feedback->setProperty( "progress", QObject::tr( "Exporting section %1" ).arg( i + 1 ).arg( total ) );
feedback->setProgress( step * i );
}
if ( feedback && feedback->isCanceled() )
Expand Down Expand Up @@ -505,7 +508,10 @@ QgsLayoutExporter::ExportResult QgsLayoutExporter::exportToPdf( QgsAbstractLayou
{
if ( feedback )
{
feedback->setProperty( "progress", QObject::tr( "Exporting %1 of %2" ).arg( i + 1 ).arg( total ) );
if ( total > 0 )
feedback->setProperty( "progress", QObject::tr( "Exporting %1 of %2" ).arg( i + 1 ).arg( total ) );
else
feedback->setProperty( "progress", QObject::tr( "Exporting section %1" ).arg( i + 1 ).arg( total ) );
feedback->setProgress( step * i );
}
if ( feedback && feedback->isCanceled() )
Expand Down Expand Up @@ -579,7 +585,10 @@ QgsLayoutExporter::ExportResult QgsLayoutExporter::exportToPdfs( QgsAbstractLayo
{
if ( feedback )
{
feedback->setProperty( "progress", QObject::tr( "Exporting %1 of %2" ).arg( i + 1 ).arg( total ) );
if ( total > 0 )
feedback->setProperty( "progress", QObject::tr( "Exporting %1 of %2" ).arg( i + 1 ).arg( total ) );
else
feedback->setProperty( "progress", QObject::tr( "Exporting section %1" ).arg( i + 1 ).arg( total ) );
feedback->setProgress( step * i );
}
if ( feedback && feedback->isCanceled() )
Expand Down Expand Up @@ -792,7 +801,11 @@ QgsLayoutExporter::ExportResult QgsLayoutExporter::exportToSvg( QgsAbstractLayou
{
if ( feedback )
{
feedback->setProperty( "progress", QObject::tr( "Exporting %1 of %2" ).arg( i + 1 ).arg( total ) );
if ( total > 0 )
feedback->setProperty( "progress", QObject::tr( "Exporting %1 of %2" ).arg( i + 1 ).arg( total ) );
else
feedback->setProperty( "progress", QObject::tr( "Exporting section %1" ).arg( i + 1 ).arg( total ) );

feedback->setProgress( step * i );
}
if ( feedback && feedback->isCanceled() )
Expand Down

0 comments on commit 17292c1

Please sign in to comment.