Skip to content
Permalink
Browse files

When scale bar is numeric disable controls which don't apply

Don't change scale bar box size automatically when style is numeric
Remove duplicate call to adjustBoxSize when scale bar font changes
  • Loading branch information
nyalldawson committed Jun 12, 2013
1 parent f4300df commit e253cd3e1ed12b77f0bf0bff6deff4e33cd4b941
@@ -184,6 +184,7 @@ void QgsComposerScaleBarWidget::setGuiElements()
//style...
QString style = mComposerScaleBar->style();
mStyleComboBox->setCurrentIndex( mStyleComboBox->findText( tr( style.toLocal8Bit().data() ) ) );
toggleStyleSpecificControls( style );

//alignment
mAlignmentComboBox->setCurrentIndex(( int )( mComposerScaleBar->alignment() ) );
@@ -438,12 +439,38 @@ void QgsComposerScaleBarWidget::on_mStyleComboBox_currentIndexChanged( const QSt
{
untranslatedStyleName = "Numeric";
}

//disable or enable controls which apply to specific scale bar styles
toggleStyleSpecificControls( untranslatedStyleName );

mComposerScaleBar->setStyle( untranslatedStyleName );
mComposerScaleBar->update();
connectUpdateSignal();
mComposerScaleBar->endCommand();
}

void QgsComposerScaleBarWidget::toggleStyleSpecificControls( const QString& style )
{
if ( style == "Numeric" )
{
//Disable controls which don't apply to numeric scale bars
mGroupBoxUnits->setEnabled( false );
mGroupBoxUnits->setCollapsed( true );
mGroupBoxSegments->setEnabled( false );
mGroupBoxSegments->setCollapsed( true );
mLabelBarSpaceSpinBox->setEnabled( false );
mLineWidthSpinBox->setEnabled( false );
}
else
{
//Enable all controls
mGroupBoxUnits->setEnabled( true );
mGroupBoxSegments->setEnabled( true );
mLabelBarSpaceSpinBox->setEnabled( true );
mLineWidthSpinBox->setEnabled( true );
}
}

void QgsComposerScaleBarWidget::on_mLabelBarSpaceSpinBox_valueChanged( double d )
{
if ( !mComposerScaleBar )
@@ -64,6 +64,9 @@ class QgsComposerScaleBarWidget: public QWidget, private Ui::QgsComposerScaleBar
/**Enables/disables the signals of the input gui elements*/
void blockMemberSignals( bool enable );

/**Enables/disables controls based on scale bar style*/
void toggleStyleSpecificControls( const QString& style );

void connectUpdateSignal();
void disconnectUpdateSignal();
};
@@ -278,7 +278,11 @@ void QgsComposerScaleBar::adjustBoxSize()

void QgsComposerScaleBar::update()
{
adjustBoxSize();
//Don't adjust box size for numeric scale bars:
if ( mStyle->name() != "Numeric" )
{
adjustBoxSize();
}
QgsComposerItem::update();
}

@@ -386,7 +390,6 @@ QFont QgsComposerScaleBar::font() const
void QgsComposerScaleBar::setFont( const QFont& font )
{
mFont = font;
adjustBoxSize();
update();
emit itemChanged();
}
@@ -124,7 +124,7 @@
</widget>
</item>
<item>
<widget class="QgsCollapsibleGroupBoxBasic" name="groupBox_2">
<widget class="QgsCollapsibleGroupBoxBasic" name="mGroupBoxUnits">
<property name="title">
<string>Units</string>
</property>
@@ -184,7 +184,7 @@
</widget>
</item>
<item>
<widget class="QgsCollapsibleGroupBoxBasic" name="groupBox_3">
<widget class="QgsCollapsibleGroupBoxBasic" name="mGroupBoxSegments">
<property name="title">
<string>Segments</string>
</property>

0 comments on commit e253cd3

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