Skip to content

Commit

Permalink
Get selection color from map canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere authored and wonder-sk committed Sep 15, 2017
1 parent a4e3a77 commit 9478036
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
6 changes: 6 additions & 0 deletions python/gui/qgsmapcanvas.sip
Expand Up @@ -269,6 +269,12 @@ Read property of QColor bgColor.
.. versionadded:: 2.4
%End

QColor selectionColor() const;
%Docstring
.. versionadded:: 3.0
:rtype: QColor
%End

void updateScale();
%Docstring
Emits signal scaleChanged to update scale in main window
Expand Down
7 changes: 1 addition & 6 deletions src/app/qgisapp.cpp
Expand Up @@ -9907,16 +9907,11 @@ void QgisApp::new3DMapCanvas()
QgsProject *prj = QgsProject::instance();
QgsRectangle fullExtent = mMapCanvas->fullExtent();

int r = prj->readNumEntry( QStringLiteral( "Gui" ), QStringLiteral( "/SelectionColorRedPart" ), 255 );
int g = prj->readNumEntry( QStringLiteral( "Gui" ), QStringLiteral( "/SelectionColorGreenPart" ), 255 );
int b = prj->readNumEntry( QStringLiteral( "Gui" ), QStringLiteral( "/SelectionColorBluePart" ), 255 );
int a = prj->readNumEntry( QStringLiteral( "Gui" ), QStringLiteral( "/SelectionColorAlphaPart" ), 255 );

Map3D *map = new Map3D;
map->crs = prj->crs();
map->originX = fullExtent.center().x();
map->originY = fullExtent.center().y();
map->setSelectionColor( QColor( r, g, b, a ) );
map->setSelectionColor( mMapCanvas->selectionColor() );
map->setBackgroundColor( mMapCanvas->canvasColor() );
map->setLayers( mMapCanvas->layers() );

Expand Down
5 changes: 5 additions & 0 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -1595,6 +1595,11 @@ void QgsMapCanvas::setSelectionColor( const QColor &color )
mSettings.setSelectionColor( color );
}

QColor QgsMapCanvas::selectionColor() const
{
return mSettings.selectionColor();
}

int QgsMapCanvas::layerCount() const
{
return mapSettings().layers().size();
Expand Down
4 changes: 4 additions & 0 deletions src/gui/qgsmapcanvas.h
Expand Up @@ -259,6 +259,10 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
//! \since QGIS 2.4
void setSelectionColor( const QColor &color );

//! Returns color for selected features
//! \since QGIS 3.0
QColor selectionColor() const;

//! Emits signal scaleChanged to update scale in main window
void updateScale();

Expand Down

0 comments on commit 9478036

Please sign in to comment.