diff --git a/src/app/application.cpp b/src/app/application.cpp index 30072668f..6ef487b5d 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -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); } diff --git a/src/gui/options.ui b/src/gui/options.ui index 0a659ece5..5bdfc2fa9 100644 --- a/src/gui/options.ui +++ b/src/gui/options.ui @@ -520,7 +520,7 @@ 0 0 487 - 1005 + 965 @@ -990,7 +990,7 @@ - Run an external program on torrent completion + Run external program on torrent completion true @@ -1003,18 +1003,7 @@ - - - The following parameters are supported: -<ul> -<li>%f: Torrent path</li> -<li>%n: Torrent name</li> -</ul> - - - Qt::RichText - - + diff --git a/src/gui/options_imp.cpp b/src/gui/options_imp.cpp index 8400bcedf..5a8050170 100644 --- a/src/gui/options_imp.cpp +++ b/src/gui/options_imp.cpp @@ -180,6 +180,19 @@ options_imp::options_imp(QWidget *parent): connect(mailNotifPassword, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton())); connect(autoRunBox, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(autoRun_txt, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton())); + + autoRun_param->setText(QString::fromUtf8("%1\n %2\n %3\n %4\n %5\n %6\n %7\n %8\n %9\n %10") + .arg(tr("Supported parameters (case sensitive):")) + .arg(tr("%N: Torrent name")) + .arg(tr("%F: Downloaded file name (single-file torrent only)")) + .arg(tr("%L: Label")) + .arg(tr("%D: Save path")) + .arg(tr("%K: \"single\"|\"multi\" file(s)")) + .arg(tr("%C: Number of files")) + .arg(tr("%Z: Torrent size (bytes)")) + .arg(tr("%T: Current tracker")) + .arg(tr("%I: Info hash"))); + // Connection tab connect(spinPort, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); connect(checkRandomPort, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));