Merge pull request #31734 from elpaso/bugfix-gh31428-text-formatting-enable-disable

Update bg and buffer status in text format widget
This commit is contained in:
Alessandro Pasotti 2019-09-13 11:01:17 +02:00 committed by GitHub
commit 4f9e4f121a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 6 deletions

View File

@ -472,6 +472,17 @@ void QgsTextFormatWidget::initWidget()
connect( mQuadrantBtnGrp, static_cast<void ( QButtonGroup::* )( int )>( &QButtonGroup::buttonClicked ), this, &QgsTextFormatWidget::updatePreview );
connect( mBufferDrawDDBtn, &QgsPropertyOverrideButton::activated, this, &QgsTextFormatWidget::updateBufferFrameStatus );
connect( mBufferDrawChkBx, &QCheckBox::stateChanged, [ = ]( int )
{
updateBufferFrameStatus();
} );
connect( mShapeDrawDDBtn, &QgsPropertyOverrideButton::activated, this, &QgsTextFormatWidget::updateShapeFrameStatus );
connect( mShapeDrawChkBx, &QCheckBox::stateChanged, [ = ]( int )
{
updateShapeFrameStatus();
} );
mGeometryGeneratorType->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPolygonLayer.svg" ) ), tr( "Polygon / MultiPolygon" ), QgsWkbTypes::GeometryType::PolygonGeometry );
mGeometryGeneratorType->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconLineLayer.svg" ) ), tr( "LineString / MultiLineString" ), QgsWkbTypes::GeometryType::LineGeometry );
mGeometryGeneratorType->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPointLayer.svg" ) ), tr( "Point / MultiPoint" ), QgsWkbTypes::GeometryType::PointGeometry );
@ -791,6 +802,7 @@ void QgsTextFormatWidget::updateWidgetForFormat( const QgsTextFormat &format )
// buffer
mBufferDrawChkBx->setChecked( buffer.enabled() );
mBufferFrame->setEnabled( buffer.enabled() );
spinBufferSize->setValue( buffer.size() );
mBufferUnitWidget->setUnit( buffer.sizeUnit() );
mBufferUnitWidget->setMapUnitScale( buffer.sizeMapUnitScale() );
@ -843,6 +855,7 @@ void QgsTextFormatWidget::updateWidgetForFormat( const QgsTextFormat &format )
// shape background
mShapeDrawChkBx->setChecked( background.enabled() );
mShapeFrame->setEnabled( background.enabled() || mBufferDrawDDBtn->isActive() );
mShapeTypeCmbBx->blockSignals( true );
mShapeTypeCmbBx->setCurrentIndex( mShapeTypeCmbBx->findData( background.type() ) );
mShapeTypeCmbBx->blockSignals( false );
@ -962,11 +975,11 @@ QgsTextFormat QgsTextFormatWidget::format( bool includeDataDefinedProperties ) c
background.setEnabled( mShapeDrawChkBx->isChecked() );
background.setType( static_cast< QgsTextBackgroundSettings::ShapeType >( mShapeTypeCmbBx->currentData().toInt() ) );
background.setSvgFile( mShapeSVGPathLineEdit->text() );
background.setSizeType( ( QgsTextBackgroundSettings::SizeType )mShapeSizeCmbBx->currentIndex() );
background.setSizeType( static_cast< QgsTextBackgroundSettings::SizeType >( mShapeSizeCmbBx->currentIndex() ) );
background.setSize( QSizeF( mShapeSizeXSpnBx->value(), mShapeSizeYSpnBx->value() ) );
background.setSizeUnit( mShapeSizeUnitWidget->unit() );
background.setSizeMapUnitScale( mShapeSizeUnitWidget->getMapUnitScale() );
background.setRotationType( ( QgsTextBackgroundSettings::RotationType )( mShapeRotationCmbBx->currentIndex() ) );
background.setRotationType( static_cast< QgsTextBackgroundSettings::RotationType >( mShapeRotationCmbBx->currentIndex() ) );
background.setRotation( mShapeRotationDblSpnBx->value() );
background.setOffset( QPointF( mShapeOffsetXSpnBx->value(), mShapeOffsetYSpnBx->value() ) );
background.setOffsetUnit( mShapeOffsetUnitWidget->unit() );
@ -1117,7 +1130,7 @@ void QgsTextFormatWidget::updateFont( const QFont &font )
blockFontChangeSignals( true );
mFontFamilyCmbBx->setCurrentFont( mRefFont );
populateFontStyleComboBox();
int idx = mFontCapitalsComboBox->findData( QVariant( ( unsigned int ) mRefFont.capitalization() ) );
int idx = mFontCapitalsComboBox->findData( QVariant( static_cast< unsigned int >( mRefFont.capitalization() ) ) );
mFontCapitalsComboBox->setCurrentIndex( idx == -1 ? 0 : idx );
mFontUnderlineBtn->setChecked( mRefFont.underline() );
mFontStrikethroughBtn->setChecked( mRefFont.strikeOut() );
@ -1304,7 +1317,7 @@ void QgsTextFormatWidget::mFontSizeSpinBox_valueChanged( double d )
void QgsTextFormatWidget::mFontCapitalsComboBox_currentIndexChanged( int index )
{
int capitalsindex = mFontCapitalsComboBox->itemData( index ).toInt();
mRefFont.setCapitalization( ( QFont::Capitalization ) capitalsindex );
mRefFont.setCapitalization( static_cast< QFont::Capitalization >( capitalsindex ) );
updateFont( mRefFont );
}
@ -1628,6 +1641,18 @@ void QgsTextFormatWidget::createAuxiliaryField()
emit auxiliaryFieldCreated();
}
void QgsTextFormatWidget::updateShapeFrameStatus()
{
mShapeFrame->setEnabled( mShapeDrawDDBtn->isActive() || mShapeDrawChkBx->isChecked() );
}
void QgsTextFormatWidget::updateBufferFrameStatus()
{
mBufferFrame->setEnabled( mBufferDrawDDBtn->isActive() || mBufferDrawChkBx->isChecked() );
}
void QgsTextFormatWidget::setFormatFromStyle( const QString &name, QgsStyle::StyleEntity type )
{
switch ( type )
@ -1722,8 +1747,8 @@ void QgsTextFormatWidget::mShapeSVGParamsBtn_clicked()
void QgsTextFormatWidget::mShapeRotationCmbBx_currentIndexChanged( int index )
{
mShapeRotationDblSpnBx->setEnabled( ( QgsTextBackgroundSettings::RotationType )index != QgsTextBackgroundSettings::RotationSync );
mShapeRotationDDBtn->setEnabled( ( QgsTextBackgroundSettings::RotationType )index != QgsTextBackgroundSettings::RotationSync );
mShapeRotationDblSpnBx->setEnabled( static_cast< QgsTextBackgroundSettings::RotationType >( index ) != QgsTextBackgroundSettings::RotationSync );
mShapeRotationDDBtn->setEnabled( static_cast< QgsTextBackgroundSettings::RotationType >( index ) != QgsTextBackgroundSettings::RotationSync );
}
void QgsTextFormatWidget::mPreviewTextEdit_textChanged( const QString &text )

View File

@ -297,6 +297,8 @@ class GUI_EXPORT QgsTextFormatWidget : public QWidget, public QgsExpressionConte
void updateAvailableShadowPositions();
void updateProperty();
void createAuxiliaryField();
void updateShapeFrameStatus();
void updateBufferFrameStatus();
};