Skip to content

Commit

Permalink
Fix font size not restoring when opening label property dialog
Browse files Browse the repository at this point in the history
Also make font size of 0 correspond to a null value, ie the
label uses the default layer font size.
  • Loading branch information
nyalldawson committed Jan 18, 2015
1 parent 6a65050 commit bb7e53c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
21 changes: 19 additions & 2 deletions src/app/qgslabelpropertydialog.cpp
Expand Up @@ -262,8 +262,19 @@ void QgsLabelPropertyDialog::init( const QString& layerId, int featureId, const
mFontItalicBtn->setEnabled( true );
break;
case QgsPalLayerSettings::Size:
{
mFontSizeSpinBox->setEnabled( true );
double size = mCurLabelFeat.attribute( ddIndx ).toDouble( &ok );
if ( ok )
{
mFontSizeSpinBox->setValue( size );
}
else
{
mFontSizeSpinBox->setValue( 0 );
}
break;
}
default:
break;
}
Expand Down Expand Up @@ -329,13 +340,13 @@ void QgsLabelPropertyDialog::updateFont( const QFont& font, bool block )

if ( block )
blockElementSignals( true );

mFontFamilyCmbBx->setCurrentFont( mLabelFont );
populateFontStyleComboBox();
mFontUnderlineBtn->setChecked( mLabelFont.underline() );
mFontStrikethroughBtn->setChecked( mLabelFont.strikeOut() );
mFontBoldBtn->setChecked( mLabelFont.bold() );
mFontItalicBtn->setChecked( mLabelFont.italic() );
mFontSizeSpinBox->setValue( mLabelFont.pointSizeF() );
if ( block )
blockElementSignals( false );
}
Expand Down Expand Up @@ -452,7 +463,13 @@ void QgsLabelPropertyDialog::on_mFontItalicBtn_toggled( bool ckd )

void QgsLabelPropertyDialog::on_mFontSizeSpinBox_valueChanged( double d )
{
insertChangedValue( QgsPalLayerSettings::Size, d );
QVariant size( d );
if ( d <= 0 )
{
//null value so that font size is reset to default
size.clear();
}
insertChangedValue( QgsPalLayerSettings::Size, size );
}

void QgsLabelPropertyDialog::on_mBufferSizeSpinBox_valueChanged( double d )
Expand Down
11 changes: 10 additions & 1 deletion src/ui/qgslabelpropertydialogbase.ui
Expand Up @@ -225,11 +225,20 @@
</item>
<item>
<widget class="QgsDoubleSpinBox" name="mFontSizeSpinBox">
<property name="specialValueText">
<string>Default</string>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>999999.000000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
<property name="showClearButton">
<bool>false</bool>
<bool>true</bool>
</property>
</widget>
</item>
Expand Down

0 comments on commit bb7e53c

Please sign in to comment.