Skip to content

Commit 4d7cb24

Browse files
committedNov 19, 2015
Fix overview canvas background color not set (fix #11157)
(cherry-picked from f60ca59)
1 parent c576281 commit 4d7cb24

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,7 @@ QgisApp::QgisApp()
864864
, mToolPopupOverviews( 0 )
865865
, mToolPopupDisplay( 0 )
866866
, mMapCanvas( 0 )
867+
, mOverviewCanvas( 0 )
867868
, mLayerTreeView( 0 )
868869
, mLayerTreeCanvasBridge( 0 )
869870
, mMapLayerOrder( 0 )
@@ -2282,25 +2283,33 @@ void QgisApp::createCanvasTools()
22822283
void QgisApp::createOverview()
22832284
{
22842285
// overview canvas
2285-
QgsMapOverviewCanvas* overviewCanvas = new QgsMapOverviewCanvas( NULL, mMapCanvas );
2286-
overviewCanvas->setWhatsThis( tr( "Map overview canvas. This canvas can be used to display a locator map that shows the current extent of the map canvas. The current extent is shown as a red rectangle. Any layer on the map can be added to the overview canvas." ) );
2286+
mOverviewCanvas = new QgsMapOverviewCanvas( NULL, mMapCanvas );
2287+
2288+
//set canvas color to default
2289+
QSettings settings;
2290+
int red = settings.value( "/qgis/default_canvas_color_red", 255 ).toInt();
2291+
int green = settings.value( "/qgis/default_canvas_color_green", 255 ).toInt();
2292+
int blue = settings.value( "/qgis/default_canvas_color_blue", 255 ).toInt();
2293+
mOverviewCanvas->setBackgroundColor( QColor( red, green, blue ) );
2294+
2295+
mOverviewCanvas->setWhatsThis( tr( "Map overview canvas. This canvas can be used to display a locator map that shows the current extent of the map canvas. The current extent is shown as a red rectangle. Any layer on the map can be added to the overview canvas." ) );
22872296

22882297
QBitmap overviewPanBmp = QBitmap::fromData( QSize( 16, 16 ), pan_bits );
22892298
QBitmap overviewPanBmpMask = QBitmap::fromData( QSize( 16, 16 ), pan_mask_bits );
22902299
mOverviewMapCursor = new QCursor( overviewPanBmp, overviewPanBmpMask, 0, 0 ); //set upper left corner as hot spot - this is better when extent marker is small; hand won't cover the marker
2291-
overviewCanvas->setCursor( *mOverviewMapCursor );
2300+
mOverviewCanvas->setCursor( *mOverviewMapCursor );
22922301
// QVBoxLayout *myOverviewLayout = new QVBoxLayout;
22932302
// myOverviewLayout->addWidget(overviewCanvas);
22942303
// overviewFrame->setLayout(myOverviewLayout);
22952304
mOverviewDock = new QDockWidget( tr( "Overview" ), this );
22962305
mOverviewDock->setObjectName( "Overview" );
22972306
mOverviewDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
2298-
mOverviewDock->setWidget( overviewCanvas );
2307+
mOverviewDock->setWidget( mOverviewCanvas );
22992308
addDockWidget( Qt::LeftDockWidgetArea, mOverviewDock );
23002309
// add to the Panel submenu
23012310
mPanelMenu->addAction( mOverviewDock->toggleViewAction() );
23022311

2303-
mMapCanvas->enableOverviewMode( overviewCanvas );
2312+
mMapCanvas->enableOverviewMode( mOverviewCanvas );
23042313

23052314
// moved here to set anti aliasing to both map canvas and overview
23062315
QSettings mySettings;
@@ -3631,6 +3640,7 @@ void QgisApp::fileNew( bool thePromptToSaveFlag, bool forceBlank )
36313640
prj->writeEntry( "Gui", "/CanvasColorGreenPart", myGreen );
36323641
prj->writeEntry( "Gui", "/CanvasColorBluePart", myBlue );
36333642
mMapCanvas->setCanvasColor( QColor( myRed, myGreen, myBlue ) );
3643+
mOverviewCanvas->setBackgroundColor( QColor( myRed, myGreen, myBlue ) );
36343644

36353645
prj->dirty( false );
36363646

@@ -4008,6 +4018,8 @@ bool QgisApp::addProject( QString projectFile )
40084018
int myBlueInt = QgsProject::instance()->readNumEntry( "Gui", "/CanvasColorBluePart", 255 );
40094019
QColor myColor = QColor( myRedInt, myGreenInt, myBlueInt );
40104020
mMapCanvas->setCanvasColor( myColor ); //this is fill color before rendering starts
4021+
mOverviewCanvas->setBackgroundColor( myColor );
4022+
40114023
QgsDebugMsg( "Canvas background color restored..." );
40124024
myRedInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorRedPart", 255 );
40134025
myGreenInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorGreenPart", 255 );

‎src/app/qgisapp.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class QgsMapLayer;
5555
class QgsMapTip;
5656
class QgsMapTool;
5757
class QgsMapToolAdvancedDigitizing;
58+
class QgsMapOverviewCanvas;
5859
class QgsPoint;
5960
class QgsProviderRegistry;
6061
class QgsPythonUtils;
@@ -432,6 +433,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
432433
//! return CAD dock widget
433434
QgsAdvancedDigitizingDockWidget *cadDockWidget() { return mAdvancedDigitizingDockWidget; }
434435

436+
//! Returns map overview canvas
437+
QgsMapOverviewCanvas* mapOverviewCanvas() { return mOverviewCanvas; }
438+
435439
//! show layer properties
436440
void showLayerProperties( QgsMapLayer *ml );
437441

@@ -1534,6 +1538,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
15341538
QMenu *mToolPopupDisplay;
15351539
//! Map canvas
15361540
QgsMapCanvas *mMapCanvas;
1541+
//! Overview map canvas
1542+
QgsMapOverviewCanvas *mOverviewCanvas;
15371543
//! Table of contents (legend) for the map
15381544
QgsLayerTreeView *mLayerTreeView;
15391545
//! Helper class that connects layer tree with map canvas

‎src/app/qgsprojectproperties.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include "qgscolorschemeregistry.h"
5050
#include "qgssymbollayerv2utils.h"
5151
#include "qgscolordialog.h"
52+
#include "qgsmapoverviewcanvas.h"
5253

5354
//qt includes
5455
#include <QInputDialog>
@@ -678,6 +679,8 @@ void QgsProjectProperties::apply()
678679
QgsProject::instance()->writeEntry( "Gui", "/CanvasColorGreenPart", myColor.green() );
679680
QgsProject::instance()->writeEntry( "Gui", "/CanvasColorBluePart", myColor.blue() );
680681
mMapCanvas->setCanvasColor( myColor );
682+
QgisApp::instance()->mapOverviewCanvas()->setBackgroundColor( myColor );
683+
QgisApp::instance()->mapOverviewCanvas()->refresh();
681684

682685
//save project scales
683686
QStringList myScales;

‎src/gui/qgsmapoverviewcanvas.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ QgsMapOverviewCanvas::QgsMapOverviewCanvas( QWidget * parent, QgsMapCanvas* mapC
7474
, mMapCanvas( mapCanvas )
7575
, mJob( 0 )
7676
{
77+
setAutoFillBackground( true );
7778
setObjectName( "theOverviewCanvas" );
7879
mPanningWidget = new QgsPanningWidget( this );
7980

0 commit comments

Comments
 (0)
Please sign in to comment.