@@ -123,6 +123,7 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QWid
123
123
chkMergeLines->setChecked ( lyr.mergeLines );
124
124
chkMultiLine->setChecked ( lyr.multiLineLabels );
125
125
mMinSizeSpinBox ->setValue ( lyr.minFeatureSize );
126
+ chkAddDirectionSymbol->setChecked ( lyr.addDirectionSymbol );
126
127
127
128
bool scaleBased = ( lyr.scaleMin != 0 && lyr.scaleMax != 0 );
128
129
chkScaleBasedVisibility->setChecked ( scaleBased );
@@ -139,7 +140,19 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QWid
139
140
140
141
btnTextColor->setColor ( lyr.textColor );
141
142
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 () );
143
156
updateUi ();
144
157
145
158
updateOptions ();
@@ -238,7 +251,17 @@ QgsPalLayerSettings QgsLabelingGui::layerSettings()
238
251
{
239
252
lyr.bufferSize = 0 ;
240
253
}
254
+ if ( chkAddDirectionSymbol->isChecked () )
255
+ {
256
+ lyr.addDirectionSymbol = true ;
257
+ }
258
+ else
259
+ {
260
+ lyr.addDirectionSymbol = false ;
261
+ }
241
262
lyr.minFeatureSize = mMinSizeSpinBox ->value ();
263
+ lyr.fontSizeInMapUnits = ( mFontSizeUnitComboBox ->currentIndex () == 1 );
264
+
242
265
243
266
// data defined labeling
244
267
setDataDefinedProperty ( mSizeAttributeComboBox , QgsPalLayerSettings::Size, lyr );
@@ -250,6 +273,12 @@ QgsPalLayerSettings QgsLabelingGui::layerSettings()
250
273
setDataDefinedProperty ( mFontFamilyAttributeComboBox , QgsPalLayerSettings::Family, lyr );
251
274
setDataDefinedProperty ( mBufferSizeAttributeComboBox , QgsPalLayerSettings:: BufferSize, lyr );
252
275
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 );
253
282
254
283
return lyr;
255
284
}
@@ -308,6 +337,12 @@ void QgsLabelingGui::populateDataDefinedCombos( QgsPalLayerSettings& s )
308
337
comboList << mFontFamilyAttributeComboBox ;
309
338
comboList << mBufferSizeAttributeComboBox ;
310
339
comboList << mBufferColorAttributeComboBox ;
340
+ comboList << mXCoordinateComboBox ;
341
+ comboList << mYCoordinateComboBox ;
342
+ comboList << mHorizontalAlignmentComboBox ;
343
+ comboList << mVerticalAlignmentComboBox ;
344
+ comboList << mLabelDistanceComboBox ;
345
+ comboList << mRotationComboBox ;
311
346
312
347
QList<QComboBox*>::iterator comboIt = comboList.begin ();
313
348
for ( ; comboIt != comboList.end (); ++comboIt )
@@ -335,6 +370,12 @@ void QgsLabelingGui::populateDataDefinedCombos( QgsPalLayerSettings& s )
335
370
setCurrentComboValue ( mFontFamilyAttributeComboBox , s, QgsPalLayerSettings::Family );
336
371
setCurrentComboValue ( mBufferSizeAttributeComboBox , s , QgsPalLayerSettings::BufferSize );
337
372
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 );
338
379
}
339
380
340
381
void QgsLabelingGui::changeTextColor ()
@@ -352,14 +393,21 @@ void QgsLabelingGui::changeTextFont()
352
393
bool ok;
353
394
QFont font = QFontDialog::getFont ( &ok, lblFontPreview->font (), this );
354
395
if ( ok )
396
+ {
355
397
updateFont ( font );
398
+ }
399
+ mFontSizeSpinBox ->setValue ( font.pointSizeF () );
356
400
}
357
401
358
402
void QgsLabelingGui::updateFont ( QFont font )
359
403
{
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 ) );
361
410
lblFontPreview->setFont ( font );
362
-
363
411
updatePreview ();
364
412
}
365
413
@@ -418,3 +466,57 @@ void QgsLabelingGui::updateOptions()
418
466
stackedOptions->setCurrentWidget ( pageOptionsEmpty );
419
467
}
420
468
}
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