plasma: blind-start services via KRun from kickoff menu

KRun will show message box if exec fails (it uses KToolInvocation itself
and checks the return value) and the menu will not be blocked while the
application is starting

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-12-17 17:22:58 +02:00
parent f3e5025c2f
commit ce614f2297

View file

@ -27,7 +27,7 @@
#include <KDebug> #include <KDebug>
#include <KJob> #include <KJob>
#include <KService> #include <KService>
#include <KToolInvocation> #include <KRun>
#include <KUrl> #include <KUrl>
#include <Solid/PowerManagement> #include <Solid/PowerManagement>
@ -48,20 +48,17 @@ using namespace Kickoff;
bool ServiceItemHandler::openUrl(const KUrl& url) bool ServiceItemHandler::openUrl(const KUrl& url)
{ {
int result = KToolInvocation::startServiceByDesktopPath(url.pathOrUrl(), QStringList(), 0, 0, 0, "", true); KService::Ptr service = KService::serviceByDesktopPath(url.pathOrUrl());
if (result == 0) { if (!service.isNull()) {
KService::Ptr service = KService::serviceByDesktopPath(url.pathOrUrl()); RecentApplications::self()->add(service);
} else {
if (!service.isNull()) { qWarning() << "Failed to find service for" << url;
RecentApplications::self()->add(service); return false;
} else {
qWarning() << "Failed to find service for" << url;
return false;
}
} }
return result == 0; new KRun(url, 0);
return true;
} }
bool LeaveItemHandler::openUrl(const KUrl& url) bool LeaveItemHandler::openUrl(const KUrl& url)