23#include <QDesktopServices>
27QString QgsOpenUrlAlgorithm::name()
const
29 return QStringLiteral(
"openurl" );
32QString QgsOpenUrlAlgorithm::displayName()
const
34 return tr(
"Open file or URL" );
37QString QgsOpenUrlAlgorithm::shortDescription()
const
39 return tr(
"Opens files in their default associated application, or URLs in the user's default web browser." );
42QStringList QgsOpenUrlAlgorithm::tags()
const
44 return tr(
"open,url,internet,url,fetch,get,request,https,pdf,file" ).split(
',' );
47QString QgsOpenUrlAlgorithm::group()
const
49 return tr(
"File tools" );
52QString QgsOpenUrlAlgorithm::groupId()
const
54 return QStringLiteral(
"filetools" );
57QString QgsOpenUrlAlgorithm::shortHelpString()
const
59 return tr(
"This algorithm opens files in their default associated application, or URLs in the user's default web browser." );
62QgsOpenUrlAlgorithm *QgsOpenUrlAlgorithm::createInstance()
const
64 return new QgsOpenUrlAlgorithm();
67void QgsOpenUrlAlgorithm::initAlgorithm(
const QVariantMap & )
70 addOutput(
new QgsProcessingOutputBoolean( QStringLiteral(
"SUCCESS" ), QObject::tr(
"Successfully performed opening file or URL" ) ) );
75 const QString url = parameterAsString( parameters, QStringLiteral(
"URL" ), context );
78 const QUrl qurl = QUrl::fromUserInput( url );
80 const bool result = QDesktopServices::openUrl( qurl );
83 feedback->
pushInfo( QObject::tr(
"Successfully opened %1" ).arg( url ) );
85 feedback->
reportError( QObject::tr(
"Failed opening %1" ).arg( url ) );
88 outputs.insert( QStringLiteral(
"SUCCESS" ), result );
Contains information about the context in which a processing algorithm is executed.
Custom exception class for processing related exceptions.
Base class for providing feedback from a processing algorithm.
virtual void pushInfo(const QString &info)
Pushes a general informational message from the algorithm.
virtual void reportError(const QString &error, bool fatalError=false)
Reports that the algorithm encountered an error while executing.
A boolean output for processing algorithms.
A string parameter for processing algorithms.