Skip to content

Commit

Permalink
Clicking the label obstacle QLabel should toggle the checkbox, just l…
Browse files Browse the repository at this point in the history
…ike a normal checkbox label...
  • Loading branch information
nyalldawson committed Sep 1, 2020
1 parent 4cd40ab commit 9e67b05
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/gui/labeling/qgslabelinggui.cpp
Expand Up @@ -283,6 +283,8 @@ QgsLabelingGui::QgsLabelingGui( QgsVectorLayer *layer, QgsMapCanvas *mapCanvas,

connect( mCalloutStyleComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLabelingGui::calloutTypeChanged );

mLblNoObstacle1->installEventFilter( this );

setLayer( layer );
}

Expand Down Expand Up @@ -630,6 +632,21 @@ void QgsLabelingGui::syncDefinedCheckboxFrame( QgsPropertyOverrideButton *ddBtn,
f->setEnabled( chkBx->isChecked() );
}

bool QgsLabelingGui::eventFilter( QObject *object, QEvent *event )
{
if ( object == mLblNoObstacle1 )
{
if ( event->type() == QEvent::MouseButtonPress && dynamic_cast< QMouseEvent * >( event )->button() == Qt::LeftButton )
{
// clicking the obstacle label toggles the checkbox, just like a "normal" checkbox label...
mChkNoObstacle->setChecked( !mChkNoObstacle->isChecked() );
return true;
}
return false;
}
return QgsTextFormatWidget::eventFilter( object, event );
}

void QgsLabelingGui::updateUi()
{
// enable/disable inline groupbox-like setups (that need to honor data defined setting)
Expand Down
1 change: 1 addition & 0 deletions src/gui/labeling/qgslabelinggui.h
Expand Up @@ -65,6 +65,7 @@ class GUI_EXPORT QgsLabelingGui : public QgsTextFormatWidget
protected:
void blockInitSignals( bool block );
void syncDefinedCheckboxFrame( QgsPropertyOverrideButton *ddBtn, QCheckBox *chkBx, QFrame *f );
bool eventFilter( QObject *object, QEvent *event ) override;

private slots:

Expand Down

0 comments on commit 9e67b05

Please sign in to comment.