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