Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[labeling] Prevent users from unselecting all line placement options
(fix #13007)
  • Loading branch information
nyalldawson committed Jul 12, 2015
1 parent f9917b5 commit c7138ff
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
27 changes: 27 additions & 0 deletions src/app/qgslabelinggui.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 )
Expand Down
3 changes: 2 additions & 1 deletion src/app/qgslabelinggui.h
Expand Up @@ -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 );

Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/ui/qgslabelingguibase.ui
Expand Up @@ -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>
Expand Down

0 comments on commit c7138ff

Please sign in to comment.