Skip to content

Commit dad7aa7

Browse files
sbrunnerm-kuhn
authored andcommittedDec 15, 2015
Make the rubber band color configurable
1 parent 02fcaca commit dad7aa7

File tree

4 files changed

+91
-17
lines changed

4 files changed

+91
-17
lines changed
 

‎src/app/nodetool/qgsmaptoolnodetool.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,16 @@ void QgsMapToolNodeTool::updateSelectFeature()
360360

361361
mSelectRubberBand = new QgsGeometryRubberBand( mCanvas, mSelectedFeature->geometry()->type() );
362362
mSelectRubberBand->setBrushStyle( Qt::SolidPattern );
363-
mSelectRubberBand->setFillColor( QColor( 255, 0, 0, 50 ) );
363+
364+
QSettings settings;
365+
QColor color(
366+
settings.value( "/qgis/digitizing/select_color_red", 255 ).toInt(),
367+
settings.value( "/qgis/digitizing/select_color_green", 0 ).toInt(),
368+
settings.value( "/qgis/digitizing/select_color_blue", 0 ).toInt() );
369+
double myAlpha = settings.value( "/qgis/digitizing/select_color_alpha", 30 ).toInt() / 255.0 ;
370+
color.setAlphaF( myAlpha );
371+
mSelectRubberBand->setFillColor( color );
372+
364373
QgsAbstractGeometryV2* rbGeom = mSelectedFeature->geometry()->geometry()->clone();
365374
QgsVectorLayer *vlayer = mSelectedFeature->vlayer();
366375
if ( mCanvas->mapSettings().layerTransform( vlayer ) )
@@ -489,6 +498,8 @@ void QgsMapToolNodeTool::canvasReleaseEvent( QgsMapMouseEvent* e )
489498

490499
mDeselectOnRelease = -1;
491500
}
501+
502+
updateSelectFeature();
492503
}
493504

494505
void QgsMapToolNodeTool::deactivate()

‎src/app/qgsoptions.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,15 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) :
794794
mLineColorToolButton->setContext( "gui" );
795795
mLineColorToolButton->setDefaultColor( QColor( 255, 0, 0, 200 ) );
796796

797+
myRed = settings.value( "/qgis/digitizing/fill_color_red", 255 ).toInt();
798+
myGreen = settings.value( "/qgis/digitizing/fill_color_green", 0 ).toInt();
799+
myBlue = settings.value( "/qgis/digitizing/fill_color_blue", 0 ).toInt();
800+
myAlpha = settings.value( "/qgis/digitizing/fill_color_alpha", 30 ).toInt();
801+
mFillColorToolButton->setColor( QColor( myRed, myGreen, myBlue, myAlpha ) );
802+
mFillColorToolButton->setAllowAlpha( true );
803+
mFillColorToolButton->setContext( "gui" );
804+
mFillColorToolButton->setDefaultColor( QColor( 255, 0, 0, 30 ) );
805+
797806
//default snap mode
798807
mDefaultSnapModeComboBox->insertItem( 0, tr( "To vertex" ), "to vertex" );
799808
mDefaultSnapModeComboBox->insertItem( 1, tr( "To segment" ), "to segment" );
@@ -1288,6 +1297,12 @@ void QgsOptions::saveOptions()
12881297
settings.setValue( "/qgis/digitizing/line_color_blue", digitizingColor.blue() );
12891298
settings.setValue( "/qgis/digitizing/line_color_alpha", digitizingColor.alpha() );
12901299

1300+
digitizingColor = mFillColorToolButton->color();
1301+
settings.setValue( "/qgis/digitizing/fill_color_red", digitizingColor.red() );
1302+
settings.setValue( "/qgis/digitizing/fill_color_green", digitizingColor.green() );
1303+
settings.setValue( "/qgis/digitizing/fill_color_blue", digitizingColor.blue() );
1304+
settings.setValue( "/qgis/digitizing/fill_color_alpha", digitizingColor.alpha() );
1305+
12911306
//default snap mode
12921307
QString defaultSnapModeString = mDefaultSnapModeComboBox->itemData( mDefaultSnapModeComboBox->currentIndex() ).toString();
12931308
settings.setValue( "/qgis/digitizing/default_snap_mode", defaultSnapModeString );

‎src/gui/qgsmaptooledit.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ QgsRubberBand* QgsMapToolEdit::createRubberBand( QGis::GeometryType geometryType
3939
QSettings settings;
4040
QgsRubberBand* rb = new QgsRubberBand( mCanvas, geometryType );
4141
rb->setWidth( settings.value( "/qgis/digitizing/line_width", 1 ).toInt() );
42-
QColor color( settings.value( "/qgis/digitizing/line_color_red", 255 ).toInt(),
43-
settings.value( "/qgis/digitizing/line_color_green", 0 ).toInt(),
44-
settings.value( "/qgis/digitizing/line_color_blue", 0 ).toInt() );
42+
QColor color(
43+
settings.value( "/qgis/digitizing/line_color_red", 255 ).toInt(),
44+
settings.value( "/qgis/digitizing/line_color_green", 0 ).toInt(),
45+
settings.value( "/qgis/digitizing/line_color_blue", 0 ).toInt() );
4546
double myAlpha = settings.value( "/qgis/digitizing/line_color_alpha", 200 ).toInt() / 255.0;
4647
if ( alternativeBand )
4748
{
@@ -54,6 +55,15 @@ QgsRubberBand* QgsMapToolEdit::createRubberBand( QGis::GeometryType geometryType
5455
}
5556
color.setAlphaF( myAlpha );
5657
rb->setColor( color );
58+
59+
QColor fillColor(
60+
settings.value( "/qgis/digitizing/fill_color_red", 255 ).toInt(),
61+
settings.value( "/qgis/digitizing/fill_color_green", 0 ).toInt(),
62+
settings.value( "/qgis/digitizing/fill_color_blue", 0 ).toInt() );
63+
myAlpha = settings.value( "/qgis/digitizing/fill_color_alpha", 30 ).toInt() / 255.0 ;
64+
fillColor.setAlphaF( myAlpha );
65+
rb->setFillColor( fillColor );
66+
5767
rb->show();
5868
return rb;
5969
}

‎src/ui/qgsoptionsbase.ui

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3558,6 +3558,32 @@
35583558
<string>Rubberband</string>
35593559
</property>
35603560
<layout class="QGridLayout" name="_9">
3561+
<item row="0" column="9">
3562+
<spacer name="horizontalSpacer_33">
3563+
<property name="orientation">
3564+
<enum>Qt::Horizontal</enum>
3565+
</property>
3566+
<property name="sizeHint" stdset="0">
3567+
<size>
3568+
<width>40</width>
3569+
<height>20</height>
3570+
</size>
3571+
</property>
3572+
</spacer>
3573+
</item>
3574+
<item row="0" column="0">
3575+
<widget class="QLabel" name="mLineWidthTextLabel">
3576+
<property name="sizePolicy">
3577+
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
3578+
<horstretch>0</horstretch>
3579+
<verstretch>0</verstretch>
3580+
</sizepolicy>
3581+
</property>
3582+
<property name="text">
3583+
<string>Line width</string>
3584+
</property>
3585+
</widget>
3586+
</item>
35613587
<item row="0" column="2">
35623588
<widget class="QLabel" name="mLineColorTextLabel">
35633589
<property name="sizePolicy">
@@ -3581,31 +3607,43 @@
35813607
</property>
35823608
</widget>
35833609
</item>
3584-
<item row="0" column="0">
3585-
<widget class="QLabel" name="mLineWidthTextLabel">
3610+
<item row="0" column="5">
3611+
<widget class="QgsColorButtonV2" name="mFillColorToolButton">
35863612
<property name="sizePolicy">
3587-
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
3613+
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
35883614
<horstretch>0</horstretch>
35893615
<verstretch>0</verstretch>
35903616
</sizepolicy>
35913617
</property>
3618+
<property name="minimumSize">
3619+
<size>
3620+
<width>120</width>
3621+
<height>0</height>
3622+
</size>
3623+
</property>
3624+
<property name="maximumSize">
3625+
<size>
3626+
<width>120</width>
3627+
<height>16777215</height>
3628+
</size>
3629+
</property>
35923630
<property name="text">
3593-
<string>Line width</string>
3631+
<string/>
35943632
</property>
35953633
</widget>
35963634
</item>
35973635
<item row="0" column="4">
3598-
<spacer name="horizontalSpacer_33">
3599-
<property name="orientation">
3600-
<enum>Qt::Horizontal</enum>
3636+
<widget class="QLabel" name="mSelectColorTextLabel">
3637+
<property name="sizePolicy">
3638+
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
3639+
<horstretch>0</horstretch>
3640+
<verstretch>0</verstretch>
3641+
</sizepolicy>
36013642
</property>
3602-
<property name="sizeHint" stdset="0">
3603-
<size>
3604-
<width>40</width>
3605-
<height>20</height>
3606-
</size>
3643+
<property name="text">
3644+
<string>Fill color</string>
36073645
</property>
3608-
</spacer>
3646+
</widget>
36093647
</item>
36103648
<item row="0" column="3">
36113649
<widget class="QgsColorButtonV2" name="mLineColorToolButton">

0 commit comments

Comments
 (0)
Please sign in to comment.