Skip to content

Commit 5c873f6

Browse files
committed
Ensure all canvases are refreshed when project properties are applied
1 parent d619980 commit 5c873f6

File tree

4 files changed

+25
-26
lines changed

4 files changed

+25
-26
lines changed

src/app/qgisapp.cpp

+1-7
Original file line numberDiff line numberDiff line change
@@ -3129,7 +3129,6 @@ QgsMapCanvas *QgisApp::createNewMapCanvas( const QString &name )
31293129

31303130
mapCanvas->setLayers( mMapCanvas->layers() );
31313131
mapCanvas->setExtent( mMapCanvas->extent() );
3132-
mapCanvas->setCachingEnabled( true );
31333132

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

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

10612-
//pass any refresh signals off to canvases
10613-
// Line below was commented out by wonder three years ago (r4949).
10614-
// It is needed to refresh scale bar after changing display units.
10615-
connect( pp, SIGNAL( refresh() ), mMapCanvas, SLOT( refresh() ) );
10616-
1061710611
// Display the modal dialog box.
1061810612
pp->exec();
1061910613

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

1062710621
// delete the property sheet object
1062810622
delete pp;
10629-
} // QgisApp::projectProperties
10623+
}
1063010624

1063110625

1063210626
QgsClipboard *QgisApp::clipboard()

src/app/qgsprojectproperties.cpp

+23-14
Original file line numberDiff line numberDiff line change
@@ -812,21 +812,25 @@ void QgsProjectProperties::apply()
812812
}
813813

814814
//set the color for selections
815-
QColor myColor = pbnSelectionColor->color();
816-
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/SelectionColorRedPart" ), myColor.red() );
817-
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/SelectionColorGreenPart" ), myColor.green() );
818-
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/SelectionColorBluePart" ), myColor.blue() );
819-
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/SelectionColorAlphaPart" ), myColor.alpha() );
820-
mMapCanvas->setSelectionColor( myColor );
815+
QColor selectionColor = pbnSelectionColor->color();
816+
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/SelectionColorRedPart" ), selectionColor.red() );
817+
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/SelectionColorGreenPart" ), selectionColor.green() );
818+
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/SelectionColorBluePart" ), selectionColor.blue() );
819+
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/SelectionColorAlphaPart" ), selectionColor.alpha() );
820+
821821

822822
//set the color for canvas
823-
myColor = pbnCanvasColor->color();
824-
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/CanvasColorRedPart" ), myColor.red() );
825-
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/CanvasColorGreenPart" ), myColor.green() );
826-
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/CanvasColorBluePart" ), myColor.blue() );
827-
mMapCanvas->setCanvasColor( myColor );
828-
QgisApp::instance()->mapOverviewCanvas()->setBackgroundColor( myColor );
829-
QgisApp::instance()->mapOverviewCanvas()->refresh();
823+
QColor canvasColor = pbnCanvasColor->color();
824+
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/CanvasColorRedPart" ), canvasColor.red() );
825+
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/CanvasColorGreenPart" ), canvasColor.green() );
826+
QgsProject::instance()->writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/CanvasColorBluePart" ), canvasColor.blue() );
827+
828+
Q_FOREACH ( QgsMapCanvas *canvas, QgisApp::instance()->mapCanvases() )
829+
{
830+
canvas->setCanvasColor( canvasColor );
831+
canvas->setSelectionColor( selectionColor );
832+
}
833+
QgisApp::instance()->mapOverviewCanvas()->setBackgroundColor( canvasColor );
830834

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

1143-
emit refresh();
1147+
//refresh canvases to reflect new properties, eg background color and scale bar after changing display units.
1148+
Q_FOREACH ( QgsMapCanvas *canvas, QgisApp::instance()->mapCanvases() )
1149+
{
1150+
canvas->refresh();
1151+
}
1152+
QgisApp::instance()->mapOverviewCanvas()->refresh();
11441153
}
11451154

11461155
void QgsProjectProperties::showProjectionsTab()

src/app/qgsprojectproperties.h

-3
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,6 @@ class APP_EXPORT QgsProjectProperties : public QgsOptionsDialogBase, private Ui:
162162
//! Signal used to inform listeners that project scale list may have changed
163163
void scalesChanged( const QStringList &scales = QStringList() );
164164

165-
//! let listening canvases know to refresh
166-
void refresh();
167-
168165
private:
169166

170167
//! Formats for displaying coordinates

src/gui/qgsmapcanvas.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -1544,7 +1544,6 @@ void QgsMapCanvas::unsetMapTool( QgsMapTool *tool )
15441544
}
15451545
}
15461546

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

15621561
// background of QGraphicsScene
15631562
mScene->setBackgroundBrush( bgBrush );
1564-
} // setBackgroundColor
1563+
}
15651564

15661565
QColor QgsMapCanvas::canvasColor() const
15671566
{

0 commit comments

Comments
 (0)