Skip to content

Commit 0165846

Browse files
author
g_j_m
committed
Apply patch in ticket #458 (user configurable colour for the measure
tool). Thanks to Lars. git-svn-id: http://svn.osgeo.org/qgis/trunk@6375 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 4e80bf5 commit 0165846

File tree

4 files changed

+156
-80
lines changed

4 files changed

+156
-80
lines changed

src/gui/qgsmeasure.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ void QgsMeasure::activate()
8181
mCalc->setDefaultEllipsoid();
8282
mCalc->setProjectAsSourceSRS();
8383

84+
QSettings settings;
85+
int myRed = settings.value("/qgis/default_measure_color_red", 180).toInt();
86+
int myGreen = settings.value("/qgis/default_measure_color_green", 180).toInt();
87+
int myBlue = settings.value("/qgis/default_measure_color_blue", 180).toInt();
88+
mRubberBand->setColor(QColor(myRed, myGreen, myBlue));
89+
8490
// If we suspect that they have data that is projected, yet the
8591
// map SRS is set to a geographic one, warn them.
8692
if (mCalc->geographic() &&
@@ -136,6 +142,13 @@ void QgsMeasure::restart(void )
136142

137143
mRubberBand->reset(mMeasureArea);
138144

145+
// re-read color settings
146+
QSettings settings;
147+
int myRed = settings.value("/qgis/default_measure_color_red", 180).toInt();
148+
int myGreen = settings.value("/qgis/default_measure_color_green", 180).toInt();
149+
int myBlue = settings.value("/qgis/default_measure_color_blue", 180).toInt();
150+
mRubberBand->setColor(QColor(myRed, myGreen, myBlue));
151+
139152
mRightMouseClicked = false;
140153
}
141154

src/gui/qgsoptions.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ QgsOptions::QgsOptions(QWidget *parent, Qt::WFlags fl) :
122122
myGreen = settings.value("/qgis/default_canvas_color_green",255).toInt();
123123
myBlue = settings.value("/qgis/default_canvas_color_blue",255).toInt();
124124
pbnCanvasColor->setColor( QColor(myRed,myGreen,myBlue) );
125+
126+
// set the default color for the measure tool
127+
myRed = settings.value("/qgis/default_measure_color_red",180).toInt();
128+
myGreen = settings.value("/qgis/default_measure_color_green",180).toInt();
129+
myBlue = settings.value("/qgis/default_measure_color_blue",180).toInt();
130+
pbnMeasureColour->setColor( QColor(myRed,myGreen,myBlue) );
125131

126132
capitaliseCheckBox->setChecked(settings.value("qgis/capitaliseLayerName", QVariant(false)).toBool());
127133

@@ -151,6 +157,16 @@ void QgsOptions::on_pbnCanvasColor_clicked()
151157
pbnCanvasColor->setColor(color);
152158
}
153159
}
160+
161+
void QgsOptions::on_pbnMeasureColour_clicked()
162+
{
163+
QColor color = QColorDialog::getColor(pbnMeasureColour->color(), this);
164+
if (color.isValid())
165+
{
166+
pbnMeasureColour->setColor(color);
167+
}
168+
}
169+
154170
void QgsOptions::themeChanged(const QString &newThemeName)
155171
{
156172
// Slot to change the theme as user scrolls through the choices
@@ -214,6 +230,12 @@ void QgsOptions::saveOptions()
214230
myGreen = settings.writeEntry("/qgis/default_canvas_color_green",myColor.green());
215231
myBlue = settings.writeEntry("/qgis/default_canvas_color_blue",myColor.blue());
216232

233+
//set the default color for the measure tool
234+
myColor = pbnMeasureColour->color();
235+
myRed = settings.setValue("/qgis/default_measure_color_red",myColor.red());
236+
myGreen = settings.setValue("/qgis/default_measure_color_green",myColor.green());
237+
myBlue = settings.setValue("/qgis/default_measure_color_blue",myColor.blue());
238+
217239
settings.writeEntry("/qgis/wheel_action", cmbWheelAction->currentIndex());
218240
settings.writeEntry("/qgis/zoom_factor", spinZoomFactor->value());
219241

src/gui/qgsoptions.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ class QgsOptions :public QDialog, private Ui::QgsOptionsBase
6868
*/
6969
void on_pbnSelectionColour_clicked();
7070

71+
/*!
72+
* Slot to select the default measure tool colour
73+
*/
74+
void on_pbnMeasureColour_clicked();
75+
7176
/*!
7277
* Slot to select the default map selection colour
7378
*/

src/ui/qgsoptionsbase.ui

Lines changed: 116 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<item row="0" column="0" >
3232
<widget class="QTabWidget" name="tabWidget" >
3333
<property name="currentIndex" >
34-
<number>0</number>
34+
<number>2</number>
3535
</property>
3636
<widget class="QWidget" name="tabAppearance" >
3737
<attribute name="title" >
@@ -152,7 +152,7 @@
152152
<string>Selection Color:</string>
153153
</property>
154154
<property name="buddy" >
155-
<cstring>pbnSelectionColour</cstring>
155+
<cstring>pbnMeasureColour</cstring>
156156
</property>
157157
</widget>
158158
</item>
@@ -408,23 +408,10 @@
408408
<property name="spacing" >
409409
<number>6</number>
410410
</property>
411-
<item row="3" column="0" >
412-
<spacer>
413-
<property name="orientation" >
414-
<enum>Qt::Vertical</enum>
415-
</property>
416-
<property name="sizeHint" >
417-
<size>
418-
<width>20</width>
419-
<height>40</height>
420-
</size>
421-
</property>
422-
</spacer>
423-
</item>
424-
<item row="0" column="0" >
425-
<widget class="QGroupBox" name="groupBox_7" >
411+
<item row="2" column="0" >
412+
<widget class="QGroupBox" name="groupBox_10" >
426413
<property name="title" >
427-
<string>Search radius</string>
414+
<string>Panning and zooming</string>
428415
</property>
429416
<layout class="QGridLayout" >
430417
<property name="margin" >
@@ -433,43 +420,49 @@
433420
<property name="spacing" >
434421
<number>6</number>
435422
</property>
436-
<item row="1" column="0" colspan="2" >
437-
<widget class="QLabel" name="textLabel2" >
423+
<item row="0" column="1" >
424+
<widget class="QComboBox" name="cmbWheelAction" >
425+
<item>
426+
<property name="text" >
427+
<string>Zoom</string>
428+
</property>
429+
</item>
430+
<item>
431+
<property name="text" >
432+
<string>Zoom and recenter</string>
433+
</property>
434+
</item>
435+
<item>
436+
<property name="text" >
437+
<string>Nothing</string>
438+
</property>
439+
</item>
440+
</widget>
441+
</item>
442+
<item row="1" column="0" >
443+
<widget class="QLabel" name="label_3" >
438444
<property name="text" >
439-
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
440-
p, li { white-space: pre-wrap; }
441-
&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">
442-
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-weight:600;">Note:&lt;/span> Specify the search radius as a percentage of the map width.&lt;/p>
443-
&lt;p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;/p>&lt;/body>&lt;/html></string>
444-
</property>
445-
<property name="wordWrap" >
446-
<bool>true</bool>
445+
<string>Zoom factor:</string>
447446
</property>
448447
</widget>
449448
</item>
450449
<item row="0" column="0" >
451-
<widget class="QLabel" name="textLabel1_3" >
450+
<widget class="QLabel" name="label_2" >
452451
<property name="text" >
453-
<string>Search Radius for Identifying Features</string>
454-
</property>
455-
<property name="buddy" >
456-
<cstring>spinBoxIdentifyValue</cstring>
452+
<string>Mouse wheel action:</string>
457453
</property>
458454
</widget>
459455
</item>
460-
<item row="0" column="1" >
461-
<widget class="QDoubleSpinBox" name="spinBoxIdentifyValue" >
462-
<property name="suffix" >
463-
<string>%</string>
464-
</property>
465-
<property name="maximum" >
466-
<double>100.000000000000000</double>
456+
<item row="1" column="1" >
457+
<widget class="QDoubleSpinBox" name="spinZoomFactor" >
458+
<property name="decimals" >
459+
<number>1</number>
467460
</property>
468-
<property name="singleStep" >
469-
<double>0.010000000000000</double>
461+
<property name="minimum" >
462+
<double>1.100000000000000</double>
470463
</property>
471464
<property name="value" >
472-
<double>5.000000000000000</double>
465+
<double>2.000000000000000</double>
473466
</property>
474467
</widget>
475468
</item>
@@ -488,6 +481,45 @@ p, li { white-space: pre-wrap; }
488481
<property name="spacing" >
489482
<number>6</number>
490483
</property>
484+
<item row="1" column="2" >
485+
<spacer>
486+
<property name="orientation" >
487+
<enum>Qt::Horizontal</enum>
488+
</property>
489+
<property name="sizeHint" >
490+
<size>
491+
<width>191</width>
492+
<height>20</height>
493+
</size>
494+
</property>
495+
</spacer>
496+
</item>
497+
<item row="1" column="1" >
498+
<widget class="QgsColorButton" name="pbnMeasureColour" >
499+
<property name="minimumSize" >
500+
<size>
501+
<width>100</width>
502+
<height>0</height>
503+
</size>
504+
</property>
505+
<property name="text" >
506+
<string/>
507+
</property>
508+
</widget>
509+
</item>
510+
<item row="0" column="1" colspan="2" >
511+
<widget class="QComboBox" name="cmbEllipsoid" />
512+
</item>
513+
<item row="1" column="0" >
514+
<widget class="QLabel" name="textLabel1_10" >
515+
<property name="text" >
516+
<string>Rubberband color:</string>
517+
</property>
518+
<property name="buddy" >
519+
<cstring>cmbEllipsoid</cstring>
520+
</property>
521+
</widget>
522+
</item>
491523
<item row="0" column="0" >
492524
<widget class="QLabel" name="textLabel1_8" >
493525
<property name="text" >
@@ -498,16 +530,13 @@ p, li { white-space: pre-wrap; }
498530
</property>
499531
</widget>
500532
</item>
501-
<item row="0" column="1" >
502-
<widget class="QComboBox" name="cmbEllipsoid" />
503-
</item>
504533
</layout>
505534
</widget>
506535
</item>
507-
<item row="2" column="0" >
508-
<widget class="QGroupBox" name="groupBox_10" >
536+
<item row="0" column="0" >
537+
<widget class="QGroupBox" name="groupBox_7" >
509538
<property name="title" >
510-
<string>Panning and zooming</string>
539+
<string>Search radius</string>
511540
</property>
512541
<layout class="QGridLayout" >
513542
<property name="margin" >
@@ -516,55 +545,62 @@ p, li { white-space: pre-wrap; }
516545
<property name="spacing" >
517546
<number>6</number>
518547
</property>
519-
<item row="0" column="1" >
520-
<widget class="QComboBox" name="cmbWheelAction" >
521-
<item>
522-
<property name="text" >
523-
<string>Zoom</string>
524-
</property>
525-
</item>
526-
<item>
527-
<property name="text" >
528-
<string>Zoom and recenter</string>
529-
</property>
530-
</item>
531-
<item>
532-
<property name="text" >
533-
<string>Nothing</string>
534-
</property>
535-
</item>
536-
</widget>
537-
</item>
538-
<item row="1" column="0" >
539-
<widget class="QLabel" name="label_3" >
548+
<item row="1" column="0" colspan="2" >
549+
<widget class="QLabel" name="textLabel2" >
540550
<property name="text" >
541-
<string>Zoom factor:</string>
551+
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
552+
p, li { white-space: pre-wrap; }
553+
&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">
554+
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-weight:600;">Note:&lt;/span> Specify the search radius as a percentage of the map width.&lt;/p>
555+
&lt;p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;/p>&lt;/body>&lt;/html></string>
556+
</property>
557+
<property name="wordWrap" >
558+
<bool>true</bool>
542559
</property>
543560
</widget>
544561
</item>
545562
<item row="0" column="0" >
546-
<widget class="QLabel" name="label_2" >
563+
<widget class="QLabel" name="textLabel1_3" >
547564
<property name="text" >
548-
<string>Mouse wheel action:</string>
565+
<string>Search Radius for Identifying Features</string>
566+
</property>
567+
<property name="buddy" >
568+
<cstring>spinBoxIdentifyValue</cstring>
549569
</property>
550570
</widget>
551571
</item>
552-
<item row="1" column="1" >
553-
<widget class="QDoubleSpinBox" name="spinZoomFactor" >
554-
<property name="decimals" >
555-
<number>1</number>
572+
<item row="0" column="1" >
573+
<widget class="QDoubleSpinBox" name="spinBoxIdentifyValue" >
574+
<property name="suffix" >
575+
<string>%</string>
556576
</property>
557-
<property name="minimum" >
558-
<double>1.100000000000000</double>
577+
<property name="maximum" >
578+
<double>100.000000000000000</double>
579+
</property>
580+
<property name="singleStep" >
581+
<double>0.010000000000000</double>
559582
</property>
560583
<property name="value" >
561-
<double>2.000000000000000</double>
584+
<double>5.000000000000000</double>
562585
</property>
563586
</widget>
564587
</item>
565588
</layout>
566589
</widget>
567590
</item>
591+
<item row="3" column="0" >
592+
<spacer>
593+
<property name="orientation" >
594+
<enum>Qt::Vertical</enum>
595+
</property>
596+
<property name="sizeHint" >
597+
<size>
598+
<width>20</width>
599+
<height>40</height>
600+
</size>
601+
</property>
602+
</spacer>
603+
</item>
568604
</layout>
569605
</widget>
570606
<widget class="QWidget" name="TabPage" >

0 commit comments

Comments
 (0)