mirror of
				https://github.com/qgis/QGIS.git
				synced 2025-11-04 00:04:25 -05:00 
			
		
		
		
	Add action info to the form d&d panel
This commit is contained in:
		
							parent
							
								
									c068d40a7a
								
							
						
					
					
						commit
						8cc230d8a0
					
				@ -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
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -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 )};
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -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;
 | 
			
		||||
 | 
			
		||||
@ -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:
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user