Merge pull request #3457 from Chocobo1/ext_param

Add more "Run External Program" parameters
This commit is contained in:
sledgehammer999 2015-07-29 23:17:19 +03:00
commit fce3a2d5c0
3 changed files with 55 additions and 45 deletions

View file

@ -140,11 +140,19 @@ void Application::torrentFinished(BitTorrent::TorrentHandle *const torrent)
// AutoRun program
if (pref->isAutoRunEnabled()) {
QString program = pref->getAutoRunProgram().trimmed();
// Replace %f by torrent path
program.replace("%f", torrent->savePathParsed());
// Replace %n by torrent name
program.replace("%n", torrent->name());
QString program = pref->getAutoRunProgram();
int file_count = torrent->filesCount();
program.replace("%N", torrent->name());
program.replace("%F", (file_count > 1) ? "" : torrent->fileName(0));
program.replace("%L", torrent->label());
program.replace("%D", torrent->rootPath());
program.replace("%K", (file_count > 1) ? "multi" : "single");
program.replace("%C", QString::number(torrent->filesCount()));
program.replace("%Z", QString::number(torrent->totalSize()));
program.replace("%T", torrent->currentTracker());
program.replace("%I", torrent->hash());
QProcess::startDetached(program);
}