void QgsActionManager::runAction( const QgsAction &action ) { if ( action.type() == QgsAction::OpenUrl ) { QFileInfo finfo( action.command() ); if ( finfo.exists() && finfo.isFile() ) QDesktopServices::openUrl( QUrl::fromLocalFile( action.command() ) ); else QDesktopServices::openUrl( QUrl( action.command(), QUrl::TolerantMode ) ); } else if ( action.type() == QgsAction::GenericPython ) { // TODO: capture output from QgsPythonRunner (like QgsRunProcess does) QgsPythonRunner::run( action.command() ); } else { // The QgsRunProcess instance created by this static function // deletes itself when no longer needed. QgsRunProcess::create( action.command(), action.capture() ); } }
void QgsActionManager::doAction( const QUuid& actionId, const QgsFeature& feat, const QgsExpressionContext& context ) { QgsAction act = action( actionId ); if ( !act.isValid() || !act.runable() ) return; QgsExpressionContext actionContext( context ); if ( mLayer ) actionContext << QgsExpressionContextUtils::layerScope( mLayer ); actionContext.setFeature( feat ); QString expandedAction = QgsExpression::replaceExpressionText( act.command(), &actionContext ); if ( expandedAction.isEmpty() ) return; QgsAction newAction( act.type(), act.name(), expandedAction, act.capture() ); runAction( newAction ); }