From 51b4ef326d9154f266a6b2a172cce5cec015fad9 Mon Sep 17 00:00:00 2001 From: WarmUpTill Date: Sun, 21 Nov 2021 17:35:05 +0100 Subject: [PATCH] Add fallback using QDesktopServices::openUrl() for "run" action Users not familiar with launching processes with arguments might expect the run action to behave like clicking on icons on the desktop and be frustrated if the "file is not being opened". Thus introducing this fallback might help some users out. --- src/macro-action-run.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/macro-action-run.cpp b/src/macro-action-run.cpp index 4cfdefe0..e23d4c7c 100644 --- a/src/macro-action-run.cpp +++ b/src/macro-action-run.cpp @@ -5,6 +5,7 @@ #include #include +#include const std::string MacroActionRun::id = "run"; @@ -14,7 +15,13 @@ bool MacroActionRun::_registered = MacroActionFactory::Register( bool MacroActionRun::PerformAction() { - QProcess::startDetached(QString::fromStdString(_path), _args); + if (!QProcess::startDetached(QString::fromStdString(_path), _args) && + _args.empty()) { + vblog(LOG_INFO, "run \"%s\" using QDesktopServices", + _path.c_str()); + QDesktopServices::openUrl( + QUrl::fromLocalFile(QString::fromStdString(_path))); + } return true; }