Skip to content

Commit

Permalink
Fix setEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Aug 16, 2021
1 parent 9772e95 commit 6de2f2d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
Expand Up @@ -48,6 +48,8 @@ Sets the ``action``.

virtual void setFeature( const QgsFeature &feature );

virtual void setEnabled( bool enabled );


};

Expand Down
8 changes: 8 additions & 0 deletions src/gui/editorwidgets/qgsactionwidgetwrapper.cpp
Expand Up @@ -33,6 +33,14 @@ void QgsActionWidgetWrapper::setFeature( const QgsFeature &feature )
mFeature = feature;
}

void QgsActionWidgetWrapper::setEnabled( bool enabled )
{
if ( valid() && layer() )
{
mActionButton->setEnabled( ! mAction.isEnabledOnlyWhenEditable() || enabled );
}
}

bool QgsActionWidgetWrapper::valid() const
{
return mAction.isValid() && mAction.runable();
Expand Down
1 change: 1 addition & 0 deletions src/gui/editorwidgets/qgsactionwidgetwrapper.h
Expand Up @@ -58,6 +58,7 @@ class GUI_EXPORT QgsActionWidgetWrapper : public QgsWidgetWrapper
public slots:

void setFeature( const QgsFeature &feature ) override;
void setEnabled( bool enabled ) override;

private:

Expand Down
8 changes: 6 additions & 2 deletions src/gui/qgsattributeform.cpp
Expand Up @@ -1348,8 +1348,8 @@ void QgsAttributeForm::synchronizeState()

for ( QgsWidgetWrapper *ww : std::as_const( mWidgets ) )
{
QgsEditorWidgetWrapper *eww = qobject_cast<QgsEditorWidgetWrapper *>( ww );
if ( eww )

if ( QgsEditorWidgetWrapper *eww = qobject_cast<QgsEditorWidgetWrapper *>( ww ); eww )
{
QgsAttributeFormEditorWidget *formWidget = mFormEditorWidgets.value( eww->fieldIdx() );

Expand All @@ -1363,6 +1363,10 @@ void QgsAttributeForm::synchronizeState()

updateIcon( eww );
}
else // handle QgsWidgetWrapper different than QgsEditorWidgetWrapper
{
ww->setEnabled( isEditable );
}
}

if ( mMode != QgsAttributeEditorContext::SearchMode )
Expand Down

0 comments on commit 6de2f2d

Please sign in to comment.