Add more "Run External Program" parameters, closes #3053, #238, #1291, #1522.

This commit is contained in:
Chocobo1 2015-07-19 16:06:32 +08:00
parent ff8f37b262
commit 3baec1c327
3 changed files with 28 additions and 18 deletions

View file

@ -140,10 +140,18 @@ void Application::torrentFinished(BitTorrent::TorrentHandle *const torrent)
// AutoRun program
if (pref->isAutoRunEnabled()) {
QString program = pref->getAutoRunProgram();
// Replace %f by torrent path
program.replace("%f", torrent->savePathParsed());
// Replace %n by torrent name
program.replace("%n", torrent->name());
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);
}