Skip to content

Commit f64f8e2

Browse files
committedSep 2, 2017
[composer] Allow finer setting of scalebar height and widths
While the settings are stored as double, they were being rounded off in the UI to the nearest mm (cherry-picked from 7ca0b3d)
1 parent aec8cd3 commit f64f8e2

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed
 

‎src/app/composer/qgscomposerscalebarwidget.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,15 @@ void QgsComposerScaleBarWidget::on_mNumberOfSegmentsSpinBox_valueChanged( int i
219219
mComposerScaleBar->endCommand();
220220
}
221221

222-
void QgsComposerScaleBarWidget::on_mHeightSpinBox_valueChanged( int i )
222+
void QgsComposerScaleBarWidget::on_mHeightSpinBox_valueChanged( double d )
223223
{
224224
if ( !mComposerScaleBar )
225225
{
226226
return;
227227
}
228228
mComposerScaleBar->beginCommand( tr( "Scalebar height changed" ), QgsComposerMergeCommand::ScaleBarHeight );
229229
disconnectUpdateSignal();
230-
mComposerScaleBar->setHeight( i );
230+
mComposerScaleBar->setHeight( d );
231231
mComposerScaleBar->update();
232232
connectUpdateSignal();
233233
mComposerScaleBar->endCommand();
@@ -647,7 +647,7 @@ void QgsComposerScaleBarWidget::composerMapChanged( QgsComposerItem* item )
647647
mComposerScaleBar->endCommand();
648648
}
649649

650-
void QgsComposerScaleBarWidget::on_mMinWidthSpinBox_valueChanged( int )
650+
void QgsComposerScaleBarWidget::on_mMinWidthSpinBox_valueChanged( double )
651651
{
652652
if ( !mComposerScaleBar )
653653
{
@@ -662,7 +662,7 @@ void QgsComposerScaleBarWidget::on_mMinWidthSpinBox_valueChanged( int )
662662
mComposerScaleBar->endCommand();
663663
}
664664

665-
void QgsComposerScaleBarWidget::on_mMaxWidthSpinBox_valueChanged( int )
665+
void QgsComposerScaleBarWidget::on_mMaxWidthSpinBox_valueChanged( double )
666666
{
667667
if ( !mComposerScaleBar )
668668
{

‎src/app/composer/qgscomposerscalebarwidget.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class QgsComposerScaleBarWidget: public QgsComposerItemBaseWidget, private Ui::Q
3535

3636
public slots:
3737

38-
void on_mHeightSpinBox_valueChanged( int i );
38+
void on_mHeightSpinBox_valueChanged( double d );
3939
void on_mLineWidthSpinBox_valueChanged( double d );
4040
void on_mSegmentSizeSpinBox_valueChanged( double d );
4141
void on_mSegmentsLeftSpinBox_valueChanged( int i );
@@ -54,8 +54,8 @@ class QgsComposerScaleBarWidget: public QgsComposerItemBaseWidget, private Ui::Q
5454
void on_mUnitsComboBox_currentIndexChanged( int index );
5555
void on_mLineJoinStyleCombo_currentIndexChanged( int index );
5656
void on_mLineCapStyleCombo_currentIndexChanged( int index );
57-
void on_mMinWidthSpinBox_valueChanged( int i );
58-
void on_mMaxWidthSpinBox_valueChanged( int i );
57+
void on_mMinWidthSpinBox_valueChanged( double d );
58+
void on_mMaxWidthSpinBox_valueChanged( double d );
5959

6060
private slots:
6161
void setGuiElements();

‎src/core/composer/qgscomposerscalebar.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,8 +757,8 @@ bool QgsComposerScaleBar::readXML( const QDomElement& itemElem, const QDomDocume
757757
mNumSegmentsLeft = itemElem.attribute( "numSegmentsLeft", "0" ).toInt();
758758
mNumUnitsPerSegment = itemElem.attribute( "numUnitsPerSegment", "1.0" ).toDouble();
759759
mSegmentSizeMode = static_cast<SegmentSizeMode>( itemElem.attribute( "segmentSizeMode", "0" ).toInt() );
760-
mMinBarWidth = itemElem.attribute( "minBarWidth", "50" ).toInt();
761-
mMaxBarWidth = itemElem.attribute( "maxBarWidth", "150" ).toInt();
760+
mMinBarWidth = itemElem.attribute( "minBarWidth", "50" ).toDouble();
761+
mMaxBarWidth = itemElem.attribute( "maxBarWidth", "150" ).toDouble();
762762
mSegmentMillimeters = itemElem.attribute( "segmentMillimeters", "0.0" ).toDouble();
763763
mNumMapUnitsPerScaleBarUnit = itemElem.attribute( "numMapUnitsPerScaleBarUnit", "1.0" ).toDouble();
764764
mPen.setWidthF( itemElem.attribute( "outlineWidth", "0.3" ).toDouble() );

‎src/ui/composer/qgscomposerscalebarwidgetbase.ui

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@
262262
</widget>
263263
</item>
264264
<item row="4" column="2">
265-
<widget class="QgsSpinBox" name="mMaxWidthSpinBox">
265+
<widget class="QgsDoubleSpinBox" name="mMaxWidthSpinBox">
266266
<property name="enabled">
267267
<bool>false</bool>
268268
</property>
@@ -288,7 +288,7 @@
288288
</widget>
289289
</item>
290290
<item row="3" column="2">
291-
<widget class="QgsSpinBox" name="mMinWidthSpinBox">
291+
<widget class="QgsDoubleSpinBox" name="mMinWidthSpinBox">
292292
<property name="enabled">
293293
<bool>false</bool>
294294
</property>
@@ -304,7 +304,7 @@
304304
</widget>
305305
</item>
306306
<item row="5" column="2">
307-
<widget class="QgsSpinBox" name="mHeightSpinBox">
307+
<widget class="QgsDoubleSpinBox" name="mHeightSpinBox">
308308
<property name="suffix">
309309
<string> mm</string>
310310
</property>

0 commit comments

Comments
 (0)
Please sign in to comment.