23#include <QDesktopServices>
26#include "moc_qgsalgorithmurlopener.cpp"
30QString QgsOpenUrlAlgorithm::name()
const
32 return QStringLiteral(
"openurl" );
35QString QgsOpenUrlAlgorithm::displayName()
const
37 return tr(
"Open file or URL" );
40QString QgsOpenUrlAlgorithm::shortDescription()
const
42 return tr(
"Opens files in their default associated application, or URLs in the user's default web browser." );
45QStringList QgsOpenUrlAlgorithm::tags()
const
47 return tr(
"open,url,internet,url,fetch,get,request,https,pdf,file" ).split(
',' );
50QString QgsOpenUrlAlgorithm::group()
const
52 return tr(
"File tools" );
55QString QgsOpenUrlAlgorithm::groupId()
const
57 return QStringLiteral(
"filetools" );
60QString QgsOpenUrlAlgorithm::shortHelpString()
const
62 return tr(
"This algorithm opens files in their default associated application, or URLs in the user's default web browser." );
65QgsOpenUrlAlgorithm *QgsOpenUrlAlgorithm::createInstance()
const
67 return new QgsOpenUrlAlgorithm();
70void QgsOpenUrlAlgorithm::initAlgorithm(
const QVariantMap & )
73 addOutput(
new QgsProcessingOutputBoolean( QStringLiteral(
"SUCCESS" ), QObject::tr(
"Successfully performed opening file or URL" ) ) );
78 const QString url = parameterAsString( parameters, QStringLiteral(
"URL" ), context );
81 const QUrl qurl = QUrl::fromUserInput( url );
83 const bool result = QDesktopServices::openUrl( qurl );
86 feedback->
pushInfo( QObject::tr(
"Successfully opened %1" ).arg( url ) );
88 feedback->
reportError( QObject::tr(
"Failed opening %1" ).arg( url ) );
91 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.