Add action info to the form d&d panel

This commit is contained in:
Alessandro Pasotti 2021-10-05 18:32:29 +02:00 committed by Nyall Dawson
parent c068d40a7a
commit 8cc230d8a0
4 changed files with 65 additions and 0 deletions

View File

@ -214,6 +214,13 @@ Sets an expression context scope to use for running the action.
Returns an expression context scope used for running the action.
.. versionadded:: 3.0
%End
QString html( ) const;
%Docstring
Returns an HTML table with the basic information about this action.
.. versionadded:: 3.24
%End
};

View File

@ -163,4 +163,53 @@ void QgsAction::setExpressionContextScope( const QgsExpressionContextScope &scop
QgsExpressionContextScope QgsAction::expressionContextScope() const
{
return mExpressionContextScope;
}
QString QgsAction::html() const
{
QString typeText;
switch ( mType )
{
case Generic:
{
typeText = QObject::tr( "Generic" );
break;
}
case GenericPython:
{
typeText = QObject::tr( "Generic Python" );
break;
}
case Mac:
{
typeText = QObject::tr( "Mac" );
break;
}
case Windows:
{
typeText = QObject::tr( "Windows" );
break;
}
case Unix:
{
typeText = QObject::tr( "Unix" );
break;
}
case OpenUrl:
{
typeText = QObject::tr( "Open URL" );
break;
}
}
return { QObject::tr( R"html(
<h2>Action Details</h2>
<p>
<b>Description:</b> %1<br>
<b>Short title:</b> %2<br>
<b>Type:</b> %3<br>
<b>Scope:</b> %4<br>
<b>Action:</b><br>
<pre>%6</pre>
</p>
)html" ).arg( mDescription, mShortTitle, typeText, actionScopes().values().join( QStringLiteral( ", " ) ), mCommand )};
};

View File

@ -247,6 +247,13 @@ class CORE_EXPORT QgsAction
*/
QgsExpressionContextScope expressionContextScope() const;
/**
* Returns an HTML table with the basic information about this action.
*
* \since QGIS 3.24
*/
QString html( ) const;
private:
ActionType mType = Generic;
QString mDescription;

View File

@ -589,6 +589,8 @@ void QgsAttributesFormProperties::loadAttributeSpecificEditor( QgsAttributesDnDT
case DnDTreeItemData::Action:
{
receiver->selectFirstMatchingItem( itemData );
const QgsAction action {mLayer->actions()->action( itemData.name() )};
loadInfoWidget( action.html() );
break;
}
case DnDTreeItemData::QmlWidget: