diff --git a/src/qmlcontrols/kioplugin/krunproxy.h b/src/qmlcontrols/kioplugin/krunproxy.h --- a/src/qmlcontrols/kioplugin/krunproxy.h +++ b/src/qmlcontrols/kioplugin/krunproxy.h @@ -33,6 +33,13 @@ * opens the url from the existing file */ Q_INVOKABLE bool openUrl(const QString &filePath); + + /** + * Runs the service (application) + * @param serviceName the name of the desktop file without extension + * @return true on success + */ + Q_INVOKABLE bool openService(const QString &serviceName); }; #endif diff --git a/src/qmlcontrols/kioplugin/krunproxy.cpp b/src/qmlcontrols/kioplugin/krunproxy.cpp --- a/src/qmlcontrols/kioplugin/krunproxy.cpp +++ b/src/qmlcontrols/kioplugin/krunproxy.cpp @@ -41,12 +41,20 @@ } if (fileMymeType == QStringLiteral("application/x-desktop")) { - // If our mimetype is a desktop file, then we don't won't to open + // If our mimetype is a desktop file, then we don't want to open // the desktop file itself but the application in which it is associated // with. KService::Ptr service = KService::serviceByDesktopPath(filePath); return KRun::runService(*service, QList(), nullptr) != 0; } else { return KRun::runUrl(QUrl(filePath), fileMymeType, nullptr); } } + +bool KRunProxy::openService(const QString &serviceName) +{ + KService::Ptr service = KService::serviceByDesktopName(serviceName); + if(service) + return KRun::runApplication(*service, QList(), nullptr) != 0; + return false; +}