Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 1ad7a788 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Have KRun start services instead of using KDesktopFileParser + QProcess

BUG: 402513
parent ae1e7105
add_executable(runservice main.cpp)
target_link_libraries(runservice KF5::Service KF5::KIOCore)
target_link_libraries(runservice KF5::Service KF5::KIOWidgets)
install(TARGETS runservice DESTINATION ${KDE_INSTALL_LIBEXECDIR_KF5}/discover)
......@@ -18,28 +18,27 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#include <QCoreApplication>
#include <QApplication>
#include <QFile>
#include <QTextStream>
#include <QUrl>
#include <QProcess>
#include <KService>
#include <KRun>
#include <KIO/DesktopExecParser>
int main(int argc, char** argv)
{
QCoreApplication app(argc, argv);
QApplication app(argc, argv);
if (app.arguments().size() != 2)
return 1;
KService _service(app.arguments().constLast());
if (!_service.isValid())
KService service(app.arguments().constLast());
if (!service.isValid())
return 2;
QTextStream cerr(stderr);
KIO::DesktopExecParser execParser(_service, {});
if (KRun::runApplication(service, {}, nullptr) == 0)
return 3;
auto args = execParser.resultingArguments();
const auto execName = args.takeFirst();
return !QProcess::startDetached(execName, args);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment