Skip to content

Commit bed703e

Browse files
committedAug 20, 2015
[GRASS] region pen options moved to GRASS options
1 parent faa32f3 commit bed703e

File tree

11 files changed

+151
-130
lines changed

11 files changed

+151
-130
lines changed
 

‎src/plugins/grass/qgsgrass_plugin.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<file alias="grass_new_point.png">themes/default/grass_new_point.png</file>
2020
<file alias="grass_new_vector_layer.png">themes/default/grass_new_vector_layer.png</file>
2121
<file alias="grass_open_mapset.png">themes/default/grass_open_mapset.png</file>
22+
<file alias="grass_options_region.png">themes/default/grass_options_region.png</file>
2223
<file alias="grass_region_edit.png">themes/default/grass_region_edit.png</file>
2324
<file alias="grass_region.png">themes/default/grass_region.png</file>
2425
<file alias="grass_set_region.png">themes/default/grass_set_region.png</file>

‎src/plugins/grass/qgsgrassplugin.cpp

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,7 @@ void QgsGrassPlugin::initGui()
226226
this, SLOT( setEditAction() ) );
227227

228228
connect( QgsGrass::instance(), SIGNAL( mapsetChanged() ), SLOT( mapsetChanged() ) );
229-
230-
// Init Region symbology
231-
mRegionPen.setColor( QColor( settings.value( "/GRASS/region/color", "#ff0000" ).toString() ) );
232-
mRegionPen.setWidth( settings.value( "/GRASS/region/width", 0 ).toInt() );
233-
mRegionBand->setColor( mRegionPen.color() );
234-
mRegionBand->setWidth( mRegionPen.width() );
229+
connect( QgsGrass::instance(), SIGNAL( regionPenChanged() ), SLOT( displayRegion() ) );
235230

236231
mapsetChanged();
237232

@@ -486,6 +481,10 @@ void QgsGrassPlugin::displayRegion()
486481

487482
QgsRectangle rect( QgsPoint( window.west, window.north ), QgsPoint( window.east, window.south ) );
488483

484+
QPen regionPen = QgsGrass::regionPen();
485+
mRegionBand->setColor( regionPen.color() );
486+
mRegionBand->setWidth( regionPen.width() );
487+
489488
QgsGrassRegionEdit::drawRegion( mCanvas, mRegionBand, rect, &mCoordinateTransform );
490489
}
491490

@@ -536,23 +535,6 @@ void QgsGrassPlugin::regionClosed()
536535
mRegion = 0;
537536
}
538537

539-
QPen & QgsGrassPlugin::regionPen()
540-
{
541-
return mRegionPen;
542-
}
543-
544-
void QgsGrassPlugin::setRegionPen( QPen & pen )
545-
{
546-
mRegionPen = pen;
547-
548-
mRegionBand->setColor( mRegionPen.color() );
549-
mRegionBand->setWidth( mRegionPen.width() );
550-
551-
QSettings settings;
552-
settings.setValue( "/GRASS/region/color", mRegionPen.color().name() );
553-
settings.setValue( "/GRASS/region/width", ( int ) mRegionPen.width() );
554-
}
555-
556538
void QgsGrassPlugin::openMapset()
557539
{
558540
// QgsDebugMsg("entered.");

‎src/plugins/grass/qgsgrassplugin.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
#include "qgscoordinatereferencesystem.h"
2020
#include "qgscoordinatetransform.h"
2121
#include <QObject>
22-
#include <QPen>
23-
2422

2523
class QgsGrassTools;
2624
class QgsGrassNewMapset;
@@ -75,10 +73,6 @@ class QgsGrassPlugin : public QObject, public QgisPlugin
7573
//! Destructor
7674
virtual ~QgsGrassPlugin();
7775

78-
//! Get Region Pen
79-
QPen & regionPen( void );
80-
//! Set Region Pen
81-
void setRegionPen( QPen & );
8276
//! Get an icon from the active theme if possible
8377
static QIcon getThemeIcon( const QString &theName );
8478

@@ -139,8 +133,6 @@ class QgsGrassPlugin : public QObject, public QgisPlugin
139133

140134
//! Pointer to Display region acction
141135
QAction *mRegionAction;
142-
//! Region width
143-
QPen mRegionPen;
144136
//! Region dialog
145137
QgsGrassRegion *mRegion;
146138
// Region rubber band

‎src/plugins/grass/qgsgrassregion.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -258,31 +258,6 @@ QgsGrassRegion::QgsGrassRegion( QgsGrassPlugin *plugin, QgisInterface *iface,
258258
connect( mEWRes, SIGNAL( editingFinished() ), this, SLOT( EWResChanged() ) );
259259
connect( mRows, SIGNAL( editingFinished() ), this, SLOT( rowsChanged() ) );
260260
connect( mCols, SIGNAL( editingFinished() ), this, SLOT( colsChanged() ) );
261-
262-
// Symbology
263-
QPen pen = mPlugin->regionPen();
264-
mColorButton->setContext( "gui" );
265-
mColorButton->setColorDialogTitle( tr( "Select color" ) );
266-
mColorButton->setColor( pen.color() );
267-
connect( mColorButton, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( changeColor( const QColor& ) ) );
268-
269-
mWidthSpinBox->setValue( pen.width() );
270-
connect( mWidthSpinBox, SIGNAL( valueChanged( int ) ), this, SLOT( changeWidth() ) );
271-
}
272-
273-
void QgsGrassRegion::changeColor( const QColor& color )
274-
{
275-
QPen pen = mPlugin->regionPen();
276-
pen.setColor( color );
277-
mPlugin->setRegionPen( pen );
278-
}
279-
280-
void QgsGrassRegion::changeWidth( void )
281-
{
282-
QPen pen = mPlugin->regionPen();
283-
284-
pen.setWidth( mWidthSpinBox->value() );
285-
mPlugin->setRegionPen( pen );
286261
}
287262

288263
QString QgsGrassRegion::formatEdge( double v )

‎src/plugins/grass/qgsgrassregion.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ class QgsGrassRegion: public QDialog, private Ui::QgsGrassRegionBase
8181

8282
void radioChanged( void );
8383

84-
void changeColor( const QColor& color );
85-
void changeWidth( void );
86-
8784
void restorePosition( void );
8885

8986
//! Called when the capture finished to refresh the mWindow values

‎src/plugins/grass/qgsgrassregionbase.ui

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -160,67 +160,6 @@ or change the following values</string>
160160
</widget>
161161
</item>
162162
<item row="2" column="0">
163-
<widget class="QGroupBox" name="groupBox_3">
164-
<property name="title">
165-
<string>Border</string>
166-
</property>
167-
<layout class="QGridLayout" name="gridLayout_3">
168-
<item row="0" column="0">
169-
<widget class="QLabel" name="textLabel7">
170-
<property name="text">
171-
<string>Color</string>
172-
</property>
173-
</widget>
174-
</item>
175-
<item row="0" column="2">
176-
<widget class="QLabel" name="textLabel6">
177-
<property name="text">
178-
<string>Width</string>
179-
</property>
180-
<property name="indent">
181-
<number>20</number>
182-
</property>
183-
</widget>
184-
</item>
185-
<item row="0" column="3">
186-
<widget class="QSpinBox" name="mWidthSpinBox"/>
187-
</item>
188-
<item row="0" column="4">
189-
<spacer name="horizontalSpacer">
190-
<property name="orientation">
191-
<enum>Qt::Horizontal</enum>
192-
</property>
193-
<property name="sizeHint" stdset="0">
194-
<size>
195-
<width>40</width>
196-
<height>20</height>
197-
</size>
198-
</property>
199-
</spacer>
200-
</item>
201-
<item row="0" column="1">
202-
<widget class="QgsColorButtonV2" name="mColorButton">
203-
<property name="minimumSize">
204-
<size>
205-
<width>120</width>
206-
<height>0</height>
207-
</size>
208-
</property>
209-
<property name="maximumSize">
210-
<size>
211-
<width>120</width>
212-
<height>16777215</height>
213-
</size>
214-
</property>
215-
<property name="text">
216-
<string/>
217-
</property>
218-
</widget>
219-
</item>
220-
</layout>
221-
</widget>
222-
</item>
223-
<item row="3" column="0">
224163
<widget class="QDialogButtonBox" name="buttonBox">
225164
<property name="orientation">
226165
<enum>Qt::Horizontal</enum>
@@ -232,13 +171,6 @@ or change the following values</string>
232171
</item>
233172
</layout>
234173
</widget>
235-
<customwidgets>
236-
<customwidget>
237-
<class>QgsColorButtonV2</class>
238-
<extends>QToolButton</extends>
239-
<header>qgscolorbuttonv2.h</header>
240-
</customwidget>
241-
</customwidgets>
242174
<resources/>
243175
<connections/>
244176
</ui>
Loading

‎src/providers/grass/qgsgrass.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,6 +2350,23 @@ void QgsGrass::setModulesConfig( bool custom, const QString &customDir )
23502350
}
23512351
}
23522352

2353+
QPen QgsGrass::regionPen()
2354+
{
2355+
QSettings settings;
2356+
QPen pen;
2357+
pen.setColor( QColor( settings.value( "/GRASS/region/color", "#ff0000" ).toString() ) );
2358+
pen.setWidthF( settings.value( "/GRASS/region/width", 0 ).toFloat() );
2359+
return pen;
2360+
}
2361+
2362+
void QgsGrass::setRegionPen( const QPen & pen )
2363+
{
2364+
QSettings settings;
2365+
settings.setValue( "/GRASS/region/color", pen.color().name() );
2366+
settings.setValue( "/GRASS/region/width", pen.widthF() );
2367+
emit regionPenChanged();
2368+
}
2369+
23532370
bool QgsGrass::modulesDebug()
23542371
{
23552372
QSettings settings;

‎src/providers/grass/qgsgrass.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define QGSGRASS_H
1818

1919
#include <QMutex>
20+
#include <QPen>
2021

2122
#include <setjmp.h>
2223

@@ -471,6 +472,10 @@ class GRASS_LIB_EXPORT QgsGrass : public QObject
471472

472473
void setModulesConfig( bool custom, const QString &customDir );
473474

475+
static QPen regionPen();
476+
477+
void setRegionPen( const QPen & pen );
478+
474479
// Modules UI debug
475480
static bool modulesDebug();
476481

@@ -501,6 +506,9 @@ class GRASS_LIB_EXPORT QgsGrass : public QObject
501506
/** Emitted when modules debug mode changed */
502507
void modulesDebugChanged();
503508

509+
/** Emitted when region pen changed */
510+
void regionPenChanged();
511+
504512
private:
505513
static int initialized; // Set to 1 after initialization
506514
static bool active; // is active mode

‎src/providers/grass/qgsgrassoptions.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ QgsGrassOptions::QgsGrassOptions( QWidget *parent )
5353

5454
mImportExternalCheckBox->setChecked( settings.value( mImportSettingsPath + "/external", true ).toBool() );
5555

56+
// Region
57+
QPen regionPen = QgsGrass::regionPen();
58+
mRegionColorButton->setContext( "gui" );
59+
mRegionColorButton->setColorDialogTitle( tr( "Select color" ) );
60+
mRegionColorButton->setColor( regionPen.color() );
61+
mRegionWidthSpinBox->setValue( regionPen.width() );
62+
5663
restoreOptionsBaseUi();
5764
}
5865

@@ -87,4 +94,10 @@ void QgsGrassOptions::saveOptions()
8794
mCrsTransformationComboBox->itemData( mCrsTransformationComboBox->currentIndex() ).toInt() );
8895

8996
settings.setValue( mImportSettingsPath + "/external", mImportExternalCheckBox->isChecked() );
97+
98+
// Region
99+
QPen regionPen = QgsGrass::regionPen();
100+
regionPen.setColor( mRegionColorButton->color() );
101+
regionPen.setWidthF( mRegionWidthSpinBox->value() );
102+
QgsGrass::instance()->setRegionPen( regionPen );
90103
}

‎src/providers/grass/qgsgrassoptionsbase.ui

Lines changed: 107 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@
7171
<property name="resizeMode">
7272
<enum>QListView::Adjust</enum>
7373
</property>
74+
<property name="uniformItemSizes">
75+
<bool>false</bool>
76+
</property>
7477
<property name="wordWrap">
7578
<bool>true</bool>
7679
</property>
@@ -95,6 +98,15 @@
9598
<normaloff>:/images/icons/qbrowser-icon-60x60.png</normaloff>:/images/icons/qbrowser-icon-60x60.png</iconset>
9699
</property>
97100
</item>
101+
<item>
102+
<property name="text">
103+
<string>Region</string>
104+
</property>
105+
<property name="icon">
106+
<iconset resource="../../plugins/grass/qgsgrass_plugin.qrc">
107+
<normaloff>:/images/themes/default/grass/grass_options_region.png</normaloff>:/images/themes/default/grass/grass_options_region.png</iconset>
108+
</property>
109+
</item>
98110
</widget>
99111
</item>
100112
</layout>
@@ -119,7 +131,7 @@
119131
<number>0</number>
120132
</property>
121133
<property name="currentIndex">
122-
<number>0</number>
134+
<number>2</number>
123135
</property>
124136
<widget class="QWidget" name="mModulesPage">
125137
<layout class="QVBoxLayout" name="verticalLayout_7">
@@ -234,8 +246,8 @@
234246
<rect>
235247
<x>0</x>
236248
<y>0</y>
237-
<width>286</width>
238-
<height>98</height>
249+
<width>447</width>
250+
<height>358</height>
239251
</rect>
240252
</property>
241253
<layout class="QVBoxLayout" name="verticalLayout_28">
@@ -308,6 +320,92 @@
308320
</item>
309321
</layout>
310322
</widget>
323+
<widget class="QWidget" name="mRegionPage">
324+
<layout class="QVBoxLayout" name="verticalLayout_9">
325+
<item>
326+
<widget class="QgsCollapsibleGroupBox" name="mRegionGroupBox">
327+
<property name="title">
328+
<string>Region border</string>
329+
</property>
330+
<layout class="QVBoxLayout" name="verticalLayout_8">
331+
<item>
332+
<layout class="QGridLayout" name="gridLayout_2">
333+
<item row="0" column="0">
334+
<widget class="QLabel" name="mRegionColorLabel">
335+
<property name="text">
336+
<string>Color</string>
337+
</property>
338+
</widget>
339+
</item>
340+
<item row="0" column="1">
341+
<widget class="QgsColorButtonV2" name="mRegionColorButton">
342+
<property name="minimumSize">
343+
<size>
344+
<width>120</width>
345+
<height>0</height>
346+
</size>
347+
</property>
348+
<property name="maximumSize">
349+
<size>
350+
<width>120</width>
351+
<height>16777215</height>
352+
</size>
353+
</property>
354+
<property name="text">
355+
<string/>
356+
</property>
357+
</widget>
358+
</item>
359+
<item row="0" column="2">
360+
<spacer name="horizontalSpacer_2">
361+
<property name="orientation">
362+
<enum>Qt::Horizontal</enum>
363+
</property>
364+
<property name="sizeHint" stdset="0">
365+
<size>
366+
<width>40</width>
367+
<height>20</height>
368+
</size>
369+
</property>
370+
</spacer>
371+
</item>
372+
<item row="1" column="0">
373+
<widget class="QLabel" name="mRegionWidthLabel">
374+
<property name="text">
375+
<string>Width</string>
376+
</property>
377+
</widget>
378+
</item>
379+
<item row="1" column="1">
380+
<widget class="QDoubleSpinBox" name="mRegionWidthSpinBox">
381+
<property name="decimals">
382+
<number>1</number>
383+
</property>
384+
<property name="singleStep">
385+
<double>0.200000000000000</double>
386+
</property>
387+
</widget>
388+
</item>
389+
</layout>
390+
</item>
391+
<item>
392+
<spacer name="verticalSpacer_3">
393+
<property name="orientation">
394+
<enum>Qt::Vertical</enum>
395+
</property>
396+
<property name="sizeHint" stdset="0">
397+
<size>
398+
<width>20</width>
399+
<height>40</height>
400+
</size>
401+
</property>
402+
</spacer>
403+
</item>
404+
</layout>
405+
</widget>
406+
</item>
407+
</layout>
408+
</widget>
311409
</widget>
312410
</item>
313411
</layout>
@@ -345,6 +443,11 @@
345443
</layout>
346444
</widget>
347445
<customwidgets>
446+
<customwidget>
447+
<class>QgsColorButtonV2</class>
448+
<extends>QToolButton</extends>
449+
<header>qgscolorbuttonv2.h</header>
450+
</customwidget>
348451
<customwidget>
349452
<class>QgsCollapsibleGroupBox</class>
350453
<extends>QGroupBox</extends>
@@ -354,6 +457,7 @@
354457
</customwidgets>
355458
<resources>
356459
<include location="../../../images/images.qrc"/>
460+
<include location="../../plugins/grass/qgsgrass_plugin.qrc"/>
357461
</resources>
358462
<connections>
359463
<connection>

0 commit comments

Comments
 (0)
Please sign in to comment.