Skip to content

Commit

Permalink
When scale bar is numeric disable controls which don't apply
Browse files Browse the repository at this point in the history
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 e253cd3
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 4 deletions.
27 changes: 27 additions & 0 deletions src/app/composer/qgscomposerscalebarwidget.cpp
Expand Up @@ -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() ) );
Expand Down Expand Up @@ -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 )
Expand Down
3 changes: 3 additions & 0 deletions src/app/composer/qgscomposerscalebarwidget.h
Expand Up @@ -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();
};
Expand Down
7 changes: 5 additions & 2 deletions src/core/composer/qgscomposerscalebar.cpp
Expand Up @@ -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();
}

Expand Down Expand Up @@ -386,7 +390,6 @@ QFont QgsComposerScaleBar::font() const
void QgsComposerScaleBar::setFont( const QFont& font )
{
mFont = font;
adjustBoxSize();
update();
emit itemChanged();
}
Expand Down
4 changes: 2 additions & 2 deletions src/ui/qgscomposerscalebarwidgetbase.ui
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit e253cd3

Please sign in to comment.