mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-22 17:26:21 +03:00
parent
1bd499565e
commit
758ea7edca
1 changed files with 21 additions and 8 deletions
|
@ -563,6 +563,7 @@ void Application::runExternalProgram(const QString &programTemplate, const BitTo
|
||||||
};
|
};
|
||||||
|
|
||||||
const QString logMsg = tr("Running external program. Torrent: \"%1\". Command: `%2`");
|
const QString logMsg = tr("Running external program. Torrent: \"%1\". Command: `%2`");
|
||||||
|
const QString logMsgError = tr("Failed to run external program. Torrent: \"%1\". Command: `%2`");
|
||||||
|
|
||||||
// The processing sequenece is different for Windows and other OS, this is intentional
|
// The processing sequenece is different for Windows and other OS, this is intentional
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
|
@ -582,8 +583,6 @@ void Application::runExternalProgram(const QString &programTemplate, const BitTo
|
||||||
for (int i = 1; i < argCount; ++i)
|
for (int i = 1; i < argCount; ++i)
|
||||||
argList += QString::fromWCharArray(args[i]);
|
argList += QString::fromWCharArray(args[i]);
|
||||||
|
|
||||||
LogMsg(logMsg.arg(torrent->name(), program));
|
|
||||||
|
|
||||||
QProcess proc;
|
QProcess proc;
|
||||||
proc.setProgram(QString::fromWCharArray(args[0]));
|
proc.setProgram(QString::fromWCharArray(args[0]));
|
||||||
proc.setArguments(argList);
|
proc.setArguments(argList);
|
||||||
|
@ -608,7 +607,11 @@ void Application::runExternalProgram(const QString &programTemplate, const BitTo
|
||||||
args->startupInfo->hStdOutput = nullptr;
|
args->startupInfo->hStdOutput = nullptr;
|
||||||
args->startupInfo->hStdError = nullptr;
|
args->startupInfo->hStdError = nullptr;
|
||||||
});
|
});
|
||||||
proc.startDetached();
|
|
||||||
|
if (proc.startDetached())
|
||||||
|
LogMsg(logMsg.arg(torrent->name(), program));
|
||||||
|
else
|
||||||
|
LogMsg(logMsgError.arg(torrent->name(), program));
|
||||||
#else // Q_OS_WIN
|
#else // Q_OS_WIN
|
||||||
QStringList args = Utils::String::splitCommand(programTemplate);
|
QStringList args = Utils::String::splitCommand(programTemplate);
|
||||||
|
|
||||||
|
@ -624,11 +627,21 @@ void Application::runExternalProgram(const QString &programTemplate, const BitTo
|
||||||
arg = replaceVariables(arg);
|
arg = replaceVariables(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString command = args.takeFirst();
|
||||||
|
QProcess proc;
|
||||||
|
proc.setProgram(command);
|
||||||
|
proc.setArguments(args);
|
||||||
|
|
||||||
|
if (proc.startDetached())
|
||||||
|
{
|
||||||
// show intended command in log
|
// show intended command in log
|
||||||
LogMsg(logMsg.arg(torrent->name(), replaceVariables(programTemplate)));
|
LogMsg(logMsg.arg(torrent->name(), replaceVariables(programTemplate)));
|
||||||
|
}
|
||||||
const QString command = args.takeFirst();
|
else
|
||||||
QProcess::startDetached(command, args);
|
{
|
||||||
|
// show intended command in log
|
||||||
|
LogMsg(logMsgError.arg(torrent->name(), replaceVariables(programTemplate)));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -783,7 +796,7 @@ try
|
||||||
actionExit->setIcon(UIThemeManager::instance()->getIcon(u"application-exit"_qs));
|
actionExit->setIcon(UIThemeManager::instance()->getIcon(u"application-exit"_qs));
|
||||||
actionExit->setMenuRole(QAction::QuitRole);
|
actionExit->setMenuRole(QAction::QuitRole);
|
||||||
actionExit->setShortcut(Qt::CTRL | Qt::Key_Q);
|
actionExit->setShortcut(Qt::CTRL | Qt::Key_Q);
|
||||||
connect(actionExit, &QAction::triggered, this, [this]()
|
connect(actionExit, &QAction::triggered, this, []
|
||||||
{
|
{
|
||||||
QApplication::exit();
|
QApplication::exit();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue