Skip to content

Commit d619980

Browse files
committed
Ensure additional canvases respect settings
1 parent d452ae1 commit d619980

File tree

2 files changed

+33
-28
lines changed

2 files changed

+33
-28
lines changed

src/app/qgisapp.cpp

+28-28
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,10 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
787787
functionProfile( &QgisApp::createToolBars, this, QStringLiteral( "Toolbars" ) );
788788
functionProfile( &QgisApp::createStatusBar, this, QStringLiteral( "Status bar" ) );
789789
functionProfile( &QgisApp::createCanvasTools, this, QStringLiteral( "Create canvas tools" ) );
790+
790791
mMapCanvas->freeze();
792+
applyDefaultSettingsToCanvas( mMapCanvas );
793+
791794
functionProfile( &QgisApp::initLayerTreeView, this, QStringLiteral( "Init Layer tree view" ) );
792795
functionProfile( &QgisApp::createOverview, this, QStringLiteral( "Create overview" ) );
793796
functionProfile( &QgisApp::createMapTips, this, QStringLiteral( "Create map tips" ) );
@@ -1631,6 +1634,17 @@ void QgisApp::applyProjectSettingsToCanvas( QgsMapCanvas *canvas )
16311634
canvas->setSelectionColor( myColor );
16321635
}
16331636

1637+
void QgisApp::applyDefaultSettingsToCanvas( QgsMapCanvas *canvas )
1638+
{
1639+
QgsSettings settings;
1640+
canvas->enableAntiAliasing( settings.value( QStringLiteral( "qgis/enable_anti_aliasing" ), true ).toBool() );
1641+
double zoomFactor = settings.value( QStringLiteral( "qgis/zoom_factor" ), 2 ).toDouble();
1642+
canvas->setWheelFactor( zoomFactor );
1643+
canvas->setCachingEnabled( settings.value( QStringLiteral( "qgis/enable_render_caching" ), true ).toBool() );
1644+
canvas->setParallelRenderingEnabled( settings.value( QStringLiteral( "qgis/parallel_rendering" ), true ).toBool() );
1645+
canvas->setMapUpdateInterval( settings.value( QStringLiteral( "qgis/map_update_interval" ), 250 ).toInt() );
1646+
}
1647+
16341648
void QgisApp::readSettings()
16351649
{
16361650
QgsSettings settings;
@@ -3032,20 +3046,6 @@ void QgisApp::createOverview()
30323046
mPanelMenu->addAction( mOverviewDock->toggleViewAction() );
30333047

30343048
mLayerTreeCanvasBridge->setOvervewCanvas( mOverviewCanvas );
3035-
3036-
// moved here to set anti aliasing to both map canvas and overview
3037-
QgsSettings mySettings;
3038-
// Anti Aliasing enabled by default as of QGIS 1.7
3039-
mMapCanvas->enableAntiAliasing( mySettings.value( QStringLiteral( "qgis/enable_anti_aliasing" ), true ).toBool() );
3040-
3041-
double zoomFactor = mySettings.value( QStringLiteral( "qgis/zoom_factor" ), 2 ).toDouble();
3042-
mMapCanvas->setWheelFactor( zoomFactor );
3043-
3044-
mMapCanvas->setCachingEnabled( mySettings.value( QStringLiteral( "qgis/enable_render_caching" ), true ).toBool() );
3045-
3046-
mMapCanvas->setParallelRenderingEnabled( mySettings.value( QStringLiteral( "qgis/parallel_rendering" ), true ).toBool() );
3047-
3048-
mMapCanvas->setMapUpdateInterval( mySettings.value( QStringLiteral( "qgis/map_update_interval" ), 250 ).toInt() );
30493049
}
30503050

30513051
void QgisApp::addDockWidget( Qt::DockWidgetArea area, QDockWidget *thepDockWidget )
@@ -3124,17 +3124,23 @@ QgsMapCanvas *QgisApp::createNewMapCanvas( const QString &name )
31243124
mapCanvas->freeze( true );
31253125
mapCanvas->setObjectName( name );
31263126

3127+
applyProjectSettingsToCanvas( mapCanvas );
3128+
applyDefaultSettingsToCanvas( mapCanvas );
3129+
3130+
mapCanvas->setLayers( mMapCanvas->layers() );
3131+
mapCanvas->setExtent( mMapCanvas->extent() );
3132+
mapCanvas->setCachingEnabled( true );
3133+
3134+
mapCanvas->setDestinationCrs( QgsProject::instance()->crs() );
3135+
3136+
31273137
// add existing annotations to canvas
31283138
Q_FOREACH ( QgsAnnotation *annotation, QgsProject::instance()->annotationManager()->annotations() )
31293139
{
31303140
QgsMapCanvasAnnotationItem *canvasItem = new QgsMapCanvasAnnotationItem( annotation, mapCanvas );
31313141
Q_UNUSED( canvasItem ); //item is already added automatically to canvas scene
31323142
}
31333143

3134-
applyProjectSettingsToCanvas( mapCanvas );
3135-
3136-
mapCanvas->setDestinationCrs( QgsProject::instance()->crs() );
3137-
31383144
addDockWidget( Qt::RightDockWidgetArea, mapCanvasWidget );
31393145
mapCanvas->freeze( false );
31403146
return mapCanvas;
@@ -9177,16 +9183,10 @@ void QgisApp::showOptionsDialog( QWidget *parent, const QString &currentPage )
91779183

91789184
setupLayerTreeViewFromSettings();
91799185

9180-
mMapCanvas->enableAntiAliasing( mySettings.value( QStringLiteral( "qgis/enable_anti_aliasing" ) ).toBool() );
9181-
9182-
double zoomFactor = mySettings.value( QStringLiteral( "qgis/zoom_factor" ), 2 ).toDouble();
9183-
mMapCanvas->setWheelFactor( zoomFactor );
9184-
9185-
mMapCanvas->setCachingEnabled( mySettings.value( QStringLiteral( "qgis/enable_render_caching" ), true ).toBool() );
9186-
9187-
mMapCanvas->setParallelRenderingEnabled( mySettings.value( QStringLiteral( "qgis/parallel_rendering" ), true ).toBool() );
9188-
9189-
mMapCanvas->setMapUpdateInterval( mySettings.value( QStringLiteral( "qgis/map_update_interval" ), 250 ).toInt() );
9186+
Q_FOREACH ( QgsMapCanvas *canvas, mapCanvases() )
9187+
{
9188+
applyDefaultSettingsToCanvas( canvas );
9189+
}
91909190

91919191
if ( oldCapitalize != mySettings.value( QStringLiteral( "qgis/capitalizeLayerName" ), QVariant( false ) ).toBool() )
91929192
{

src/app/qgisapp.h

+5
Original file line numberDiff line numberDiff line change
@@ -1563,6 +1563,11 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
15631563
*/
15641564
void applyProjectSettingsToCanvas( QgsMapCanvas *canvas );
15651565

1566+
/**
1567+
* Applies global qgis settings to the specified canvas
1568+
*/
1569+
void applyDefaultSettingsToCanvas( QgsMapCanvas *canvas );
1570+
15661571
QgisAppStyleSheet *mStyleSheetBuilder = nullptr;
15671572

15681573
// actions for menus and toolbars -----------------

0 commit comments

Comments
 (0)