Skip to content

Commit bb7e53c

Browse files
committed
Fix font size not restoring when opening label property dialog
Also make font size of 0 correspond to a null value, ie the label uses the default layer font size.
1 parent 6a65050 commit bb7e53c

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

src/app/qgslabelpropertydialog.cpp

+19-2
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,19 @@ void QgsLabelPropertyDialog::init( const QString& layerId, int featureId, const
262262
mFontItalicBtn->setEnabled( true );
263263
break;
264264
case QgsPalLayerSettings::Size:
265+
{
265266
mFontSizeSpinBox->setEnabled( true );
267+
double size = mCurLabelFeat.attribute( ddIndx ).toDouble( &ok );
268+
if ( ok )
269+
{
270+
mFontSizeSpinBox->setValue( size );
271+
}
272+
else
273+
{
274+
mFontSizeSpinBox->setValue( 0 );
275+
}
266276
break;
277+
}
267278
default:
268279
break;
269280
}
@@ -329,13 +340,13 @@ void QgsLabelPropertyDialog::updateFont( const QFont& font, bool block )
329340

330341
if ( block )
331342
blockElementSignals( true );
343+
332344
mFontFamilyCmbBx->setCurrentFont( mLabelFont );
333345
populateFontStyleComboBox();
334346
mFontUnderlineBtn->setChecked( mLabelFont.underline() );
335347
mFontStrikethroughBtn->setChecked( mLabelFont.strikeOut() );
336348
mFontBoldBtn->setChecked( mLabelFont.bold() );
337349
mFontItalicBtn->setChecked( mLabelFont.italic() );
338-
mFontSizeSpinBox->setValue( mLabelFont.pointSizeF() );
339350
if ( block )
340351
blockElementSignals( false );
341352
}
@@ -452,7 +463,13 @@ void QgsLabelPropertyDialog::on_mFontItalicBtn_toggled( bool ckd )
452463

453464
void QgsLabelPropertyDialog::on_mFontSizeSpinBox_valueChanged( double d )
454465
{
455-
insertChangedValue( QgsPalLayerSettings::Size, d );
466+
QVariant size( d );
467+
if ( d <= 0 )
468+
{
469+
//null value so that font size is reset to default
470+
size.clear();
471+
}
472+
insertChangedValue( QgsPalLayerSettings::Size, size );
456473
}
457474

458475
void QgsLabelPropertyDialog::on_mBufferSizeSpinBox_valueChanged( double d )

src/ui/qgslabelpropertydialogbase.ui

+10-1
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,20 @@
225225
</item>
226226
<item>
227227
<widget class="QgsDoubleSpinBox" name="mFontSizeSpinBox">
228+
<property name="specialValueText">
229+
<string>Default</string>
230+
</property>
231+
<property name="minimum">
232+
<double>0.000000000000000</double>
233+
</property>
228234
<property name="maximum">
229235
<double>999999.000000000000000</double>
230236
</property>
237+
<property name="value">
238+
<double>0.000000000000000</double>
239+
</property>
231240
<property name="showClearButton">
232-
<bool>false</bool>
241+
<bool>true</bool>
233242
</property>
234243
</widget>
235244
</item>

0 commit comments

Comments
 (0)