KIO::DesktopExecParser Class
class KIO::DesktopExecParserParses the Exec= line from a .desktop file, and process all the '%' placeholders, e.g. handling URLs vs local files. More...
Header: | #include <KIO/DesktopExecParser> |
CMake: | find_package(KF6 REQUIRED COMPONENTS KIO) target_link_libraries(mytarget PRIVATE KF6::KIOCore) |
Since: | 5.0 |
Public Functions
DesktopExecParser(const KService &service, const QList<QUrl> &urls) | |
(since 5.71) QString | errorMessage() const |
QStringList | resultingArguments() const |
void | setSuggestedFileName(const QString &suggestedFileName) |
void | setUrlsAreTempFiles(bool tempFiles) |
Static Public Members
QString | executableName(const QString &execLine) |
QString | executablePath(const QString &execLine) |
bool | hasSchemeHandler(const QUrl &url) |
bool | isProtocolInSupportedList(const QUrl &url, const QStringList &supportedProtocols) |
QStringList | supportedProtocols(const KService &service) |
Detailed Description
The processing actually happens when calling resultingArguments(), after setting everything up.
Member Function Documentation
DesktopExecParser::DesktopExecParser(const KService &service, const QList<QUrl> &urls)
Creates a parser for a desktop file Exec line.
service the service to extract information from. The KService instance must remain alive as long as the parser is alive.
urls The urls the service should open.
[since 5.71]
QString DesktopExecParser::errorMessage() const
Returns an error message for when resultingArguments() returns an empty list
This function was introduced in 5.71.
[static]
QString DesktopExecParser::executableName(const QString &execLine)
Given a full command line (e.g. the Exec= line from a .desktop file), extract the name of the executable being run (removing the path, if specified).
execLine the full command line
Returns the name of the executable to run, example: "ls"
[static]
QString DesktopExecParser::executablePath(const QString &execLine)
Given a full command line (e.g. the Exec= line from a .desktop file), extract the name of the executable being run, including its full path, if specified.
execLine the full command line
Returns the name of the executable to run, example: "/bin/ls"
[static]
bool DesktopExecParser::hasSchemeHandler(const QUrl &url)
Returns true if protocol should be opened by a "handler" application, i.e. an application associated to _all_ URLs using this protocol (a.k.a. scheme).
[static]
bool DesktopExecParser::isProtocolInSupportedList(const QUrl &url, const QStringList &supportedProtocols)
Returns true if protocol is in the list of protocols returned by supportedProtocols(). The only reason for this method is the special handling of "KIO".
QStringList DesktopExecParser::resultingArguments() const
Returns a list of arguments suitable for QProcess. Returns an empty list on error, check errorMessage() for details.
void DesktopExecParser::setSuggestedFileName(const QString &suggestedFileName)
Sets the file name to use in the case of downloading the file to a tempfile in order to give to a non-url-aware application. Some apps rely on the extension to determine the MIME type of the file. Usually the file name comes from the URL, but in the case of the HTTP Content-Disposition header, we need to override the file name.
void DesktopExecParser::setUrlsAreTempFiles(bool tempFiles)
If tempFiles is set to true and the urls given to the constructor are local files, they will be deleted when the application exits.
[static]
QStringList DesktopExecParser::supportedProtocols(const KService &service)
Returns the list of protocols which the application supports. This can be a list of actual protocol names, or just "KIO" for KIO-based apps.