63
63
#include " qgsreportorganizerwidget.h"
64
64
#include " qgsreadwritecontext.h"
65
65
#include " ui_qgssvgexportoptions.h"
66
+ #include " qgsproxyprogresstask.h"
66
67
#include " ui_defaults.h"
67
68
68
69
#include < QShortcut>
@@ -1760,12 +1761,19 @@ void QgsLayoutDesignerDialog::print()
1760
1761
QgsLayoutExporter::PrintExportSettings printSettings;
1761
1762
printSettings.rasterizeWholeImage = mLayout ->customProperty ( QStringLiteral ( " rasterize" ), false ).toBool ();
1762
1763
1764
+ QgsProxyProgressTask *proxyTask = new QgsProxyProgressTask ( tr ( " Printing “%1”" ).arg ( mMasterLayout ->name () ) );
1765
+ QgsApplication::taskManager ()->addTask ( proxyTask );
1766
+
1763
1767
// force a refresh, to e.g. update data defined properties, tables, etc
1764
1768
mLayout ->refresh ();
1765
1769
1766
1770
QgsLayoutExporter exporter ( mLayout );
1767
1771
QString printerName = printer ()->printerName ();
1768
- switch ( exporter.print ( *printer (), printSettings ) )
1772
+ QgsLayoutExporter::ExportResult result = exporter.print ( *printer (), printSettings );
1773
+
1774
+ proxyTask->finalize ( result == QgsLayoutExporter::Success );
1775
+
1776
+ switch ( result )
1769
1777
{
1770
1778
case QgsLayoutExporter::Success:
1771
1779
{
@@ -1864,14 +1872,20 @@ void QgsLayoutDesignerDialog::exportToRaster()
1864
1872
1865
1873
mView ->setPaintingEnabled ( false );
1866
1874
QgsTemporaryCursorOverride cursorOverride ( Qt::BusyCursor );
1875
+ QgsProxyProgressTask *proxyTask = new QgsProxyProgressTask ( tr ( " Exporting “%1”" ).arg ( mMasterLayout ->name () ) );
1876
+ QgsApplication::taskManager ()->addTask ( proxyTask );
1867
1877
1868
1878
// force a refresh, to e.g. update data defined properties, tables, etc
1869
1879
mLayout ->refresh ();
1870
1880
1871
1881
QgsLayoutExporter exporter ( mLayout );
1872
1882
1873
1883
QFileInfo fi ( fileNExt.first );
1874
- switch ( exporter.exportToImage ( fileNExt.first , settings ) )
1884
+ QgsLayoutExporter::ExportResult result = exporter.exportToImage ( fileNExt.first , settings );
1885
+
1886
+ proxyTask->finalize ( result == QgsLayoutExporter::Success );
1887
+
1888
+ switch ( result )
1875
1889
{
1876
1890
case QgsLayoutExporter::Success:
1877
1891
mMessageBar ->pushMessage ( tr ( " Export layout" ),
@@ -1963,6 +1977,8 @@ void QgsLayoutDesignerDialog::exportToPdf()
1963
1977
1964
1978
mView ->setPaintingEnabled ( false );
1965
1979
QgsTemporaryCursorOverride cursorOverride ( Qt::BusyCursor );
1980
+ QgsProxyProgressTask *proxyTask = new QgsProxyProgressTask ( tr ( " Exporting “%1”" ).arg ( mMasterLayout ->name () ) );
1981
+ QgsApplication::taskManager ()->addTask ( proxyTask );
1966
1982
1967
1983
QgsLayoutExporter::PdfExportSettings pdfSettings;
1968
1984
pdfSettings.rasterizeWholeImage = mLayout ->customProperty ( QStringLiteral ( " rasterize" ), false ).toBool ();
@@ -1972,7 +1988,11 @@ void QgsLayoutDesignerDialog::exportToPdf()
1972
1988
mLayout ->refresh ();
1973
1989
1974
1990
QgsLayoutExporter exporter ( mLayout );
1975
- switch ( exporter.exportToPdf ( outputFileName, pdfSettings ) )
1991
+ QgsLayoutExporter::ExportResult result = exporter.exportToPdf ( outputFileName, pdfSettings );
1992
+
1993
+ proxyTask->finalize ( result == QgsLayoutExporter::Success );
1994
+
1995
+ switch ( result )
1976
1996
{
1977
1997
case QgsLayoutExporter::Success:
1978
1998
{
@@ -2074,11 +2094,18 @@ void QgsLayoutDesignerDialog::exportToSvg()
2074
2094
mView ->setPaintingEnabled ( false );
2075
2095
QgsTemporaryCursorOverride cursorOverride ( Qt::BusyCursor );
2076
2096
2097
+ QgsProxyProgressTask *proxyTask = new QgsProxyProgressTask ( tr ( " Exporting “%1”" ).arg ( mMasterLayout ->name () ) );
2098
+ QgsApplication::taskManager ()->addTask ( proxyTask );
2099
+
2077
2100
// force a refresh, to e.g. update data defined properties, tables, etc
2078
2101
mLayout ->refresh ();
2079
2102
2080
2103
QgsLayoutExporter exporter ( mLayout );
2081
- switch ( exporter.exportToSvg ( outputFileName, svgSettings ) )
2104
+ QgsLayoutExporter::ExportResult result = exporter.exportToSvg ( outputFileName, svgSettings );
2105
+
2106
+ proxyTask->finalize ( result == QgsLayoutExporter::Success );
2107
+
2108
+ switch ( result )
2082
2109
{
2083
2110
case QgsLayoutExporter::Success:
2084
2111
{
@@ -2324,11 +2351,16 @@ void QgsLayoutDesignerDialog::printAtlas()
2324
2351
std::unique_ptr< QgsFeedback > feedback = qgis::make_unique< QgsFeedback >();
2325
2352
std::unique_ptr< QProgressDialog > progressDialog = qgis::make_unique< QProgressDialog >( tr ( " Printing maps…" ), tr ( " Abort" ), 0 , 100 , this );
2326
2353
progressDialog->setWindowTitle ( tr ( " Printing Atlas" ) );
2354
+
2355
+ QgsProxyProgressTask *proxyTask = new QgsProxyProgressTask ( tr ( " Printing “%1”" ).arg ( mMasterLayout ->name () ) );
2356
+
2327
2357
connect ( feedback.get (), &QgsFeedback::progressChanged, this , [ & ]( double progress )
2328
2358
{
2329
2359
progressDialog->setValue ( static_cast < int >( progress ) );
2330
2360
progressDialog->setLabelText ( feedback->property ( " progress" ).toString () ) ;
2331
2361
2362
+ proxyTask->setProxyProgress ( progress );
2363
+
2332
2364
#ifdef Q_OS_LINUX
2333
2365
// For some reason on Windows hasPendingEvents() always return true,
2334
2366
// but one iteration is actually enough on Windows to get good interactivity
@@ -2347,8 +2379,14 @@ void QgsLayoutDesignerDialog::printAtlas()
2347
2379
feedback->cancel ();
2348
2380
} );
2349
2381
2382
+ QgsApplication::taskManager ()->addTask ( proxyTask );
2383
+
2350
2384
QString printerName = printer ()->printerName ();
2351
- switch ( QgsLayoutExporter::print ( printAtlas, *printer (), printSettings, error, feedback.get () ) )
2385
+ QgsLayoutExporter::ExportResult result = QgsLayoutExporter::print ( printAtlas, *printer (), printSettings, error, feedback.get () );
2386
+
2387
+ proxyTask->finalize ( result == QgsLayoutExporter::Success );
2388
+
2389
+ switch ( result )
2352
2390
{
2353
2391
case QgsLayoutExporter::Success:
2354
2392
{
@@ -2494,11 +2532,16 @@ void QgsLayoutDesignerDialog::exportAtlasToRaster()
2494
2532
std::unique_ptr< QgsFeedback > feedback = qgis::make_unique< QgsFeedback >();
2495
2533
std::unique_ptr< QProgressDialog > progressDialog = qgis::make_unique< QProgressDialog >( tr ( " Rendering maps…" ), tr ( " Abort" ), 0 , 100 , this );
2496
2534
progressDialog->setWindowTitle ( tr ( " Exporting Atlas" ) );
2535
+
2536
+ QgsProxyProgressTask *proxyTask = new QgsProxyProgressTask ( tr ( " Exporting “%1”" ).arg ( mMasterLayout ->name () ) );
2537
+
2497
2538
connect ( feedback.get (), &QgsFeedback::progressChanged, this , [ & ]( double progress )
2498
2539
{
2499
2540
progressDialog->setValue ( static_cast < int >( progress ) );
2500
2541
progressDialog->setLabelText ( feedback->property ( " progress" ).toString () ) ;
2501
2542
2543
+ proxyTask->setProxyProgress ( progress );
2544
+
2502
2545
#ifdef Q_OS_LINUX
2503
2546
// For some reason on Windows hasPendingEvents() always return true,
2504
2547
// but one iteration is actually enough on Windows to get good interactivity
@@ -2517,8 +2560,13 @@ void QgsLayoutDesignerDialog::exportAtlasToRaster()
2517
2560
feedback->cancel ();
2518
2561
} );
2519
2562
2563
+ QgsApplication::taskManager ()->addTask ( proxyTask );
2564
+
2520
2565
QString fileName = QDir ( dir ).filePath ( QStringLiteral ( " atlas" ) ); // filename is overridden by atlas
2521
2566
QgsLayoutExporter::ExportResult result = QgsLayoutExporter::exportToImage ( printAtlas, fileName, fileExt, settings, error, feedback.get () );
2567
+
2568
+ proxyTask->finalize ( result == QgsLayoutExporter::Success );
2569
+
2522
2570
cursorOverride.release ();
2523
2571
2524
2572
switch ( result )
@@ -2644,11 +2692,16 @@ void QgsLayoutDesignerDialog::exportAtlasToSvg()
2644
2692
std::unique_ptr< QgsFeedback > feedback = qgis::make_unique< QgsFeedback >();
2645
2693
std::unique_ptr< QProgressDialog > progressDialog = qgis::make_unique< QProgressDialog >( tr ( " Rendering maps…" ), tr ( " Abort" ), 0 , 100 , this );
2646
2694
progressDialog->setWindowTitle ( tr ( " Exporting Atlas" ) );
2695
+
2696
+ QgsProxyProgressTask *proxyTask = new QgsProxyProgressTask ( tr ( " Exporting “%1”" ).arg ( mMasterLayout ->name () ) );
2697
+
2647
2698
connect ( feedback.get (), &QgsFeedback::progressChanged, this , [ & ]( double progress )
2648
2699
{
2649
2700
progressDialog->setValue ( static_cast < int >( progress ) );
2650
2701
progressDialog->setLabelText ( feedback->property ( " progress" ).toString () ) ;
2651
2702
2703
+ proxyTask->setProxyProgress ( progress );
2704
+
2652
2705
#ifdef Q_OS_LINUX
2653
2706
// For some reason on Windows hasPendingEvents() always return true,
2654
2707
// but one iteration is actually enough on Windows to get good interactivity
@@ -2667,9 +2720,13 @@ void QgsLayoutDesignerDialog::exportAtlasToSvg()
2667
2720
feedback->cancel ();
2668
2721
} );
2669
2722
2723
+ QgsApplication::taskManager ()->addTask ( proxyTask );
2724
+
2670
2725
QString filename = QDir ( dir ).filePath ( QStringLiteral ( " atlas" ) ); // filename is overridden by atlas
2671
2726
QgsLayoutExporter::ExportResult result = QgsLayoutExporter::exportToSvg ( printAtlas, filename, svgSettings, error, feedback.get () );
2672
2727
2728
+ proxyTask->finalize ( result == QgsLayoutExporter::Success );
2729
+
2673
2730
cursorOverride.release ();
2674
2731
switch ( result )
2675
2732
{
@@ -2848,12 +2905,17 @@ void QgsLayoutDesignerDialog::exportAtlasToPdf()
2848
2905
QString error;
2849
2906
std::unique_ptr< QgsFeedback > feedback = qgis::make_unique< QgsFeedback >();
2850
2907
std::unique_ptr< QProgressDialog > progressDialog = qgis::make_unique< QProgressDialog >( tr ( " Rendering maps…" ), tr ( " Abort" ), 0 , 100 , this );
2908
+
2909
+ QgsProxyProgressTask *proxyTask = new QgsProxyProgressTask ( tr ( " Exporting “%1”" ).arg ( mMasterLayout ->name () ) );
2910
+
2851
2911
progressDialog->setWindowTitle ( tr ( " Exporting Atlas" ) );
2852
2912
connect ( feedback.get (), &QgsFeedback::progressChanged, this , [ & ]( double progress )
2853
2913
{
2854
2914
progressDialog->setValue ( static_cast < int >( progress ) );
2855
2915
progressDialog->setLabelText ( feedback->property ( " progress" ).toString () ) ;
2856
2916
2917
+ proxyTask->setProxyProgress ( progress );
2918
+
2857
2919
#ifdef Q_OS_LINUX
2858
2920
// For some reason on Windows hasPendingEvents() always return true,
2859
2921
// but one iteration is actually enough on Windows to get good interactivity
@@ -2872,6 +2934,8 @@ void QgsLayoutDesignerDialog::exportAtlasToPdf()
2872
2934
feedback->cancel ();
2873
2935
} );
2874
2936
2937
+ QgsApplication::taskManager ()->addTask ( proxyTask );
2938
+
2875
2939
QgsLayoutExporter::ExportResult result = QgsLayoutExporter::Success;
2876
2940
if ( singleFile )
2877
2941
{
@@ -2882,6 +2946,8 @@ void QgsLayoutDesignerDialog::exportAtlasToPdf()
2882
2946
result = QgsLayoutExporter::exportToPdfs ( printAtlas, outputFileName, pdfSettings, error, feedback.get () );
2883
2947
}
2884
2948
2949
+ proxyTask->finalize ( result == QgsLayoutExporter::Success );
2950
+
2885
2951
cursorOverride.release ();
2886
2952
switch ( result )
2887
2953
{
@@ -2974,6 +3040,9 @@ void QgsLayoutDesignerDialog::exportReportToRaster()
2974
3040
std::unique_ptr< QgsFeedback > feedback = qgis::make_unique< QgsFeedback >();
2975
3041
std::unique_ptr< QProgressDialog > progressDialog = qgis::make_unique< QProgressDialog >( tr ( " Rendering report…" ), tr ( " Abort" ), 0 , 0 , this );
2976
3042
progressDialog->setWindowTitle ( tr ( " Exporting Report" ) );
3043
+
3044
+ QgsProxyProgressTask *proxyTask = new QgsProxyProgressTask ( tr ( " Exporting “%1”" ).arg ( mMasterLayout ->name () ) );
3045
+
2977
3046
connect ( feedback.get (), &QgsFeedback::progressChanged, this , [ & ]( double )
2978
3047
{
2979
3048
// progressDialog->setValue( progress );
@@ -2997,10 +3066,14 @@ void QgsLayoutDesignerDialog::exportReportToRaster()
2997
3066
feedback->cancel ();
2998
3067
} );
2999
3068
3069
+ QgsApplication::taskManager ()->addTask ( proxyTask );
3070
+
3000
3071
QFileInfo fi ( fileNExt.first );
3001
3072
QString dir = fi.path ();
3002
3073
QString fileName = dir + ' /' + fi.baseName ();
3003
3074
QgsLayoutExporter::ExportResult result = QgsLayoutExporter::exportToImage ( static_cast < QgsReport * >( mMasterLayout ), fileName, fileNExt.second , settings, error, feedback.get () );
3075
+
3076
+ proxyTask->finalize ( result == QgsLayoutExporter::Success );
3004
3077
cursorOverride.release ();
3005
3078
3006
3079
switch ( result )
@@ -3087,6 +3160,9 @@ void QgsLayoutDesignerDialog::exportReportToSvg()
3087
3160
std::unique_ptr< QgsFeedback > feedback = qgis::make_unique< QgsFeedback >();
3088
3161
std::unique_ptr< QProgressDialog > progressDialog = qgis::make_unique< QProgressDialog >( tr ( " Rendering maps…" ), tr ( " Abort" ), 0 , 0 , this );
3089
3162
progressDialog->setWindowTitle ( tr ( " Exporting Report" ) );
3163
+
3164
+ QgsProxyProgressTask *proxyTask = new QgsProxyProgressTask ( tr ( " Exporting “%1”" ).arg ( mMasterLayout ->name () ) );
3165
+
3090
3166
connect ( feedback.get (), &QgsFeedback::progressChanged, this , [ & ]( double )
3091
3167
{
3092
3168
// progressDialog->setValue( progress );
@@ -3110,11 +3186,14 @@ void QgsLayoutDesignerDialog::exportReportToSvg()
3110
3186
feedback->cancel ();
3111
3187
} );
3112
3188
3189
+ QgsApplication::taskManager ()->addTask ( proxyTask );
3190
+
3113
3191
QFileInfo fi ( outputFileName );
3114
3192
QString outFile = fi.path () + ' /' + fi.baseName ();
3115
3193
QString dir = fi.path ();
3116
3194
QgsLayoutExporter::ExportResult result = QgsLayoutExporter::exportToSvg ( static_cast < QgsReport * >( mMasterLayout ), outFile, svgSettings, error, feedback.get () );
3117
3195
3196
+ proxyTask->finalize ( result == QgsLayoutExporter::Success );
3118
3197
cursorOverride.release ();
3119
3198
switch ( result )
3120
3199
{
@@ -3218,6 +3297,9 @@ void QgsLayoutDesignerDialog::exportReportToPdf()
3218
3297
std::unique_ptr< QgsFeedback > feedback = qgis::make_unique< QgsFeedback >();
3219
3298
std::unique_ptr< QProgressDialog > progressDialog = qgis::make_unique< QProgressDialog >( tr ( " Rendering maps…" ), tr ( " Abort" ), 0 , 0 , this );
3220
3299
progressDialog->setWindowTitle ( tr ( " Exporting Report" ) );
3300
+
3301
+ QgsProxyProgressTask *proxyTask = new QgsProxyProgressTask ( tr ( " Exporting “%1”" ).arg ( mMasterLayout ->name () ) );
3302
+
3221
3303
connect ( feedback.get (), &QgsFeedback::progressChanged, this , [ & ]( double )
3222
3304
{
3223
3305
// progressDialog->setValue( progress );
@@ -3241,7 +3323,11 @@ void QgsLayoutDesignerDialog::exportReportToPdf()
3241
3323
feedback->cancel ();
3242
3324
} );
3243
3325
3326
+ QgsApplication::taskManager ()->addTask ( proxyTask );
3327
+
3244
3328
QgsLayoutExporter::ExportResult result = QgsLayoutExporter::exportToPdf ( static_cast < QgsReport * >( mMasterLayout ), outputFileName, pdfSettings, error, feedback.get () );
3329
+
3330
+ proxyTask->finalize ( result == QgsLayoutExporter::Success );
3245
3331
cursorOverride.release ();
3246
3332
3247
3333
switch ( result )
@@ -3314,6 +3400,9 @@ void QgsLayoutDesignerDialog::printReport()
3314
3400
std::unique_ptr< QgsFeedback > feedback = qgis::make_unique< QgsFeedback >();
3315
3401
std::unique_ptr< QProgressDialog > progressDialog = qgis::make_unique< QProgressDialog >( tr ( " Printing maps…" ), tr ( " Abort" ), 0 , 0 , this );
3316
3402
progressDialog->setWindowTitle ( tr ( " Printing Report" ) );
3403
+
3404
+ QgsProxyProgressTask *proxyTask = new QgsProxyProgressTask ( tr ( " Printing “%1”" ).arg ( mMasterLayout ->name () ) );
3405
+
3317
3406
connect ( feedback.get (), &QgsFeedback::progressChanged, this , [ & ]( double )
3318
3407
{
3319
3408
// progressDialog->setValue( progress );
@@ -3337,15 +3426,21 @@ void QgsLayoutDesignerDialog::printReport()
3337
3426
feedback->cancel ();
3338
3427
} );
3339
3428
3429
+ QgsApplication::taskManager ()->addTask ( proxyTask );
3430
+
3340
3431
QString printerName = printer ()->printerName ();
3341
- switch ( QgsLayoutExporter::print ( static_cast < QgsReport * >( mMasterLayout ), *printer (), printSettings, error, feedback.get () ) )
3432
+ QgsLayoutExporter::ExportResult result = QgsLayoutExporter::print ( static_cast < QgsReport * >( mMasterLayout ), *printer (), printSettings, error, feedback.get () );
3433
+
3434
+ proxyTask->finalize ( result == QgsLayoutExporter::Success );
3435
+
3436
+ switch ( result )
3342
3437
{
3343
3438
case QgsLayoutExporter::Success:
3344
3439
{
3345
3440
QString message;
3346
3441
if ( !printerName.isEmpty () )
3347
3442
{
3348
- message = tr ( " Successfully printed report to %1." ).arg ( printerName );
3443
+ message = tr ( " Successfully printed report to %1." ).arg ( printerName );
3349
3444
}
3350
3445
else
3351
3446
{
0 commit comments