19#include "moc_qgsalgorithmurlopener.cpp"
24#include <QDesktopServices>
28QString QgsOpenUrlAlgorithm::name()
const
30 return QStringLiteral(
"openurl" );
33QString QgsOpenUrlAlgorithm::displayName()
const
35 return tr(
"Open file or URL" );
38QString QgsOpenUrlAlgorithm::shortDescription()
const
40 return tr(
"Opens files in their default associated application, or URLs in the user's default web browser." );
43QStringList QgsOpenUrlAlgorithm::tags()
const
45 return tr(
"open,url,internet,url,fetch,get,request,https,pdf,file" ).split(
',' );
48QString QgsOpenUrlAlgorithm::group()
const
50 return tr(
"File tools" );
53QString QgsOpenUrlAlgorithm::groupId()
const
55 return QStringLiteral(
"filetools" );
58QString QgsOpenUrlAlgorithm::shortHelpString()
const
60 return tr(
"This algorithm opens files in their default associated application, or URLs in the user's default web browser." );
63QgsOpenUrlAlgorithm *QgsOpenUrlAlgorithm::createInstance()
const
65 return new QgsOpenUrlAlgorithm();
68void QgsOpenUrlAlgorithm::initAlgorithm(
const QVariantMap & )
71 addOutput(
new QgsProcessingOutputBoolean( QStringLiteral(
"SUCCESS" ), QObject::tr(
"Successfully performed opening file or URL" ) ) );
76 const QString url = parameterAsString( parameters, QStringLiteral(
"URL" ), context );
79 const QUrl qurl = QUrl::fromUserInput( url );
81 const bool result = QDesktopServices::openUrl( qurl );
84 feedback->
pushInfo( QObject::tr(
"Successfully opened %1" ).arg( url ) );
86 feedback->
reportError( QObject::tr(
"Failed opening %1" ).arg( url ) );
89 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.