Skip to content
Permalink
Browse files

[labeling] Prevent users from unselecting all line placement options

(fix #13007)
  • Loading branch information
nyalldawson committed Jul 12, 2015
1 parent f9917b5 commit c7138ff815b3a4164021b4a1459a21c0ea4748a4
Showing with 32 additions and 1 deletion.
  1. +27 −0 src/app/qgslabelinggui.cpp
  2. +2 −1 src/app/qgslabelinggui.h
  3. +3 −0 src/ui/qgslabelingguibase.ui
@@ -121,6 +121,11 @@ QgsLabelingGui::QgsLabelingGui( QgsVectorLayer* layer, QgsMapCanvas* mapCanvas,
connect( mShadowTranspSpnBx, SIGNAL( valueChanged( int ) ), mShadowTranspSlider, SLOT( setValue( int ) ) );
connect( mLimitLabelChkBox, SIGNAL( toggled( bool ) ), mLimitLabelSpinBox, SLOT( setEnabled( bool ) ) );

//connections to prevent users removing all line placement positions
connect( chkLineAbove, SIGNAL( toggled( bool ) ), this, SLOT( updateLinePlacementOptions() ) );
connect( chkLineBelow, SIGNAL( toggled( bool ) ), this, SLOT( updateLinePlacementOptions() ) );
connect( chkLineOn, SIGNAL( toggled( bool ) ), this, SLOT( updateLinePlacementOptions() ) );

connect( btnEngineSettings, SIGNAL( clicked() ), this, SLOT( showEngineConfigDialog() ) );

// set placement methods page based on geometry type
@@ -491,6 +496,7 @@ void QgsLabelingGui::init()
mShadowBlendCmbBx->setBlendMode( lyr.shadowBlendMode );

updatePlacementWidgets();
updateLinePlacementOptions();

// needs to come before data defined setup, so connections work
blockInitSignals( false );
@@ -1541,6 +1547,27 @@ void QgsLabelingGui::on_mShapeSVGPathLineEdit_textChanged( const QString& text )
updateSvgWidgets( text );
}

void QgsLabelingGui::updateLinePlacementOptions()
{
int numOptionsChecked = ( chkLineAbove->isChecked() ? 1 : 0 ) +
( chkLineBelow->isChecked() ? 1 : 0 ) +
( chkLineOn->isChecked() ? 1 : 0 );

if ( numOptionsChecked == 1 )
{
//prevent unchecking last option
chkLineAbove->setEnabled( !chkLineAbove->isChecked() );
chkLineBelow->setEnabled( !chkLineBelow->isChecked() );
chkLineOn->setEnabled( !chkLineOn->isChecked() );
}
else
{
chkLineAbove->setEnabled( true );
chkLineBelow->setEnabled( true );
chkLineOn->setEnabled( true );
}
}

void QgsLabelingGui::updateSvgWidgets( const QString& svgPath )
{
if ( mShapeSVGPathLineEdit->text() != svgPath )
@@ -90,7 +90,7 @@ class APP_EXPORT QgsLabelingGui : public QWidget, private Ui::QgsLabelingGuiBase
void populatePlacementMethods();
void populateFieldNames();
void populateDataDefinedButtons( QgsPalLayerSettings& s );
/**Sets data defined property attribute to map */
/** Sets data defined property attribute to map */
void setDataDefinedProperty( const QgsDataDefinedButton* ddBtn, QgsPalLayerSettings::DataDefinedProperties p, QgsPalLayerSettings& lyr );
void updateFont( QFont font );

@@ -123,6 +123,7 @@ class APP_EXPORT QgsLabelingGui : public QWidget, private Ui::QgsLabelingGuiBase
void showBackgroundRadius( bool show );
void showBackgroundPenStyle( bool show );
void on_mShapeSVGPathLineEdit_textChanged( const QString& text );
void updateLinePlacementOptions();
};

#endif
@@ -3891,6 +3891,9 @@ font-style: italic;</string>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Allowed label placement for lines. At least one position must be selected.</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>

0 comments on commit c7138ff

Please sign in to comment.
You can’t perform that action at this time.