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.
This commit is contained in:
WarmUpTill
2021-11-21 17:35:05 +01:00
committed by WarmUpTill
parent ad08df3d2f
commit 51b4ef326d

View File

@@ -5,6 +5,7 @@
#include <QProcess>
#include <QFileDialog>
#include <QDesktopServices>
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;
}