Skip to content
Permalink
Browse files

[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
  • Loading branch information
nyalldawson committed Sep 1, 2017
1 parent 247d265 commit 7ca0b2deb3380691454ce481794afb5d38f715a6
@@ -233,15 +233,15 @@ void QgsComposerScaleBarWidget::on_mNumberOfSegmentsSpinBox_valueChanged( int i
mComposerScaleBar->endCommand();
}

void QgsComposerScaleBarWidget::on_mHeightSpinBox_valueChanged( int i )
void QgsComposerScaleBarWidget::on_mHeightSpinBox_valueChanged( double d )
{
if ( !mComposerScaleBar )
{
return;
}
mComposerScaleBar->beginCommand( tr( "Scalebar height changed" ), QgsComposerMergeCommand::ScaleBarHeight );
disconnectUpdateSignal();
mComposerScaleBar->setHeight( i );
mComposerScaleBar->setHeight( d );
mComposerScaleBar->update();
connectUpdateSignal();
mComposerScaleBar->endCommand();
@@ -562,6 +562,8 @@ void QgsComposerScaleBarWidget::blockMemberSignals( bool block )
mSegmentSizeRadioGroup.blockSignals( block );
mMapItemComboBox->blockSignals( block );
mFontButton->blockSignals( block );
mMinWidthSpinBox->blockSignals( block );
mMaxWidthSpinBox->blockSignals( block );
}

void QgsComposerScaleBarWidget::connectUpdateSignal()
@@ -651,7 +653,7 @@ void QgsComposerScaleBarWidget::composerMapChanged( QgsComposerItem *item )
mComposerScaleBar->endCommand();
}

void QgsComposerScaleBarWidget::on_mMinWidthSpinBox_valueChanged( int )
void QgsComposerScaleBarWidget::on_mMinWidthSpinBox_valueChanged( double )
{
if ( !mComposerScaleBar )
{
@@ -666,7 +668,7 @@ void QgsComposerScaleBarWidget::on_mMinWidthSpinBox_valueChanged( int )
mComposerScaleBar->endCommand();
}

void QgsComposerScaleBarWidget::on_mMaxWidthSpinBox_valueChanged( int )
void QgsComposerScaleBarWidget::on_mMaxWidthSpinBox_valueChanged( double )
{
if ( !mComposerScaleBar )
{
@@ -35,7 +35,7 @@ class QgsComposerScaleBarWidget: public QgsComposerItemBaseWidget, private Ui::Q

public slots:

void on_mHeightSpinBox_valueChanged( int i );
void on_mHeightSpinBox_valueChanged( double d );
void on_mLineWidthSpinBox_valueChanged( double d );
void on_mSegmentSizeSpinBox_valueChanged( double d );
void on_mSegmentsLeftSpinBox_valueChanged( int i );
@@ -53,8 +53,8 @@ class QgsComposerScaleBarWidget: public QgsComposerItemBaseWidget, private Ui::Q
void on_mUnitsComboBox_currentIndexChanged( int index );
void on_mLineJoinStyleCombo_currentIndexChanged( int index );
void on_mLineCapStyleCombo_currentIndexChanged( int index );
void on_mMinWidthSpinBox_valueChanged( int i );
void on_mMaxWidthSpinBox_valueChanged( int i );
void on_mMinWidthSpinBox_valueChanged( double d );
void on_mMaxWidthSpinBox_valueChanged( double d );

private slots:
void setGuiElements();
@@ -728,8 +728,8 @@ bool QgsComposerScaleBar::readXml( const QDomElement &itemElem, const QDomDocume
mSettings.setNumberOfSegmentsLeft( itemElem.attribute( QStringLiteral( "numSegmentsLeft" ), QStringLiteral( "0" ) ).toInt() );
mSettings.setUnitsPerSegment( itemElem.attribute( QStringLiteral( "numUnitsPerSegment" ), QStringLiteral( "1.0" ) ).toDouble() );
mSettings.setSegmentSizeMode( static_cast<QgsScaleBarSettings::SegmentSizeMode>( itemElem.attribute( QStringLiteral( "segmentSizeMode" ), QStringLiteral( "0" ) ).toInt() ) );
mSettings.setMinimumBarWidth( itemElem.attribute( QStringLiteral( "minBarWidth" ), QStringLiteral( "50" ) ).toInt() );
mSettings.setMaximumBarWidth( itemElem.attribute( QStringLiteral( "maxBarWidth" ), QStringLiteral( "150" ) ).toInt() );
mSettings.setMinimumBarWidth( itemElem.attribute( QStringLiteral( "minBarWidth" ), QStringLiteral( "50" ) ).toDouble() );
mSettings.setMaximumBarWidth( itemElem.attribute( QStringLiteral( "maxBarWidth" ), QStringLiteral( "150" ) ).toDouble() );
mSegmentMillimeters = itemElem.attribute( QStringLiteral( "segmentMillimeters" ), QStringLiteral( "0.0" ) ).toDouble();
mSettings.setMapUnitsPerScaleBarUnit( itemElem.attribute( QStringLiteral( "numMapUnitsPerScaleBarUnit" ), QStringLiteral( "1.0" ) ).toDouble() );
mSettings.setLineWidth( itemElem.attribute( QStringLiteral( "outlineWidth" ), QStringLiteral( "0.3" ) ).toDouble() );
@@ -60,9 +60,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-121</y>
<width>437</width>
<height>764</height>
<y>0</y>
<width>440</width>
<height>1004</height>
</rect>
</property>
<layout class="QVBoxLayout" name="mainLayout">
@@ -261,22 +261,6 @@
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QgsSpinBox" name="mMaxWidthSpinBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="suffix">
<string> mm</string>
</property>
<property name="prefix">
<string>max </string>
</property>
<property name="maximum">
<number>999</number>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QgsSpinBox" name="mSegmentsLeftSpinBox">
<property name="suffix">
@@ -287,49 +271,56 @@
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QgsSpinBox" name="mMinWidthSpinBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="suffix">
<string> mm</string>
<item row="2" column="0" colspan="2">
<widget class="QRadioButton" name="mFixedSizeRadio">
<property name="text">
<string>Fi&amp;xed width</string>
</property>
<property name="prefix">
<string>min </string>
<property name="checked">
<bool>true</bool>
</property>
<property name="maximum">
<number>999</number>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QRadioButton" name="mFitWidthRadio">
<property name="text">
<string>Fit segment width</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QgsSpinBox" name="mHeightSpinBox">
<widget class="QgsDoubleSpinBox" name="mHeightSpinBox">
<property name="suffix">
<string> mm</string>
</property>
<property name="prefix">
<string/>
</property>
<property name="showClearButton" stdset="0">
<bool>false</bool>
<property name="maximum">
<double>999.990000000000009</double>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QRadioButton" name="mFixedSizeRadio">
<property name="text">
<string>Fi&amp;xed width</string>
<item row="3" column="2">
<widget class="QgsDoubleSpinBox" name="mMinWidthSpinBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="checked">
<bool>true</bool>
<property name="suffix">
<string> mm</string>
</property>
<property name="maximum">
<double>999.990000000000009</double>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QRadioButton" name="mFitWidthRadio">
<property name="text">
<string>Fit segment width</string>
<item row="4" column="2">
<widget class="QgsDoubleSpinBox" name="mMaxWidthSpinBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="suffix">
<string> mm</string>
</property>
<property name="maximum">
<double>999.990000000000009</double>
</property>
</widget>
</item>

0 comments on commit 7ca0b2d

Please sign in to comment.
You can’t perform that action at this time.