Skip to content

Commit

Permalink
Ensure additional canvases respect settings
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Mar 13, 2017
1 parent d452ae1 commit d619980
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 28 deletions.
56 changes: 28 additions & 28 deletions src/app/qgisapp.cpp
Expand Up @@ -787,7 +787,10 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
functionProfile( &QgisApp::createToolBars, this, QStringLiteral( "Toolbars" ) );
functionProfile( &QgisApp::createStatusBar, this, QStringLiteral( "Status bar" ) );
functionProfile( &QgisApp::createCanvasTools, this, QStringLiteral( "Create canvas tools" ) );

mMapCanvas->freeze();
applyDefaultSettingsToCanvas( mMapCanvas );

functionProfile( &QgisApp::initLayerTreeView, this, QStringLiteral( "Init Layer tree view" ) );
functionProfile( &QgisApp::createOverview, this, QStringLiteral( "Create overview" ) );
functionProfile( &QgisApp::createMapTips, this, QStringLiteral( "Create map tips" ) );
Expand Down Expand Up @@ -1631,6 +1634,17 @@ void QgisApp::applyProjectSettingsToCanvas( QgsMapCanvas *canvas )
canvas->setSelectionColor( myColor );
}

void QgisApp::applyDefaultSettingsToCanvas( QgsMapCanvas *canvas )
{
QgsSettings settings;
canvas->enableAntiAliasing( settings.value( QStringLiteral( "qgis/enable_anti_aliasing" ), true ).toBool() );
double zoomFactor = settings.value( QStringLiteral( "qgis/zoom_factor" ), 2 ).toDouble();
canvas->setWheelFactor( zoomFactor );
canvas->setCachingEnabled( settings.value( QStringLiteral( "qgis/enable_render_caching" ), true ).toBool() );
canvas->setParallelRenderingEnabled( settings.value( QStringLiteral( "qgis/parallel_rendering" ), true ).toBool() );
canvas->setMapUpdateInterval( settings.value( QStringLiteral( "qgis/map_update_interval" ), 250 ).toInt() );
}

void QgisApp::readSettings()
{
QgsSettings settings;
Expand Down Expand Up @@ -3032,20 +3046,6 @@ void QgisApp::createOverview()
mPanelMenu->addAction( mOverviewDock->toggleViewAction() );

mLayerTreeCanvasBridge->setOvervewCanvas( mOverviewCanvas );

// moved here to set anti aliasing to both map canvas and overview
QgsSettings mySettings;
// Anti Aliasing enabled by default as of QGIS 1.7
mMapCanvas->enableAntiAliasing( mySettings.value( QStringLiteral( "qgis/enable_anti_aliasing" ), true ).toBool() );

double zoomFactor = mySettings.value( QStringLiteral( "qgis/zoom_factor" ), 2 ).toDouble();
mMapCanvas->setWheelFactor( zoomFactor );

mMapCanvas->setCachingEnabled( mySettings.value( QStringLiteral( "qgis/enable_render_caching" ), true ).toBool() );

mMapCanvas->setParallelRenderingEnabled( mySettings.value( QStringLiteral( "qgis/parallel_rendering" ), true ).toBool() );

mMapCanvas->setMapUpdateInterval( mySettings.value( QStringLiteral( "qgis/map_update_interval" ), 250 ).toInt() );
}

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

applyProjectSettingsToCanvas( mapCanvas );
applyDefaultSettingsToCanvas( mapCanvas );

mapCanvas->setLayers( mMapCanvas->layers() );
mapCanvas->setExtent( mMapCanvas->extent() );
mapCanvas->setCachingEnabled( true );

mapCanvas->setDestinationCrs( QgsProject::instance()->crs() );


// add existing annotations to canvas
Q_FOREACH ( QgsAnnotation *annotation, QgsProject::instance()->annotationManager()->annotations() )
{
QgsMapCanvasAnnotationItem *canvasItem = new QgsMapCanvasAnnotationItem( annotation, mapCanvas );
Q_UNUSED( canvasItem ); //item is already added automatically to canvas scene
}

applyProjectSettingsToCanvas( mapCanvas );

mapCanvas->setDestinationCrs( QgsProject::instance()->crs() );

addDockWidget( Qt::RightDockWidgetArea, mapCanvasWidget );
mapCanvas->freeze( false );
return mapCanvas;
Expand Down Expand Up @@ -9177,16 +9183,10 @@ void QgisApp::showOptionsDialog( QWidget *parent, const QString &currentPage )

setupLayerTreeViewFromSettings();

mMapCanvas->enableAntiAliasing( mySettings.value( QStringLiteral( "qgis/enable_anti_aliasing" ) ).toBool() );

double zoomFactor = mySettings.value( QStringLiteral( "qgis/zoom_factor" ), 2 ).toDouble();
mMapCanvas->setWheelFactor( zoomFactor );

mMapCanvas->setCachingEnabled( mySettings.value( QStringLiteral( "qgis/enable_render_caching" ), true ).toBool() );

mMapCanvas->setParallelRenderingEnabled( mySettings.value( QStringLiteral( "qgis/parallel_rendering" ), true ).toBool() );

mMapCanvas->setMapUpdateInterval( mySettings.value( QStringLiteral( "qgis/map_update_interval" ), 250 ).toInt() );
Q_FOREACH ( QgsMapCanvas *canvas, mapCanvases() )
{
applyDefaultSettingsToCanvas( canvas );
}

if ( oldCapitalize != mySettings.value( QStringLiteral( "qgis/capitalizeLayerName" ), QVariant( false ) ).toBool() )
{
Expand Down
5 changes: 5 additions & 0 deletions src/app/qgisapp.h
Expand Up @@ -1563,6 +1563,11 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
*/
void applyProjectSettingsToCanvas( QgsMapCanvas *canvas );

/**
* Applies global qgis settings to the specified canvas
*/
void applyDefaultSettingsToCanvas( QgsMapCanvas *canvas );

QgisAppStyleSheet *mStyleSheetBuilder = nullptr;

// actions for menus and toolbars -----------------
Expand Down

0 comments on commit d619980

Please sign in to comment.