451 changes: 233 additions & 218 deletions src/app/qgslabelinggui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM
mDirectSymbBtnGrp->addButton( mDirectSymbRadioBtnBelow, ( int )QgsPalLayerSettings::SymbolBelow );
mDirectSymbBtnGrp->setExclusive( true );


// upside-down labels button group
mUpsidedownBtnGrp = new QButtonGroup( this );
mUpsidedownBtnGrp->addButton( mUpsidedownRadioOff, ( int )QgsPalLayerSettings::Upright );
Expand All @@ -152,35 +151,41 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM

//mShapeCollisionsChkBx->setVisible( false ); // until implemented

updatePlacementWidgets();

// post updatePlacementWidgets() connections
connect( chkLineAbove, SIGNAL( toggled( bool ) ), this, SLOT( updatePlacementWidgets() ) );
connect( chkLineBelow, SIGNAL( toggled( bool ) ), this, SLOT( updatePlacementWidgets() ) );

// setup connection to changes in the placement
QRadioButton* placementRadios[] =
{
radAroundPoint, radOverPoint, // point
radLineParallel, radLineCurved, radLineHorizontal, // line
radAroundCentroid, radPolygonHorizontal, radPolygonFree, radPolygonPerimeter // polygon
};
for ( unsigned int i = 0; i < sizeof( placementRadios ) / sizeof( QRadioButton* ); i++ )
{
connect( placementRadios[i], SIGNAL( toggled( bool ) ), this, SLOT( updatePlacementWidgets() ) );
}
// setup point placement button group (assigned enum id currently unused)
mPlacePointBtnGrp = new QButtonGroup( this );
mPlacePointBtnGrp->addButton( radAroundPoint, ( int )QgsPalLayerSettings::AroundPoint );
mPlacePointBtnGrp->addButton( radOverPoint, ( int )QgsPalLayerSettings::OverPoint );
mPlacePointBtnGrp->setExclusive( true );
connect( mPlacePointBtnGrp, SIGNAL( buttonClicked( int ) ), this, SLOT( updatePlacementWidgets() ) );

// setup line placement button group (assigned enum id currently unused)
mPlaceLineBtnGrp = new QButtonGroup( this );
mPlaceLineBtnGrp->addButton( radLineParallel, ( int )QgsPalLayerSettings::Line );
mPlaceLineBtnGrp->addButton( radLineCurved, ( int )QgsPalLayerSettings::Curved );
mPlaceLineBtnGrp->addButton( radLineHorizontal, ( int )QgsPalLayerSettings::Horizontal );
mPlaceLineBtnGrp->setExclusive( true );
connect( mPlaceLineBtnGrp, SIGNAL( buttonClicked( int ) ), this, SLOT( updatePlacementWidgets() ) );

// setup polygon placement button group (assigned enum id currently unused)
mPlacePolygonBtnGrp = new QButtonGroup( this );
mPlacePolygonBtnGrp->addButton( radOverCentroid, ( int )QgsPalLayerSettings::OverPoint );
mPlacePolygonBtnGrp->addButton( radAroundCentroid, ( int )QgsPalLayerSettings::AroundPoint );
mPlacePolygonBtnGrp->addButton( radPolygonHorizontal, ( int )QgsPalLayerSettings::Horizontal );
mPlacePolygonBtnGrp->addButton( radPolygonFree, ( int )QgsPalLayerSettings::Free );
mPlacePolygonBtnGrp->addButton( radPolygonPerimeter, ( int )QgsPalLayerSettings::Line );
mPlacePolygonBtnGrp->setExclusive( true );
connect( mPlacePolygonBtnGrp, SIGNAL( buttonClicked( int ) ), this, SLOT( updatePlacementWidgets() ) );

// TODO: is this necessary? maybe just use the data defined-only rotation?
mPointAngleDDBtn->setVisible( false );

// set up data defined toolbuttons
// disable H,V data defined alignment until X,Y are active
disableDataDefinedAlignment();

// load layer's current QgsPalLayerSettings
init();

updateUi(); // should come after data defined button setup

// Global settings group for groupboxes' saved/retored collapsed state
// maintains state across different dialogs
foreach ( QgsCollapsibleGroupBox *grpbox, findChildren<QgsCollapsibleGroupBox*>() )
Expand Down Expand Up @@ -222,202 +227,209 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM

void QgsLabelingGui::init()
{
// load labeling settings from layer
QgsPalLayerSettings lyr;
lyr.readFromLayer( mLayer );
// load labeling settings from layer
QgsPalLayerSettings lyr;
lyr.readFromLayer( mLayer );

// enable/disable main options based upon whether layer is being labeled
chkEnableLabeling->setChecked( lyr.enabled );
cboFieldName->setEnabled( chkEnableLabeling->isChecked() );
btnExpression->setEnabled( chkEnableLabeling->isChecked() );
mLabelingFrame->setEnabled( chkEnableLabeling->isChecked() );
blockInitSignals( true );

// add the current expression to the bottom of the list
if ( lyr.isExpression && !lyr.fieldName.isEmpty() )
cboFieldName->addItem( lyr.fieldName );
// enable/disable main options based upon whether layer is being labeled
chkEnableLabeling->setChecked( lyr.enabled );
cboFieldName->setEnabled( chkEnableLabeling->isChecked() );
btnExpression->setEnabled( chkEnableLabeling->isChecked() );
mLabelingFrame->setEnabled( chkEnableLabeling->isChecked() );

cboFieldName->setCurrentIndex( cboFieldName->findText( lyr.fieldName ) );
// add the current expression to the bottom of the list
if ( lyr.isExpression && !lyr.fieldName.isEmpty() )
cboFieldName->addItem( lyr.fieldName );

// populate placement options
int distUnitIndex = lyr.distInMapUnits ? 1 : 0;
cboFieldName->setCurrentIndex( cboFieldName->findText( lyr.fieldName ) );

mCentroidRadioWhole->setChecked( lyr.centroidWhole );
switch ( lyr.placement )
{
case QgsPalLayerSettings::AroundPoint:
radAroundPoint->setChecked( true );
radAroundCentroid->setChecked( true );
// populate placement options
int distUnitIndex = lyr.distInMapUnits ? 1 : 0;

mLineDistanceSpnBx->setValue( lyr.dist );
mLineDistanceUnitComboBox->setCurrentIndex( distUnitIndex );
//spinAngle->setValue( lyr.angle ); // TODO: uncomment when supported
break;
case QgsPalLayerSettings::OverPoint:
radOverPoint->setChecked( true );
radOverCentroid->setChecked( true );

mQuadrantBtnGrp->button(( int )lyr.quadOffset )->setChecked( true );
mPointOffsetXSpinBox->setValue( lyr.xOffset );
mPointOffsetYSpinBox->setValue( lyr.yOffset );
mPointOffsetUnitsComboBox->setCurrentIndex( lyr.labelOffsetInMapUnits ? 1 : 0 );
mPointAngleSpinBox->setValue( lyr.angleOffset );
break;
case QgsPalLayerSettings::Line:
radLineParallel->setChecked( true );
radPolygonPerimeter->setChecked( true );
break;
case QgsPalLayerSettings::Curved:
radLineCurved->setChecked( true );
break;
case QgsPalLayerSettings::Horizontal:
radPolygonHorizontal->setChecked( true );
radLineHorizontal->setChecked( true );
break;
case QgsPalLayerSettings::Free:
radPolygonFree->setChecked( true );
break;
default:
Q_ASSERT( 0 && "NOOO!" );
}
mCentroidRadioWhole->setChecked( lyr.centroidWhole );
switch ( lyr.placement )
{
case QgsPalLayerSettings::AroundPoint:
radAroundPoint->setChecked( true );
radAroundCentroid->setChecked( true );

if ( lyr.placement == QgsPalLayerSettings::Line || lyr.placement == QgsPalLayerSettings::Curved )
{
mLineDistanceSpnBx->setValue( lyr.dist );
mLineDistanceUnitComboBox->setCurrentIndex( distUnitIndex );
chkLineAbove->setChecked( lyr.placementFlags & QgsPalLayerSettings::AboveLine );
chkLineBelow->setChecked( lyr.placementFlags & QgsPalLayerSettings::BelowLine );
chkLineOn->setChecked( lyr.placementFlags & QgsPalLayerSettings::OnLine );
if ( !( lyr.placementFlags & QgsPalLayerSettings::MapOrientation ) )
chkLineOrientationDependent->setChecked( true );
}
//spinAngle->setValue( lyr.angle ); // TODO: uncomment when supported
break;
case QgsPalLayerSettings::OverPoint:
radOverPoint->setChecked( true );
radOverCentroid->setChecked( true );

mQuadrantBtnGrp->button(( int )lyr.quadOffset )->setChecked( true );
mPointOffsetXSpinBox->setValue( lyr.xOffset );
mPointOffsetYSpinBox->setValue( lyr.yOffset );
mPointOffsetUnitsComboBox->setCurrentIndex( lyr.labelOffsetInMapUnits ? 1 : 0 );
mPointAngleSpinBox->setValue( lyr.angleOffset );
break;
case QgsPalLayerSettings::Line:
radLineParallel->setChecked( true );
radPolygonPerimeter->setChecked( true );
break;
case QgsPalLayerSettings::Curved:
radLineCurved->setChecked( true );
break;
case QgsPalLayerSettings::Horizontal:
radPolygonHorizontal->setChecked( true );
radLineHorizontal->setChecked( true );
break;
case QgsPalLayerSettings::Free:
radPolygonFree->setChecked( true );
break;
default:
Q_ASSERT( 0 && "NOOO!" );
}

mPrioritySlider->setValue( lyr.priority );
chkNoObstacle->setChecked( lyr.obstacle );
chkLabelPerFeaturePart->setChecked( lyr.labelPerPart );
mPalShowAllLabelsForLayerChkBx->setChecked( lyr.displayAll );
chkMergeLines->setChecked( lyr.mergeLines );
mMinSizeSpinBox->setValue( lyr.minFeatureSize );
mLimitLabelChkBox->setChecked( lyr.limitNumLabels );
mLimitLabelSpinBox->setValue( lyr.maxNumLabels );

// direction symbol(s)
mDirectSymbChkBx->setChecked( lyr.addDirectionSymbol );
mDirectSymbLeftLineEdit->setText( lyr.leftDirectionSymbol );
mDirectSymbRightLineEdit->setText( lyr.rightDirectionSymbol );
mDirectSymbRevChkBx->setChecked( lyr.reverseDirectionSymbol );

mDirectSymbBtnGrp->button(( int )lyr.placeDirectionSymbol )->setChecked( true );
mUpsidedownBtnGrp->button(( int )lyr.upsidedownLabels )->setChecked( true );

// curved label max character angles
mMaxCharAngleInDSpinBox->setValue( lyr.maxCurvedCharAngleIn );
// lyr.maxCurvedCharAngleOut must be negative, but it is shown as positive spinbox in GUI
mMaxCharAngleOutDSpinBox->setValue( qAbs( lyr.maxCurvedCharAngleOut ) );

wrapCharacterEdit->setText( lyr.wrapChar );
mFontLineHeightSpinBox->setValue( lyr.multilineHeight );
mFontMultiLineAlignComboBox->setCurrentIndex(( unsigned int ) lyr.multilineAlign );
chkPreserveRotation->setChecked( lyr.preserveRotation );

mPreviewBackgroundBtn->setColor( lyr.previewBkgrdColor );
setPreviewBackground( lyr.previewBkgrdColor );

mScaleBasedVisibilityChkBx->setChecked( lyr.scaleVisibility );
mScaleBasedVisibilityMinSpnBx->setValue( lyr.scaleMin );
mScaleBasedVisibilityMaxSpnBx->setValue( lyr.scaleMax );

// buffer
mBufferDrawChkBx->setChecked( lyr.bufferDraw );
spinBufferSize->setValue( lyr.bufferSize );
mBufferUnitComboBox->setCurrentIndex( lyr.bufferSizeInMapUnits ? 1 : 0 );
btnBufferColor->setColor( lyr.bufferColor );
mBufferTranspSpinBox->setValue( lyr.bufferTransp );
mBufferJoinStyleComboBox->setPenJoinStyle( lyr.bufferJoinStyle );
mBufferTranspFillChbx->setChecked( !lyr.bufferNoFill );
comboBufferBlendMode->setBlendMode( lyr.bufferBlendMode );

mFormatNumChkBx->setChecked( lyr.formatNumbers );
mFormatNumDecimalsSpnBx->setValue( lyr.decimals );
mFormatNumPlusSignChkBx->setChecked( lyr.plusSign );

// set pixel size limiting checked state before unit choice so limiting can be
// turned on as a default for map units, if minimum trigger value of 0 is used
mFontLimitPixelChkBox->setChecked( lyr.fontLimitPixelSize );
mMinPixelLimit = lyr.fontMinPixelSize; // ignored after first settings save
mFontMinPixelSpinBox->setValue( lyr.fontMinPixelSize == 0 ? 3 : lyr.fontMinPixelSize );
mFontMaxPixelSpinBox->setValue( lyr.fontMaxPixelSize );
mFontSizeUnitComboBox->setCurrentIndex( lyr.fontSizeInMapUnits ? 1 : 0 );

mRefFont = lyr.textFont;
mFontSizeSpinBox->setValue( lyr.textFont.pointSizeF() );
btnTextColor->setColor( lyr.textColor );
mFontTranspSpinBox->setValue( lyr.textTransp );
comboBlendMode->setBlendMode( lyr.blendMode );

mFontWordSpacingSpinBox->setValue( lyr.textFont.wordSpacing() );
mFontLetterSpacingSpinBox->setValue( lyr.textFont.letterSpacing() );

updateFontViaStyle( lyr.textNamedStyle );
updateFont( mRefFont );

// shape background
mShapeDrawChkBx->setChecked( lyr.shapeDraw );
mShapeTypeCmbBx->blockSignals( true );
mShapeTypeCmbBx->setCurrentIndex( lyr.shapeType );
mShapeTypeCmbBx->blockSignals( false );
mShapeSVGPathLineEdit->setText( lyr.shapeSVGFile );

mShapeSizeCmbBx->setCurrentIndex( lyr.shapeSizeType );
mShapeSizeXSpnBx->setValue( lyr.shapeSize.x() );
mShapeSizeYSpnBx->setValue( lyr.shapeSize.y() );
mShapeSizeUnitsCmbBx->setCurrentIndex( lyr.shapeSizeUnits - 1 );
mShapeRotationCmbBx->setCurrentIndex( lyr.shapeRotationType );
mShapeRotationDblSpnBx->setEnabled( lyr.shapeRotationType != QgsPalLayerSettings::RotationSync );
mShapeRotationDDBtn->setEnabled( lyr.shapeRotationType != QgsPalLayerSettings::RotationSync );
mShapeRotationDblSpnBx->setValue( lyr.shapeRotation );
mShapeOffsetXSpnBx->setValue( lyr.shapeOffset.x() );
mShapeOffsetYSpnBx->setValue( lyr.shapeOffset.y() );
mShapeOffsetUnitsCmbBx->setCurrentIndex( lyr.shapeOffsetUnits - 1 );
mShapeRadiusXDbSpnBx->setValue( lyr.shapeRadii.x() );
mShapeRadiusYDbSpnBx->setValue( lyr.shapeRadii.y() );
mShapeRadiusUnitsCmbBx->setCurrentIndex( lyr.shapeRadiiUnits - 1 );

mShapeFillColorBtn->setColor( lyr.shapeFillColor );
mShapeBorderColorBtn->setColor( lyr.shapeBorderColor );
mShapeBorderWidthSpnBx->setValue( lyr.shapeBorderWidth );
mShapeBorderWidthUnitsCmbBx->setCurrentIndex( lyr.shapeBorderWidthUnits - 1 );
mShapePenStyleCmbBx->setPenJoinStyle( lyr.shapeJoinStyle );

mShapeTranspSpinBox->setValue( lyr.shapeTransparency );
mShapeBlendCmbBx->setBlendMode( lyr.shapeBlendMode );

mLoadSvgParams = false;
on_mShapeTypeCmbBx_currentIndexChanged( lyr.shapeType ); // force update of shape background gui

// drop shadow
mShadowDrawChkBx->setChecked( lyr.shadowDraw );
mShadowUnderCmbBx->setCurrentIndex( lyr.shadowUnder );
mShadowOffsetAngleSpnBx->setValue( lyr.shadowOffsetAngle );
mShadowOffsetSpnBx->setValue( lyr.shadowOffsetDist );
mShadowOffsetUnitsCmbBx->setCurrentIndex( lyr.shadowOffsetUnits - 1 );
mShadowOffsetGlobalChkBx->setChecked( lyr.shadowOffsetGlobal );

mShadowRadiusDblSpnBx->setValue( lyr.shadowRadius );
mShadowRadiusUnitsCmbBx->setCurrentIndex( lyr.shadowRadiusUnits - 1 );
mShadowRadiusAlphaChkBx->setChecked( lyr.shadowRadiusAlphaOnly );
mShadowTranspSpnBx->setValue( lyr.shadowTransparency );
mShadowScaleSpnBx->setValue( lyr.shadowScale );

mShadowColorBtn->setColor( lyr.shadowColor );
mShadowBlendCmbBx->setBlendMode( lyr.shadowBlendMode );

// do this after other widgets are configured, so they can be enabled/disabled
populateDataDefinedButtons( lyr );

if ( mCoordXDDBtn->isActive() && mCoordYDDBtn->isActive() )
{
enableDataDefinedAlignment();
}
if ( lyr.placement == QgsPalLayerSettings::Line || lyr.placement == QgsPalLayerSettings::Curved )
{
mLineDistanceSpnBx->setValue( lyr.dist );
mLineDistanceUnitComboBox->setCurrentIndex( distUnitIndex );
chkLineAbove->setChecked( lyr.placementFlags & QgsPalLayerSettings::AboveLine );
chkLineBelow->setChecked( lyr.placementFlags & QgsPalLayerSettings::BelowLine );
chkLineOn->setChecked( lyr.placementFlags & QgsPalLayerSettings::OnLine );
if ( !( lyr.placementFlags & QgsPalLayerSettings::MapOrientation ) )
chkLineOrientationDependent->setChecked( true );
}

mPrioritySlider->setValue( lyr.priority );
chkNoObstacle->setChecked( lyr.obstacle );
chkLabelPerFeaturePart->setChecked( lyr.labelPerPart );
mPalShowAllLabelsForLayerChkBx->setChecked( lyr.displayAll );
chkMergeLines->setChecked( lyr.mergeLines );
mMinSizeSpinBox->setValue( lyr.minFeatureSize );
mLimitLabelChkBox->setChecked( lyr.limitNumLabels );
mLimitLabelSpinBox->setValue( lyr.maxNumLabels );

// direction symbol(s)
mDirectSymbChkBx->setChecked( lyr.addDirectionSymbol );
mDirectSymbLeftLineEdit->setText( lyr.leftDirectionSymbol );
mDirectSymbRightLineEdit->setText( lyr.rightDirectionSymbol );
mDirectSymbRevChkBx->setChecked( lyr.reverseDirectionSymbol );

mDirectSymbBtnGrp->button(( int )lyr.placeDirectionSymbol )->setChecked( true );
mUpsidedownBtnGrp->button(( int )lyr.upsidedownLabels )->setChecked( true );

// curved label max character angles
mMaxCharAngleInDSpinBox->setValue( lyr.maxCurvedCharAngleIn );
// lyr.maxCurvedCharAngleOut must be negative, but it is shown as positive spinbox in GUI
mMaxCharAngleOutDSpinBox->setValue( qAbs( lyr.maxCurvedCharAngleOut ) );

wrapCharacterEdit->setText( lyr.wrapChar );
mFontLineHeightSpinBox->setValue( lyr.multilineHeight );
mFontMultiLineAlignComboBox->setCurrentIndex(( unsigned int ) lyr.multilineAlign );
chkPreserveRotation->setChecked( lyr.preserveRotation );

mPreviewBackgroundBtn->setColor( lyr.previewBkgrdColor );
setPreviewBackground( lyr.previewBkgrdColor );

mScaleBasedVisibilityChkBx->setChecked( lyr.scaleVisibility );
mScaleBasedVisibilityMinSpnBx->setValue( lyr.scaleMin );
mScaleBasedVisibilityMaxSpnBx->setValue( lyr.scaleMax );

// buffer
mBufferDrawChkBx->setChecked( lyr.bufferDraw );
spinBufferSize->setValue( lyr.bufferSize );
mBufferUnitComboBox->setCurrentIndex( lyr.bufferSizeInMapUnits ? 1 : 0 );
btnBufferColor->setColor( lyr.bufferColor );
mBufferTranspSpinBox->setValue( lyr.bufferTransp );
mBufferJoinStyleComboBox->setPenJoinStyle( lyr.bufferJoinStyle );
mBufferTranspFillChbx->setChecked( !lyr.bufferNoFill );
comboBufferBlendMode->setBlendMode( lyr.bufferBlendMode );

mFormatNumChkBx->setChecked( lyr.formatNumbers );
mFormatNumDecimalsSpnBx->setValue( lyr.decimals );
mFormatNumPlusSignChkBx->setChecked( lyr.plusSign );

// set pixel size limiting checked state before unit choice so limiting can be
// turned on as a default for map units, if minimum trigger value of 0 is used
mFontLimitPixelChkBox->setChecked( lyr.fontLimitPixelSize );
mMinPixelLimit = lyr.fontMinPixelSize; // ignored after first settings save
mFontMinPixelSpinBox->setValue( lyr.fontMinPixelSize == 0 ? 3 : lyr.fontMinPixelSize );
mFontMaxPixelSpinBox->setValue( lyr.fontMaxPixelSize );
mFontSizeUnitComboBox->setCurrentIndex( lyr.fontSizeInMapUnits ? 1 : 0 );

mRefFont = lyr.textFont;
mFontSizeSpinBox->setValue( lyr.textFont.pointSizeF() );
btnTextColor->setColor( lyr.textColor );
mFontTranspSpinBox->setValue( lyr.textTransp );
comboBlendMode->setBlendMode( lyr.blendMode );

mFontWordSpacingSpinBox->setValue( lyr.textFont.wordSpacing() );
mFontLetterSpacingSpinBox->setValue( lyr.textFont.letterSpacing() );

updateFontViaStyle( lyr.textNamedStyle );
updateFont( mRefFont );

// shape background
mShapeDrawChkBx->setChecked( lyr.shapeDraw );
mShapeTypeCmbBx->blockSignals( true );
mShapeTypeCmbBx->setCurrentIndex( lyr.shapeType );
mShapeTypeCmbBx->blockSignals( false );
mShapeSVGPathLineEdit->setText( lyr.shapeSVGFile );

mShapeSizeCmbBx->setCurrentIndex( lyr.shapeSizeType );
mShapeSizeXSpnBx->setValue( lyr.shapeSize.x() );
mShapeSizeYSpnBx->setValue( lyr.shapeSize.y() );
mShapeSizeUnitsCmbBx->setCurrentIndex( lyr.shapeSizeUnits - 1 );
mShapeRotationCmbBx->setCurrentIndex( lyr.shapeRotationType );
mShapeRotationDblSpnBx->setEnabled( lyr.shapeRotationType != QgsPalLayerSettings::RotationSync );
mShapeRotationDDBtn->setEnabled( lyr.shapeRotationType != QgsPalLayerSettings::RotationSync );
mShapeRotationDblSpnBx->setValue( lyr.shapeRotation );
mShapeOffsetXSpnBx->setValue( lyr.shapeOffset.x() );
mShapeOffsetYSpnBx->setValue( lyr.shapeOffset.y() );
mShapeOffsetUnitsCmbBx->setCurrentIndex( lyr.shapeOffsetUnits - 1 );
mShapeRadiusXDbSpnBx->setValue( lyr.shapeRadii.x() );
mShapeRadiusYDbSpnBx->setValue( lyr.shapeRadii.y() );
mShapeRadiusUnitsCmbBx->setCurrentIndex( lyr.shapeRadiiUnits - 1 );

mShapeFillColorBtn->setColor( lyr.shapeFillColor );
mShapeBorderColorBtn->setColor( lyr.shapeBorderColor );
mShapeBorderWidthSpnBx->setValue( lyr.shapeBorderWidth );
mShapeBorderWidthUnitsCmbBx->setCurrentIndex( lyr.shapeBorderWidthUnits - 1 );
mShapePenStyleCmbBx->setPenJoinStyle( lyr.shapeJoinStyle );

mShapeTranspSpinBox->setValue( lyr.shapeTransparency );
mShapeBlendCmbBx->setBlendMode( lyr.shapeBlendMode );

mLoadSvgParams = false;
on_mShapeTypeCmbBx_currentIndexChanged( lyr.shapeType ); // force update of shape background gui

// drop shadow
mShadowDrawChkBx->setChecked( lyr.shadowDraw );
mShadowUnderCmbBx->setCurrentIndex( lyr.shadowUnder );
mShadowOffsetAngleSpnBx->setValue( lyr.shadowOffsetAngle );
mShadowOffsetSpnBx->setValue( lyr.shadowOffsetDist );
mShadowOffsetUnitsCmbBx->setCurrentIndex( lyr.shadowOffsetUnits - 1 );
mShadowOffsetGlobalChkBx->setChecked( lyr.shadowOffsetGlobal );

mShadowRadiusDblSpnBx->setValue( lyr.shadowRadius );
mShadowRadiusUnitsCmbBx->setCurrentIndex( lyr.shadowRadiusUnits - 1 );
mShadowRadiusAlphaChkBx->setChecked( lyr.shadowRadiusAlphaOnly );
mShadowTranspSpnBx->setValue( lyr.shadowTransparency );
mShadowScaleSpnBx->setValue( lyr.shadowScale );

mShadowColorBtn->setColor( lyr.shadowColor );
mShadowBlendCmbBx->setBlendMode( lyr.shadowBlendMode );

updatePlacementWidgets();

// needs to come before data defined setup, so connections work
blockInitSignals( false );

// set up data defined toolbuttons
// do this after other widgets are configured, so they can be enabled/disabled
populateDataDefinedButtons( lyr );

enableDataDefinedAlignment( mCoordXDDBtn->isActive() && mCoordYDDBtn->isActive() );

updateUi(); // should come after data defined button setup
}


Expand All @@ -429,14 +441,22 @@ QgsLabelingGui::~QgsLabelingGui()
settings.setValue( QString( "/Windows/Labeling/Tab" ), mLabelingOptionsListWidget->currentRow() );
}

void QgsLabelingGui::blockInitSignals( bool block )
{
chkLineAbove->blockSignals( block );
chkLineBelow->blockSignals( block );
mPlacePointBtnGrp->blockSignals( block );
mPlaceLineBtnGrp->blockSignals( block );
mPlacePolygonBtnGrp->blockSignals( block );
}

void QgsLabelingGui::optionsStackedWidget_CurrentChanged( int indx )
{
mLabelingOptionsListWidget->blockSignals( true );
mLabelingOptionsListWidget->setCurrentRow( indx );
mLabelingOptionsListWidget->blockSignals( false );
}


void QgsLabelingGui::collapseSample( bool collapse )
{
if ( collapse )
Expand Down Expand Up @@ -1452,23 +1472,23 @@ void QgsLabelingGui::on_mCoordXDDBtn_dataDefinedActivated( bool active )
{
if ( !active ) //no data defined alignment without data defined position
{
disableDataDefinedAlignment();
enableDataDefinedAlignment( false );
}
else if ( mCoordYDDBtn->isActive() )
{
enableDataDefinedAlignment();
enableDataDefinedAlignment( true );
}
}

void QgsLabelingGui::on_mCoordYDDBtn_dataDefinedActivated( bool active )
{
if ( !active ) //no data defined alignment without data defined position
{
disableDataDefinedAlignment();
enableDataDefinedAlignment( false );
}
else if ( mCoordXDDBtn->isActive() )
{
enableDataDefinedAlignment();
enableDataDefinedAlignment( true );
}
}

Expand Down Expand Up @@ -1669,12 +1689,7 @@ void QgsLabelingGui::showBackgroundPenStyle( bool show )
mShapePenStyleDDBtn->setVisible( show );
}

void QgsLabelingGui::disableDataDefinedAlignment()
{
mCoordAlignmentFrame->setEnabled( false );
}

void QgsLabelingGui::enableDataDefinedAlignment()
void QgsLabelingGui::enableDataDefinedAlignment( bool enable )
{
mCoordAlignmentFrame->setEnabled( true );
mCoordAlignmentFrame->setEnabled( enable );
}
8 changes: 6 additions & 2 deletions src/app/qgslabelinggui.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class QgsLabelingGui : public QWidget, private Ui::QgsLabelingGuiBase
void on_mDirectSymbRightToolBtn_clicked();

protected:
void blockInitSignals( bool block );
void blockFontChangeSignals( bool blk );
void setPreviewBackground( QColor color );
void updateFontViaStyle( const QString & fontstyle );
Expand All @@ -106,6 +107,10 @@ class QgsLabelingGui : public QWidget, private Ui::QgsLabelingGuiBase
QButtonGroup* mDirectSymbBtnGrp;
QButtonGroup* mUpsidedownBtnGrp;

QButtonGroup* mPlacePointBtnGrp;
QButtonGroup* mPlaceLineBtnGrp;
QButtonGroup* mPlacePolygonBtnGrp;

// background reference font
QFont mRefFont;
int mPreviewSize;
Expand All @@ -114,8 +119,7 @@ class QgsLabelingGui : public QWidget, private Ui::QgsLabelingGuiBase

bool mLoadSvgParams;

void disableDataDefinedAlignment();
void enableDataDefinedAlignment();
void enableDataDefinedAlignment( bool enable );

private slots:
void optionsStackedWidget_CurrentChanged( int indx );
Expand Down
8 changes: 4 additions & 4 deletions src/core/qgsmaplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ bool QgsMapLayer::readLayerXML( const QDomElement& layerElement )
if ( !keywordListElem.isNull() )
{
QStringList kwdList;
for(QDomNode n = keywordListElem.firstChild(); !n.isNull(); n = n.nextSibling())
for ( QDomNode n = keywordListElem.firstChild(); !n.isNull(); n = n.nextSibling() )
{
kwdList << n.toElement().text();
}
Expand Down Expand Up @@ -486,13 +486,13 @@ bool QgsMapLayer::writeLayerXML( QDomElement& layerElement, QDomDocument& docume
layerElement.appendChild( layerName );
layerElement.appendChild( layerTitle );
layerElement.appendChild( layerAbstract );

// layer keyword list
QStringList keywordStringList = keywordList().split( "," );
if ( keywordStringList.size() > 0 )
{
QDomElement layerKeywordList = document.createElement( "keywordList" );
for (int i = 0; i < keywordStringList.size(); ++i)
for ( int i = 0; i < keywordStringList.size(); ++i )
{
QDomElement layerKeywordValue = document.createElement( "value" );
QDomText layerKeywordText = document.createTextNode( keywordStringList.at( i ).trimmed() );
Expand Down Expand Up @@ -942,7 +942,7 @@ QString QgsMapLayer::saveDefaultStyle( bool & theResultFlag )
return saveNamedStyle( styleURI(), theResultFlag );
}

QString QgsMapLayer:: saveNamedStyle( const QString theURI, bool & theResultFlag )
QString QgsMapLayer::saveNamedStyle( const QString theURI, bool & theResultFlag )
{
QString myErrorMessage;
QDomDocument myDocument;
Expand Down