Skip to content
Permalink
Browse files

Ensure all canvases are refreshed when project properties are applied

  • Loading branch information
nyalldawson committed Mar 13, 2017
1 parent d619980 commit 5c873f666df92bc12536b07b738ca6d1c5adfab5
Showing with 25 additions and 26 deletions.
  1. +1 −7 src/app/qgisapp.cpp
  2. +23 −14 src/app/qgsprojectproperties.cpp
  3. +0 −3 src/app/qgsprojectproperties.h
  4. +1 −2 src/gui/qgsmapcanvas.cpp
@@ -3129,7 +3129,6 @@ QgsMapCanvas *QgisApp::createNewMapCanvas( const QString &name )

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

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

@@ -10609,11 +10608,6 @@ void QgisApp::projectProperties()
&QgsStatusBarScaleWidget::updateScales );
QApplication::restoreOverrideCursor();

//pass any refresh signals off to canvases
// Line below was commented out by wonder three years ago (r4949).
// It is needed to refresh scale bar after changing display units.
connect( pp, SIGNAL( refresh() ), mMapCanvas, SLOT( refresh() ) );

// Display the modal dialog box.
pp->exec();

@@ -10626,7 +10620,7 @@ void QgisApp::projectProperties()

// delete the property sheet object
delete pp;
} // QgisApp::projectProperties
}


QgsClipboard *QgisApp::clipboard()
@@ -812,21 +812,25 @@ void QgsProjectProperties::apply()
}

//set the color for selections
QColor myColor = pbnSelectionColor->color();
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/SelectionColorRedPart" ), myColor.red() );
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/SelectionColorGreenPart" ), myColor.green() );
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/SelectionColorBluePart" ), myColor.blue() );
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/SelectionColorAlphaPart" ), myColor.alpha() );
mMapCanvas->setSelectionColor( myColor );
QColor selectionColor = pbnSelectionColor->color();
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/SelectionColorRedPart" ), selectionColor.red() );
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/SelectionColorGreenPart" ), selectionColor.green() );
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/SelectionColorBluePart" ), selectionColor.blue() );
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/SelectionColorAlphaPart" ), selectionColor.alpha() );


//set the color for canvas
myColor = pbnCanvasColor->color();
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/CanvasColorRedPart" ), myColor.red() );
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/CanvasColorGreenPart" ), myColor.green() );
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/CanvasColorBluePart" ), myColor.blue() );
mMapCanvas->setCanvasColor( myColor );
QgisApp::instance()->mapOverviewCanvas()->setBackgroundColor( myColor );
QgisApp::instance()->mapOverviewCanvas()->refresh();
QColor canvasColor = pbnCanvasColor->color();
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/CanvasColorRedPart" ), canvasColor.red() );
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/CanvasColorGreenPart" ), canvasColor.green() );
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/CanvasColorBluePart" ), canvasColor.blue() );

Q_FOREACH ( QgsMapCanvas *canvas, QgisApp::instance()->mapCanvases() )
{
canvas->setCanvasColor( canvasColor );
canvas->setSelectionColor( selectionColor );
}
QgisApp::instance()->mapOverviewCanvas()->setBackgroundColor( canvasColor );

//save project scales
QStringList myScales;
@@ -1140,7 +1144,12 @@ void QgsProjectProperties::apply()
//save variables
QgsProject::instance()->setCustomVariables( mVariableEditor->variablesInActiveScope() );

emit refresh();
//refresh canvases to reflect new properties, eg background color and scale bar after changing display units.
Q_FOREACH ( QgsMapCanvas *canvas, QgisApp::instance()->mapCanvases() )
{
canvas->refresh();
}
QgisApp::instance()->mapOverviewCanvas()->refresh();
}

void QgsProjectProperties::showProjectionsTab()
@@ -162,9 +162,6 @@ class APP_EXPORT QgsProjectProperties : public QgsOptionsDialogBase, private Ui:
//! Signal used to inform listeners that project scale list may have changed
void scalesChanged( const QStringList &scales = QStringList() );

//! let listening canvases know to refresh
void refresh();

private:

//! Formats for displaying coordinates
@@ -1544,7 +1544,6 @@ void QgsMapCanvas::unsetMapTool( QgsMapTool *tool )
}
}

//! Write property of QColor bgColor.
void QgsMapCanvas::setCanvasColor( const QColor &color )
{
// background of map's pixmap
@@ -1561,7 +1560,7 @@ void QgsMapCanvas::setCanvasColor( const QColor &color )

// background of QGraphicsScene
mScene->setBackgroundBrush( bgBrush );
} // setBackgroundColor
}

QColor QgsMapCanvas::canvasColor() const
{

0 comments on commit 5c873f6

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