Commit 7e3182fb authored by Maik Qualmann's avatar Maik Qualmann
Browse files

add support for environment variables to the runFiles() function

parent 62eda671
......@@ -208,10 +208,13 @@ bool FileOperation::runFiles(const QString& appCmd, const QList<QUrl>& urls, con
cmdList << QLatin1String("%f");
}
QString exec;
QStringList dirs;
QStringList files;
QStringList cmdArgs;
QString exec = cmdList.takeFirst();
QProcess* const process = new QProcess();
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
foreach(const QUrl& url, urls)
{
......@@ -221,6 +224,23 @@ bool FileOperation::runFiles(const QString& appCmd, const QList<QUrl>& urls, con
foreach(const QString& cmd, cmdList)
{
if (exec.isEmpty() && cmd.contains(QLatin1Char('=')))
{
QStringList envList = cmd.split(QLatin1Char('='), QString::SkipEmptyParts);
if (envList.count() == 2)
{
env.insert(envList[0], envList[1]);
}
continue;
}
else if (exec.isEmpty())
{
exec = cmd;
continue;
}
if (cmd == QLatin1String("%c"))
cmdArgs << name;
else if (cmd == QLatin1String("%i"))
......@@ -241,7 +261,10 @@ bool FileOperation::runFiles(const QString& appCmd, const QList<QUrl>& urls, con
cmdArgs << cmd;
}
return (QProcess::startDetached(exec, cmdArgs));
process->setProcessEnvironment(env);
process->start(exec, cmdArgs);
return process->waitForStarted();
}
KService::List FileOperation::servicesForOpenWith(const QList<QUrl>& urls)
......
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