Skip to content
Permalink
Browse files

Get selection color from map canvas

  • Loading branch information
pblottiere authored and wonder-sk committed Aug 5, 2017
1 parent a4e3a77 commit 9478036da6a4e4e9909506d6f31d2276106d1b69
Showing with 16 additions and 6 deletions.
  1. +6 −0 python/gui/qgsmapcanvas.sip
  2. +1 −6 src/app/qgisapp.cpp
  3. +5 −0 src/gui/qgsmapcanvas.cpp
  4. +4 −0 src/gui/qgsmapcanvas.h
@@ -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
@@ -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() );

@@ -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();
@@ -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();

0 comments on commit 9478036

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