@@ -123,6 +123,7 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QWid
123123 chkMergeLines->setChecked ( lyr.mergeLines );
124124 chkMultiLine->setChecked ( lyr.multiLineLabels );
125125 mMinSizeSpinBox ->setValue ( lyr.minFeatureSize );
126+ chkAddDirectionSymbol->setChecked ( lyr.addDirectionSymbol );
126127
127128 bool scaleBased = ( lyr.scaleMin != 0 && lyr.scaleMax != 0 );
128129 chkScaleBasedVisibility->setChecked ( scaleBased );
@@ -139,7 +140,19 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QWid
139140
140141 btnTextColor->setColor ( lyr.textColor );
141142 btnBufferColor->setColor ( lyr.bufferColor );
142- updateFont ( lyr.textFont );
143+
144+ if ( lyr.fontSizeInMapUnits )
145+ {
146+ mFontSizeUnitComboBox ->setCurrentIndex ( 1 );
147+ }
148+ else
149+ {
150+ mFontSizeUnitComboBox ->setCurrentIndex ( 0 );
151+ }
152+
153+ QFont textFont = lyr.textFont ;
154+ updateFont ( textFont );
155+ mFontSizeSpinBox ->setValue ( textFont.pointSizeF () );
143156 updateUi ();
144157
145158 updateOptions ();
@@ -238,7 +251,17 @@ QgsPalLayerSettings QgsLabelingGui::layerSettings()
238251 {
239252 lyr.bufferSize = 0 ;
240253 }
254+ if ( chkAddDirectionSymbol->isChecked () )
255+ {
256+ lyr.addDirectionSymbol = true ;
257+ }
258+ else
259+ {
260+ lyr.addDirectionSymbol = false ;
261+ }
241262 lyr.minFeatureSize = mMinSizeSpinBox ->value ();
263+ lyr.fontSizeInMapUnits = ( mFontSizeUnitComboBox ->currentIndex () == 1 );
264+
242265
243266 // data defined labeling
244267 setDataDefinedProperty ( mSizeAttributeComboBox , QgsPalLayerSettings::Size, lyr );
@@ -250,6 +273,12 @@ QgsPalLayerSettings QgsLabelingGui::layerSettings()
250273 setDataDefinedProperty ( mFontFamilyAttributeComboBox , QgsPalLayerSettings::Family, lyr );
251274 setDataDefinedProperty ( mBufferSizeAttributeComboBox , QgsPalLayerSettings:: BufferSize, lyr );
252275 setDataDefinedProperty ( mBufferColorAttributeComboBox , QgsPalLayerSettings::BufferColor, lyr );
276+ setDataDefinedProperty ( mXCoordinateComboBox , QgsPalLayerSettings::PositionX, lyr );
277+ setDataDefinedProperty ( mYCoordinateComboBox , QgsPalLayerSettings::PositionY, lyr );
278+ setDataDefinedProperty ( mHorizontalAlignmentComboBox , QgsPalLayerSettings::Hali, lyr );
279+ setDataDefinedProperty ( mVerticalAlignmentComboBox , QgsPalLayerSettings::Vali, lyr );
280+ setDataDefinedProperty ( mLabelDistanceComboBox , QgsPalLayerSettings::LabelDistance, lyr );
281+ setDataDefinedProperty ( mRotationComboBox , QgsPalLayerSettings::Rotation, lyr );
253282
254283 return lyr;
255284}
@@ -308,6 +337,12 @@ void QgsLabelingGui::populateDataDefinedCombos( QgsPalLayerSettings& s )
308337 comboList << mFontFamilyAttributeComboBox ;
309338 comboList << mBufferSizeAttributeComboBox ;
310339 comboList << mBufferColorAttributeComboBox ;
340+ comboList << mXCoordinateComboBox ;
341+ comboList << mYCoordinateComboBox ;
342+ comboList << mHorizontalAlignmentComboBox ;
343+ comboList << mVerticalAlignmentComboBox ;
344+ comboList << mLabelDistanceComboBox ;
345+ comboList << mRotationComboBox ;
311346
312347 QList<QComboBox*>::iterator comboIt = comboList.begin ();
313348 for ( ; comboIt != comboList.end (); ++comboIt )
@@ -335,6 +370,12 @@ void QgsLabelingGui::populateDataDefinedCombos( QgsPalLayerSettings& s )
335370 setCurrentComboValue ( mFontFamilyAttributeComboBox , s, QgsPalLayerSettings::Family );
336371 setCurrentComboValue ( mBufferSizeAttributeComboBox , s , QgsPalLayerSettings::BufferSize );
337372 setCurrentComboValue ( mBufferColorAttributeComboBox , s, QgsPalLayerSettings::BufferColor );
373+ setCurrentComboValue ( mXCoordinateComboBox , s, QgsPalLayerSettings::PositionX );
374+ setCurrentComboValue ( mYCoordinateComboBox , s, QgsPalLayerSettings::PositionY );
375+ setCurrentComboValue ( mHorizontalAlignmentComboBox , s, QgsPalLayerSettings::Hali );
376+ setCurrentComboValue ( mVerticalAlignmentComboBox , s, QgsPalLayerSettings::Vali );
377+ setCurrentComboValue ( mLabelDistanceComboBox , s, QgsPalLayerSettings::LabelDistance );
378+ setCurrentComboValue ( mRotationComboBox , s, QgsPalLayerSettings::Rotation );
338379}
339380
340381void QgsLabelingGui::changeTextColor ()
@@ -352,14 +393,21 @@ void QgsLabelingGui::changeTextFont()
352393 bool ok;
353394 QFont font = QFontDialog::getFont ( &ok, lblFontPreview->font (), this );
354395 if ( ok )
396+ {
355397 updateFont ( font );
398+ }
399+ mFontSizeSpinBox ->setValue ( font.pointSizeF () );
356400}
357401
358402void QgsLabelingGui::updateFont ( QFont font )
359403{
360- lblFontName->setText ( QString ( " %1, %2 %3" ).arg ( font.family () ).arg ( font.pointSize () ).arg ( tr ( " pt" ) ) );
404+ QString fontSizeUnitString = tr ( " pt" );
405+ if ( mFontSizeUnitComboBox ->currentIndex () == 1 )
406+ {
407+ fontSizeUnitString = tr ( " map units" );
408+ }
409+ lblFontName->setText ( QString ( " %1, %2 %3" ).arg ( font.family () ).arg ( font.pointSize () ).arg ( fontSizeUnitString ) );
361410 lblFontPreview->setFont ( font );
362-
363411 updatePreview ();
364412}
365413
@@ -418,3 +466,57 @@ void QgsLabelingGui::updateOptions()
418466 stackedOptions->setCurrentWidget ( pageOptionsEmpty );
419467 }
420468}
469+
470+ void QgsLabelingGui::on_mFontSizeSpinBox_valueChanged ( double d )
471+ {
472+ QFont font = lblFontPreview->font ();
473+ font.setPointSizeF ( d );
474+ lblFontPreview->setFont ( font );
475+ updateFont ( font );
476+ }
477+
478+ void QgsLabelingGui::on_mFontSizeUnitComboBox_currentIndexChanged ( int index )
479+ {
480+ updateFont ( lblFontPreview->font () );
481+ }
482+
483+ void QgsLabelingGui::on_mXCoordinateComboBox_currentIndexChanged ( const QString & text )
484+ {
485+ if ( text.isEmpty () ) // no data defined alignment without data defined position
486+ {
487+ disableDataDefinedAlignment ();
488+ }
489+ else if ( !mYCoordinateComboBox ->currentText ().isEmpty () )
490+ {
491+ enableDataDefinedAlignment ();
492+ }
493+ }
494+
495+ void QgsLabelingGui::on_mYCoordinateComboBox_currentIndexChanged ( const QString & text )
496+ {
497+ if ( text.isEmpty () ) // no data defined alignment without data defined position
498+ {
499+ disableDataDefinedAlignment ();
500+ }
501+ else if ( !mXCoordinateComboBox ->currentText ().isEmpty () )
502+ {
503+ enableDataDefinedAlignment ();
504+ }
505+ }
506+
507+ void QgsLabelingGui::disableDataDefinedAlignment ()
508+ {
509+ mHorizontalAlignmentComboBox ->setCurrentIndex ( mHorizontalAlignmentComboBox ->findText ( " " ) );
510+ mHorizontalAlignmentComboBox ->setEnabled ( false );
511+ mVerticalAlignmentComboBox ->setCurrentIndex ( mVerticalAlignmentComboBox ->findText ( " " ) );
512+ mVerticalAlignmentComboBox ->setEnabled ( false );
513+ mRotationComboBox ->setCurrentIndex ( mRotationComboBox ->findText ( " " ) );
514+ mRotationComboBox ->setEnabled ( false );
515+ }
516+
517+ void QgsLabelingGui::enableDataDefinedAlignment ()
518+ {
519+ mHorizontalAlignmentComboBox ->setEnabled ( true );
520+ mVerticalAlignmentComboBox ->setEnabled ( true );
521+ mRotationComboBox ->setEnabled ( true );
522+ }
0 commit comments