Skip to content

Commit 498575e

Browse files
committed
UI tweaks + selectively enable line/cross width/marker picker
1 parent 46242e1 commit 498575e

File tree

4 files changed

+282
-229
lines changed

4 files changed

+282
-229
lines changed

src/app/qgsdecorationgrid.h

+10-18
Original file line numberDiff line numberDiff line change
@@ -58,40 +58,33 @@ class QgsDecorationGrid: public QgsDecorationItem
5858
BoundaryDirection
5959
};
6060

61-
/**Sets coordinate grid style to solid or cross
62-
@note this function was added in version 1.4*/
61+
/**Sets coordinate grid style.
62+
@note this function (and all others) was added in version 2.0 */
6363
void setGridStyle( GridStyle style ) {mGridStyle = style;}
6464
GridStyle gridStyle() const { return mGridStyle; }
6565

66-
/**Sets coordinate interval in x-direction for composergrid.
67-
@note this function was added in version 1.4*/
66+
/**Sets coordinate interval in x-direction for composergrid. */
6867
void setGridIntervalX( double interval ) { mGridIntervalX = interval;}
6968
double gridIntervalX() const { return mGridIntervalX; }
7069

71-
/**Sets coordinate interval in y-direction for composergrid.
72-
@note this function was added in version 1.4*/
70+
/**Sets coordinate interval in y-direction for composergrid. */
7371
void setGridIntervalY( double interval ) { mGridIntervalY = interval;}
7472
double gridIntervalY() const { return mGridIntervalY; }
7573

76-
/**Sets x-coordinate offset for composer grid
77-
@note this function was added in version 1.4*/
74+
/**Sets x-coordinate offset for composer grid */
7875
void setGridOffsetX( double offset ) { mGridOffsetX = offset; }
7976
double gridOffsetX() const { return mGridOffsetX; }
8077

81-
/**Sets y-coordinate offset for composer grid
82-
@note this function was added in version 1.4*/
78+
/**Sets y-coordinate offset for composer grid */
8379
void setGridOffsetY( double offset ) { mGridOffsetY = offset; }
8480
double gridOffsetY() const { return mGridOffsetY; }
8581

86-
/**Sets the pen to draw composer grid
87-
@note this function was added in version 1.4*/
82+
/**Sets the pen to draw composer grid */
8883
void setGridPen( const QPen& p ) { mGridPen = p; }
8984
QPen gridPen() const { return mGridPen; }
90-
/**Sets with of grid pen
91-
@note this function was added in version 1.4*/
85+
/**Sets with of grid pen */
9286
void setGridPenWidth( double w ) { mGridPen.setWidthF( w ); }
93-
/**Sets the color of the grid pen
94-
@note this function was added in version 1.4*/
87+
/**Sets the color of the grid pen */
9588
void setGridPenColor( const QColor& c ) { mGridPen.setColor( c ); }
9689

9790
/**Sets font for grid annotations
@@ -217,8 +210,7 @@ class QgsDecorationGrid: public QgsDecorationItem
217210
void drawText( QPainter* p, const QRectF& rect, const QString& text, const QFont& font, Qt::AlignmentFlag halignement = Qt::AlignLeft, Qt::AlignmentFlag valignement = Qt::AlignTop ) const;
218211
/**Returns the font width in millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE*/
219212
double textWidthMillimeters( const QFont& font, const QString& text ) const;
220-
/**Returns the font height of a character in millimeters
221-
@note this method was added in version 1.7*/
213+
/**Returns the font height of a character in millimeters. */
222214
double fontHeightCharacterMM( const QFont& font, const QChar& c ) const;
223215
/**Returns the font ascent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE*/
224216
double fontAscentMillimeters( const QFont& font ) const;

src/app/qgsdecorationgriddialog.cpp

+40-64
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,32 @@
3131
#include <QSettings>
3232

3333
QgsDecorationGridDialog::QgsDecorationGridDialog( QgsDecorationGrid& deco, QWidget* parent )
34-
: QDialog( parent ), mDeco( deco ), mLineSymbol( 0 ), mMarkerSymbol( 0 )
34+
: QDialog( parent ), mDeco( deco ), mLineSymbol( 0 ), mMarkerSymbol( 0 )
3535
{
3636
setupUi( this );
3737

3838
QSettings settings;
39-
restoreGeometry( settings.value( "/Windows/DecorationGrid/geometry" ).toByteArray() );
39+
// restoreGeometry( settings.value( "/Windows/DecorationGrid/geometry" ).toByteArray() );
4040

4141
chkEnable->setChecked( mDeco.enabled() );
4242

4343
// mXMinLineEdit->setValidator( new QDoubleValidator( mXMinLineEdit ) );
4444

45-
mGridTypeComboBox->insertItem( 0, tr( "Solid" ) );
46-
mGridTypeComboBox->insertItem( 1, tr( "Cross" ) );
47-
mGridTypeComboBox->insertItem( 2, tr( "Marker" ) );
45+
mGridTypeComboBox->insertItem( QgsDecorationGrid::Solid, tr( "Lines" ) );
46+
mGridTypeComboBox->insertItem( QgsDecorationGrid::Cross, tr( "Cross" ) );
47+
mGridTypeComboBox->insertItem( QgsDecorationGrid::Marker, tr( "Marker" ) );
4848

49-
mAnnotationPositionComboBox->insertItem( 0, tr( "Inside frame" ) );
50-
// mAnnotationPositionComboBox->insertItem( 1, tr( "Outside frame" ) );
49+
mAnnotationPositionComboBox->insertItem( QgsDecorationGrid::InsideMapFrame, tr( "Inside frame" ) );
50+
// mAnnotationPositionComboBox->insertItem( QgsDecorationGrid::OutsideMapFrame, tr( "Outside frame" ) );
5151

52-
mAnnotationDirectionComboBox->insertItem( 0, tr( "Horizontal" ) );
53-
mAnnotationDirectionComboBox->insertItem( 1, tr( "Vertical" ) );
54-
mAnnotationDirectionComboBox->insertItem( 2, tr( "Horizontal and Vertical" ) );
55-
mAnnotationDirectionComboBox->insertItem( 2, tr( "Boundary direction" ) );
52+
mAnnotationDirectionComboBox->insertItem( QgsDecorationGrid::Horizontal,
53+
tr( "Horizontal" ) );
54+
mAnnotationDirectionComboBox->insertItem( QgsDecorationGrid::Vertical,
55+
tr( "Vertical" ) );
56+
mAnnotationDirectionComboBox->insertItem( QgsDecorationGrid::HorizontalAndVertical,
57+
tr( "Horizontal and Vertical" ) );
58+
mAnnotationDirectionComboBox->insertItem( QgsDecorationGrid::BoundaryDirection,
59+
tr( "Boundary direction" ) );
5660

5761
updateGuiElements();
5862

@@ -71,52 +75,16 @@ void QgsDecorationGridDialog::updateGuiElements()
7175
mOffsetXSpinBox->setValue( mDeco.gridOffsetX() );
7276
mOffsetYSpinBox->setValue( mDeco.gridOffsetY() );
7377

74-
QgsDecorationGrid::GridStyle gridStyle = mDeco.gridStyle();
75-
if ( gridStyle == QgsDecorationGrid::Cross )
76-
{
77-
mGridTypeComboBox->setCurrentIndex( mGridTypeComboBox->findText( tr( "Cross" ) ) );
78-
}
79-
else if ( gridStyle == QgsDecorationGrid::Marker )
80-
{
81-
mGridTypeComboBox->setCurrentIndex( mGridTypeComboBox->findText( tr( "Marker" ) ) );
82-
}
83-
else
84-
{
85-
mGridTypeComboBox->setCurrentIndex( mGridTypeComboBox->findText( tr( "Solid" ) ) );
86-
}
87-
78+
mGridTypeComboBox->setCurrentIndex(( int ) mDeco.gridStyle() );
79+
8880
mCrossWidthSpinBox->setValue( mDeco.crossLength() );
8981

90-
QgsDecorationGrid::GridAnnotationPosition annotationPos = mDeco.gridAnnotationPosition();
91-
if ( annotationPos == QgsDecorationGrid::InsideMapFrame )
92-
{
93-
mAnnotationPositionComboBox->setCurrentIndex( mAnnotationPositionComboBox->findText( tr( "Inside frame" ) ) );
94-
}
95-
else
96-
{
97-
mAnnotationPositionComboBox->setCurrentIndex( mAnnotationPositionComboBox->findText( tr( "Outside frame" ) ) );
98-
}
99-
82+
mAnnotationPositionComboBox->setCurrentIndex(( int ) mDeco.gridAnnotationPosition() );
83+
10084
mDrawAnnotationCheckBox->setChecked( mDeco.showGridAnnotation() );
101-
102-
QgsDecorationGrid::GridAnnotationDirection dir = mDeco.gridAnnotationDirection();
103-
if ( dir == QgsDecorationGrid::Horizontal )
104-
{
105-
mAnnotationDirectionComboBox->setCurrentIndex( mAnnotationDirectionComboBox->findText( tr( "Horizontal" ) ) );
106-
}
107-
else if ( dir == QgsDecorationGrid::Vertical )
108-
{
109-
mAnnotationDirectionComboBox->setCurrentIndex( mAnnotationDirectionComboBox->findText( tr( "Vertical" ) ) );
110-
}
111-
else if ( dir == QgsDecorationGrid::HorizontalAndVertical )
112-
{
113-
mAnnotationDirectionComboBox->setCurrentIndex( mAnnotationDirectionComboBox->findText( tr( "Horizontal and Vertical" ) ) );
114-
}
115-
else //BoundaryDirection
116-
{
117-
mAnnotationDirectionComboBox->setCurrentIndex( mAnnotationDirectionComboBox->findText( tr( "Boundary direction" ) ) );
118-
}
119-
85+
86+
mAnnotationDirectionComboBox->setCurrentIndex(( int ) mDeco.gridAnnotationDirection() );
87+
12088
mCoordinatePrecisionSpinBox->setValue( mDeco.gridAnnotationPrecision() );
12189

12290
// QPen gridPen = mDeco.gridPen();
@@ -140,7 +108,7 @@ void QgsDecorationGridDialog::updateGuiElements()
140108
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( mMarkerSymbol, mMarkerSymbolButton->iconSize() );
141109
mMarkerSymbolButton->setIcon( icon );
142110
}
143-
111+
144112
// blockAllSignals( false );
145113
}
146114

@@ -196,12 +164,12 @@ void QgsDecorationGridDialog::updateDecoFromGui()
196164
mDeco.setGridAnnotationPrecision( mCoordinatePrecisionSpinBox->value() );
197165
if ( mLineSymbol )
198166
{
199-
mDeco.setLineSymbol( mLineSymbol );
167+
mDeco.setLineSymbol( mLineSymbol );
200168
mLineSymbol = dynamic_cast<QgsLineSymbolV2*>( mDeco.lineSymbol()->clone() );
201169
}
202170
if ( mMarkerSymbol )
203171
{
204-
mDeco.setMarkerSymbol( mMarkerSymbol );
172+
mDeco.setMarkerSymbol( mMarkerSymbol );
205173
mMarkerSymbol = dynamic_cast<QgsMarkerSymbolV2*>( mDeco.markerSymbol()->clone() );
206174
}
207175
}
@@ -232,7 +200,7 @@ void QgsDecorationGridDialog::apply()
232200
{
233201
updateDecoFromGui();
234202
mDeco.update();
235-
//accept();
203+
//accept();
236204
}
237205

238206
void QgsDecorationGridDialog::on_buttonBox_rejected()
@@ -243,14 +211,22 @@ void QgsDecorationGridDialog::on_buttonBox_rejected()
243211

244212
// void QgsDecorationGridDialog::on_mLineColorButton_clicked()
245213
// {
246-
// QColor newColor = QColorDialog::getColor( mLineColorButton->color() );
247-
// if ( newColor.isValid() )
248-
// {
249-
// mLineColorButton->setColor( newColor );
250-
// mDeco.setGridPenColor( newColor );
251-
// }
214+
// QColor newColor = QColorDialog::getColor( mLineColorButton->color() );
215+
// if ( newColor.isValid() )
216+
// {
217+
// mLineColorButton->setColor( newColor );
218+
// mDeco.setGridPenColor( newColor );
219+
// }
252220
// }
253221

222+
void QgsDecorationGridDialog::on_mGridTypeComboBox_currentIndexChanged( int index )
223+
{
224+
mLineSymbolButton->setEnabled( index == QgsDecorationGrid::Solid );
225+
mCrossWidthSpinBox->setEnabled( index == QgsDecorationGrid::Cross );
226+
mMarkerSymbolButton->setEnabled( index == QgsDecorationGrid::Marker );
227+
}
228+
229+
254230
void QgsDecorationGridDialog::on_mLineSymbolButton_clicked()
255231
{
256232
if ( ! mLineSymbol )

src/app/qgsdecorationgriddialog.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class QgsDecorationGridDialog : public QDialog, private Ui::QgsDecorationGridDia
4141
void on_buttonBox_accepted();
4242
void on_buttonBox_rejected();
4343
void on_buttonBox_helpRequested();
44+
void on_mGridTypeComboBox_currentIndexChanged( int index );
4445
void on_mLineSymbolButton_clicked();
4546
void on_mMarkerSymbolButton_clicked();
4647

@@ -49,7 +50,7 @@ class QgsDecorationGridDialog : public QDialog, private Ui::QgsDecorationGridDia
4950
void on_mAnnotationFontButton_clicked();
5051

5152
private:
52-
QgsDecorationGrid& mDeco;
53+
QgsDecorationGrid& mDeco;
5354
QgsLineSymbolV2* mLineSymbol;
5455
QgsMarkerSymbolV2* mMarkerSymbol;
5556

0 commit comments

Comments
 (0)