Skip to content
Permalink
Browse files

Make the rubber band color configurable

  • Loading branch information
sbrunner authored and m-kuhn committed Dec 15, 2015
1 parent 02fcaca commit dad7aa70f62bf35bddb05792ed42cd6384cfe876
Showing with 91 additions and 17 deletions.
  1. +12 −1 src/app/nodetool/qgsmaptoolnodetool.cpp
  2. +15 −0 src/app/qgsoptions.cpp
  3. +13 −3 src/gui/qgsmaptooledit.cpp
  4. +51 −13 src/ui/qgsoptionsbase.ui
@@ -360,7 +360,16 @@ void QgsMapToolNodeTool::updateSelectFeature()

mSelectRubberBand = new QgsGeometryRubberBand( mCanvas, mSelectedFeature->geometry()->type() );
mSelectRubberBand->setBrushStyle( Qt::SolidPattern );
mSelectRubberBand->setFillColor( QColor( 255, 0, 0, 50 ) );

QSettings settings;
QColor color(
settings.value( "/qgis/digitizing/select_color_red", 255 ).toInt(),
settings.value( "/qgis/digitizing/select_color_green", 0 ).toInt(),
settings.value( "/qgis/digitizing/select_color_blue", 0 ).toInt() );
double myAlpha = settings.value( "/qgis/digitizing/select_color_alpha", 30 ).toInt() / 255.0 ;
color.setAlphaF( myAlpha );
mSelectRubberBand->setFillColor( color );

QgsAbstractGeometryV2* rbGeom = mSelectedFeature->geometry()->geometry()->clone();
QgsVectorLayer *vlayer = mSelectedFeature->vlayer();
if ( mCanvas->mapSettings().layerTransform( vlayer ) )
@@ -489,6 +498,8 @@ void QgsMapToolNodeTool::canvasReleaseEvent( QgsMapMouseEvent* e )

mDeselectOnRelease = -1;
}

updateSelectFeature();
}

void QgsMapToolNodeTool::deactivate()
@@ -794,6 +794,15 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) :
mLineColorToolButton->setContext( "gui" );
mLineColorToolButton->setDefaultColor( QColor( 255, 0, 0, 200 ) );

myRed = settings.value( "/qgis/digitizing/fill_color_red", 255 ).toInt();
myGreen = settings.value( "/qgis/digitizing/fill_color_green", 0 ).toInt();
myBlue = settings.value( "/qgis/digitizing/fill_color_blue", 0 ).toInt();
myAlpha = settings.value( "/qgis/digitizing/fill_color_alpha", 30 ).toInt();
mFillColorToolButton->setColor( QColor( myRed, myGreen, myBlue, myAlpha ) );
mFillColorToolButton->setAllowAlpha( true );
mFillColorToolButton->setContext( "gui" );
mFillColorToolButton->setDefaultColor( QColor( 255, 0, 0, 30 ) );

//default snap mode
mDefaultSnapModeComboBox->insertItem( 0, tr( "To vertex" ), "to vertex" );
mDefaultSnapModeComboBox->insertItem( 1, tr( "To segment" ), "to segment" );
@@ -1288,6 +1297,12 @@ void QgsOptions::saveOptions()
settings.setValue( "/qgis/digitizing/line_color_blue", digitizingColor.blue() );
settings.setValue( "/qgis/digitizing/line_color_alpha", digitizingColor.alpha() );

digitizingColor = mFillColorToolButton->color();
settings.setValue( "/qgis/digitizing/fill_color_red", digitizingColor.red() );
settings.setValue( "/qgis/digitizing/fill_color_green", digitizingColor.green() );
settings.setValue( "/qgis/digitizing/fill_color_blue", digitizingColor.blue() );
settings.setValue( "/qgis/digitizing/fill_color_alpha", digitizingColor.alpha() );

//default snap mode
QString defaultSnapModeString = mDefaultSnapModeComboBox->itemData( mDefaultSnapModeComboBox->currentIndex() ).toString();
settings.setValue( "/qgis/digitizing/default_snap_mode", defaultSnapModeString );
@@ -39,9 +39,10 @@ QgsRubberBand* QgsMapToolEdit::createRubberBand( QGis::GeometryType geometryType
QSettings settings;
QgsRubberBand* rb = new QgsRubberBand( mCanvas, geometryType );
rb->setWidth( settings.value( "/qgis/digitizing/line_width", 1 ).toInt() );
QColor color( settings.value( "/qgis/digitizing/line_color_red", 255 ).toInt(),
settings.value( "/qgis/digitizing/line_color_green", 0 ).toInt(),
settings.value( "/qgis/digitizing/line_color_blue", 0 ).toInt() );
QColor color(
settings.value( "/qgis/digitizing/line_color_red", 255 ).toInt(),
settings.value( "/qgis/digitizing/line_color_green", 0 ).toInt(),
settings.value( "/qgis/digitizing/line_color_blue", 0 ).toInt() );
double myAlpha = settings.value( "/qgis/digitizing/line_color_alpha", 200 ).toInt() / 255.0;
if ( alternativeBand )
{
@@ -54,6 +55,15 @@ QgsRubberBand* QgsMapToolEdit::createRubberBand( QGis::GeometryType geometryType
}
color.setAlphaF( myAlpha );
rb->setColor( color );

QColor fillColor(
settings.value( "/qgis/digitizing/fill_color_red", 255 ).toInt(),
settings.value( "/qgis/digitizing/fill_color_green", 0 ).toInt(),
settings.value( "/qgis/digitizing/fill_color_blue", 0 ).toInt() );
myAlpha = settings.value( "/qgis/digitizing/fill_color_alpha", 30 ).toInt() / 255.0 ;
fillColor.setAlphaF( myAlpha );
rb->setFillColor( fillColor );

rb->show();
return rb;
}
@@ -3558,6 +3558,32 @@
<string>Rubberband</string>
</property>
<layout class="QGridLayout" name="_9">
<item row="0" column="9">
<spacer name="horizontalSpacer_33">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="mLineWidthTextLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Line width</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="mLineColorTextLabel">
<property name="sizePolicy">
@@ -3581,31 +3607,43 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="mLineWidthTextLabel">
<item row="0" column="5">
<widget class="QgsColorButtonV2" name="mFillColorToolButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Line width</string>
<string/>
</property>
</widget>
</item>
<item row="0" column="4">
<spacer name="horizontalSpacer_33">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<widget class="QLabel" name="mSelectColorTextLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
<property name="text">
<string>Fill color</string>
</property>
</spacer>
</widget>
</item>
<item row="0" column="3">
<widget class="QgsColorButtonV2" name="mLineColorToolButton">

0 comments on commit dad7aa7

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