@@ -34,6 +34,7 @@ QgsLabelPropertyDialog::QgsLabelPropertyDialog( const QString& layerId, int feat
34
34
setupUi ( this );
35
35
fillHaliComboBox ();
36
36
fillValiComboBox ();
37
+
37
38
init ( layerId, featureId, labelText );
38
39
39
40
QSettings settings;
@@ -111,11 +112,17 @@ void QgsLabelPropertyDialog::init( const QString& layerId, int featureId, const
111
112
updateFont ( mLabelFont , false );
112
113
113
114
// set all the gui elements to the default layer-level values
115
+ mLabelDistanceSpinBox ->clear ();
116
+ mLabelDistanceSpinBox ->setSpecialValueText ( tr ( " Layer default (%1)" ).arg ( QString::number ( layerSettings.dist , ' f' , mLabelDistanceSpinBox ->decimals () ) ) );
117
+ mBufferSizeSpinBox ->clear ();
118
+ mBufferSizeSpinBox ->setSpecialValueText ( tr ( " Layer default (%1)" ).arg ( QString::number ( layerSettings.bufferSize , ' f' , mBufferSizeSpinBox ->decimals () ) ) );
119
+ mRotationSpinBox ->clear ();
120
+ mXCoordSpinBox ->clear ();
121
+ mYCoordSpinBox ->clear ();
122
+
114
123
mShowLabelChkbx ->setChecked ( true );
115
124
mFontColorButton ->setColor ( layerSettings.textColor );
116
125
mBufferColorButton ->setColor ( layerSettings.bufferColor );
117
- mLabelDistanceSpinBox ->setValue ( layerSettings.dist );
118
- mBufferSizeSpinBox ->setValue ( layerSettings.bufferSize );
119
126
mMinScaleSpinBox ->setValue ( layerSettings.scaleMin );
120
127
mMaxScaleSpinBox ->setValue ( layerSettings.scaleMax );
121
128
mHaliComboBox ->setCurrentIndex ( mHaliComboBox ->findText ( " Left" ) );
@@ -486,17 +493,35 @@ void QgsLabelPropertyDialog::on_mMaxScaleSpinBox_valueChanged( int i )
486
493
487
494
void QgsLabelPropertyDialog::on_mLabelDistanceSpinBox_valueChanged ( double d )
488
495
{
489
- insertChangedValue ( QgsPalLayerSettings::LabelDistance, d );
496
+ QVariant distance ( d );
497
+ if ( d < 0 )
498
+ {
499
+ // null value so that distance is reset to default
500
+ distance.clear ();
501
+ }
502
+ insertChangedValue ( QgsPalLayerSettings::LabelDistance, distance );
490
503
}
491
504
492
505
void QgsLabelPropertyDialog::on_mXCoordSpinBox_valueChanged ( double d )
493
506
{
494
- insertChangedValue ( QgsPalLayerSettings::PositionX, d );
507
+ QVariant x ( d );
508
+ if ( d < mXCoordSpinBox ->minimum () + mXCoordSpinBox ->singleStep () )
509
+ {
510
+ // null value
511
+ x.clear ();
512
+ }
513
+ insertChangedValue ( QgsPalLayerSettings::PositionX, x );
495
514
}
496
515
497
516
void QgsLabelPropertyDialog::on_mYCoordSpinBox_valueChanged ( double d )
498
517
{
499
- insertChangedValue ( QgsPalLayerSettings::PositionY, d );
518
+ QVariant y ( d );
519
+ if ( d < mYCoordSpinBox ->minimum () + mYCoordSpinBox ->singleStep () )
520
+ {
521
+ // null value
522
+ y.clear ();
523
+ }
524
+ insertChangedValue ( QgsPalLayerSettings::PositionY, y );
500
525
}
501
526
502
527
void QgsLabelPropertyDialog::on_mFontFamilyCmbBx_currentFontChanged ( const QFont& f )
@@ -554,12 +579,24 @@ void QgsLabelPropertyDialog::on_mFontSizeSpinBox_valueChanged( double d )
554
579
555
580
void QgsLabelPropertyDialog::on_mBufferSizeSpinBox_valueChanged ( double d )
556
581
{
557
- insertChangedValue ( QgsPalLayerSettings::PositionX, d );
582
+ QVariant size ( d );
583
+ if ( d < 0 )
584
+ {
585
+ // null value so that size is reset to default
586
+ size.clear ();
587
+ }
588
+ insertChangedValue ( QgsPalLayerSettings::BufferSize, size );
558
589
}
559
590
560
591
void QgsLabelPropertyDialog::on_mRotationSpinBox_valueChanged ( double d )
561
592
{
562
- insertChangedValue ( QgsPalLayerSettings::Rotation, d );
593
+ QVariant rotation ( d );
594
+ if ( d < 0 )
595
+ {
596
+ // null value so that size is reset to default
597
+ rotation.clear ();
598
+ }
599
+ insertChangedValue ( QgsPalLayerSettings::Rotation, rotation );
563
600
}
564
601
565
602
void QgsLabelPropertyDialog::on_mFontColorButton_colorChanged ( const QColor &color )
0 commit comments