Skip to content

Commit

Permalink
Apply patch in ticket #458 (user configurable colour for the measure
Browse files Browse the repository at this point in the history
tool). Thanks to Lars.


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6375 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Jan 2, 2007
1 parent a8673c3 commit 469908c
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 80 deletions.
13 changes: 13 additions & 0 deletions src/gui/qgsmeasure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ void QgsMeasure::activate()
mCalc->setDefaultEllipsoid();
mCalc->setProjectAsSourceSRS();

QSettings settings;
int myRed = settings.value("/qgis/default_measure_color_red", 180).toInt();
int myGreen = settings.value("/qgis/default_measure_color_green", 180).toInt();
int myBlue = settings.value("/qgis/default_measure_color_blue", 180).toInt();
mRubberBand->setColor(QColor(myRed, myGreen, myBlue));

// If we suspect that they have data that is projected, yet the
// map SRS is set to a geographic one, warn them.
if (mCalc->geographic() &&
Expand Down Expand Up @@ -136,6 +142,13 @@ void QgsMeasure::restart(void )

mRubberBand->reset(mMeasureArea);

// re-read color settings
QSettings settings;
int myRed = settings.value("/qgis/default_measure_color_red", 180).toInt();
int myGreen = settings.value("/qgis/default_measure_color_green", 180).toInt();
int myBlue = settings.value("/qgis/default_measure_color_blue", 180).toInt();
mRubberBand->setColor(QColor(myRed, myGreen, myBlue));

mRightMouseClicked = false;
}

Expand Down
22 changes: 22 additions & 0 deletions src/gui/qgsoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ QgsOptions::QgsOptions(QWidget *parent, Qt::WFlags fl) :
myGreen = settings.value("/qgis/default_canvas_color_green",255).toInt();
myBlue = settings.value("/qgis/default_canvas_color_blue",255).toInt();
pbnCanvasColor->setColor( QColor(myRed,myGreen,myBlue) );

// set the default color for the measure tool
myRed = settings.value("/qgis/default_measure_color_red",180).toInt();
myGreen = settings.value("/qgis/default_measure_color_green",180).toInt();
myBlue = settings.value("/qgis/default_measure_color_blue",180).toInt();
pbnMeasureColour->setColor( QColor(myRed,myGreen,myBlue) );

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

Expand Down Expand Up @@ -151,6 +157,16 @@ void QgsOptions::on_pbnCanvasColor_clicked()
pbnCanvasColor->setColor(color);
}
}

void QgsOptions::on_pbnMeasureColour_clicked()
{
QColor color = QColorDialog::getColor(pbnMeasureColour->color(), this);
if (color.isValid())
{
pbnMeasureColour->setColor(color);
}
}

void QgsOptions::themeChanged(const QString &newThemeName)
{
// Slot to change the theme as user scrolls through the choices
Expand Down Expand Up @@ -214,6 +230,12 @@ void QgsOptions::saveOptions()
myGreen = settings.writeEntry("/qgis/default_canvas_color_green",myColor.green());
myBlue = settings.writeEntry("/qgis/default_canvas_color_blue",myColor.blue());

//set the default color for the measure tool
myColor = pbnMeasureColour->color();
myRed = settings.setValue("/qgis/default_measure_color_red",myColor.red());
myGreen = settings.setValue("/qgis/default_measure_color_green",myColor.green());
myBlue = settings.setValue("/qgis/default_measure_color_blue",myColor.blue());

settings.writeEntry("/qgis/wheel_action", cmbWheelAction->currentIndex());
settings.writeEntry("/qgis/zoom_factor", spinZoomFactor->value());

Expand Down
5 changes: 5 additions & 0 deletions src/gui/qgsoptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ class QgsOptions :public QDialog, private Ui::QgsOptionsBase
*/
void on_pbnSelectionColour_clicked();

/*!
* Slot to select the default measure tool colour
*/
void on_pbnMeasureColour_clicked();

/*!
* Slot to select the default map selection colour
*/
Expand Down
196 changes: 116 additions & 80 deletions src/ui/qgsoptionsbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<item row="0" column="0" >
<widget class="QTabWidget" name="tabWidget" >
<property name="currentIndex" >
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="tabAppearance" >
<attribute name="title" >
Expand Down Expand Up @@ -152,7 +152,7 @@
<string>Selection Color:</string>
</property>
<property name="buddy" >
<cstring>pbnSelectionColour</cstring>
<cstring>pbnMeasureColour</cstring>
</property>
</widget>
</item>
Expand Down Expand Up @@ -408,23 +408,10 @@
<property name="spacing" >
<number>6</number>
</property>
<item row="3" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" >
<widget class="QGroupBox" name="groupBox_7" >
<item row="2" column="0" >
<widget class="QGroupBox" name="groupBox_10" >
<property name="title" >
<string>Search radius</string>
<string>Panning and zooming</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
Expand All @@ -433,43 +420,49 @@
<property name="spacing" >
<number>6</number>
</property>
<item row="1" column="0" colspan="2" >
<widget class="QLabel" name="textLabel2" >
<item row="0" column="1" >
<widget class="QComboBox" name="cmbWheelAction" >
<item>
<property name="text" >
<string>Zoom</string>
</property>
</item>
<item>
<property name="text" >
<string>Zoom and recenter</string>
</property>
</item>
<item>
<property name="text" >
<string>Nothing</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">
&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>
&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>
</property>
<property name="wordWrap" >
<bool>true</bool>
<string>Zoom factor:</string>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="textLabel1_3" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Search Radius for Identifying Features</string>
</property>
<property name="buddy" >
<cstring>spinBoxIdentifyValue</cstring>
<string>Mouse wheel action:</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QDoubleSpinBox" name="spinBoxIdentifyValue" >
<property name="suffix" >
<string>%</string>
</property>
<property name="maximum" >
<double>100.000000000000000</double>
<item row="1" column="1" >
<widget class="QDoubleSpinBox" name="spinZoomFactor" >
<property name="decimals" >
<number>1</number>
</property>
<property name="singleStep" >
<double>0.010000000000000</double>
<property name="minimum" >
<double>1.100000000000000</double>
</property>
<property name="value" >
<double>5.000000000000000</double>
<double>2.000000000000000</double>
</property>
</widget>
</item>
Expand All @@ -488,6 +481,45 @@ p, li { white-space: pre-wrap; }
<property name="spacing" >
<number>6</number>
</property>
<item row="1" column="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>191</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1" >
<widget class="QgsColorButton" name="pbnMeasureColour" >
<property name="minimumSize" >
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2" >
<widget class="QComboBox" name="cmbEllipsoid" />
</item>
<item row="1" column="0" >
<widget class="QLabel" name="textLabel1_10" >
<property name="text" >
<string>Rubberband color:</string>
</property>
<property name="buddy" >
<cstring>cmbEllipsoid</cstring>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="textLabel1_8" >
<property name="text" >
Expand All @@ -498,16 +530,13 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QComboBox" name="cmbEllipsoid" />
</item>
</layout>
</widget>
</item>
<item row="2" column="0" >
<widget class="QGroupBox" name="groupBox_10" >
<item row="0" column="0" >
<widget class="QGroupBox" name="groupBox_7" >
<property name="title" >
<string>Panning and zooming</string>
<string>Search radius</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
Expand All @@ -516,55 +545,62 @@ p, li { white-space: pre-wrap; }
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="1" >
<widget class="QComboBox" name="cmbWheelAction" >
<item>
<property name="text" >
<string>Zoom</string>
</property>
</item>
<item>
<property name="text" >
<string>Zoom and recenter</string>
</property>
</item>
<item>
<property name="text" >
<string>Nothing</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_3" >
<item row="1" column="0" colspan="2" >
<widget class="QLabel" name="textLabel2" >
<property name="text" >
<string>Zoom factor:</string>
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">
&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>
&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>
</property>
<property name="wordWrap" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="label_2" >
<widget class="QLabel" name="textLabel1_3" >
<property name="text" >
<string>Mouse wheel action:</string>
<string>Search Radius for Identifying Features</string>
</property>
<property name="buddy" >
<cstring>spinBoxIdentifyValue</cstring>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QDoubleSpinBox" name="spinZoomFactor" >
<property name="decimals" >
<number>1</number>
<item row="0" column="1" >
<widget class="QDoubleSpinBox" name="spinBoxIdentifyValue" >
<property name="suffix" >
<string>%</string>
</property>
<property name="minimum" >
<double>1.100000000000000</double>
<property name="maximum" >
<double>100.000000000000000</double>
</property>
<property name="singleStep" >
<double>0.010000000000000</double>
</property>
<property name="value" >
<double>2.000000000000000</double>
<double>5.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="TabPage" >
Expand Down

0 comments on commit 469908c

Please sign in to comment.