diff --git a/src/app/application.cpp b/src/app/application.cpp index c8322a25e..59db710ad 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -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); } diff --git a/src/gui/options.ui b/src/gui/options.ui index b6ea58855..5bdfc2fa9 100644 --- a/src/gui/options.ui +++ b/src/gui/options.ui @@ -85,7 +85,7 @@ Behavior - AlignHCenter|AlignVCenter|AlignCenter + AlignCenter ItemIsSelectable|ItemIsEnabled @@ -96,7 +96,7 @@ Downloads - AlignHCenter|AlignVCenter|AlignCenter + AlignCenter ItemIsSelectable|ItemIsEnabled @@ -107,7 +107,7 @@ Connection - AlignHCenter|AlignVCenter|AlignCenter + AlignCenter ItemIsSelectable|ItemIsEnabled @@ -118,7 +118,7 @@ Speed - AlignHCenter|AlignVCenter|AlignCenter + AlignCenter ItemIsSelectable|ItemIsEnabled @@ -129,7 +129,7 @@ BitTorrent - AlignHCenter|AlignVCenter|AlignCenter + AlignCenter ItemIsSelectable|ItemIsEnabled @@ -140,7 +140,7 @@ Web UI - AlignHCenter|AlignVCenter|AlignCenter + AlignCenter ItemIsSelectable|ItemIsEnabled @@ -151,7 +151,7 @@ Advanced - AlignHCenter|AlignVCenter|AlignCenter + AlignCenter ItemIsSelectable|ItemIsEnabled @@ -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 - - + @@ -1037,8 +1026,8 @@ 0 0 - 474 - 640 + 450 + 632 @@ -1545,8 +1534,8 @@ 0 0 - 474 - 438 + 376 + 431 @@ -1826,6 +1815,12 @@ true + + hh:mm + + + false + - - hh:mm - - - false - @@ -1856,6 +1845,9 @@ true + + hh:mm + - - hh:mm - @@ -1966,8 +1955,8 @@ 0 0 - 556 - 418 + 555 + 410 @@ -2320,7 +2309,7 @@ 0 0 - 474 + 419 537 @@ -2697,8 +2686,8 @@ 0 0 - 487 - 342 + 98 + 28 diff --git a/src/gui/options_imp.cpp b/src/gui/options_imp.cpp index baddc6277..6a64f1944 100644 --- a/src/gui/options_imp.cpp +++ b/src/gui/options_imp.cpp @@ -178,6 +178,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())); @@ -402,7 +415,7 @@ void options_imp::saveOptions() { pref->setMailNotificationSMTPUsername(mailNotifUsername->text()); pref->setMailNotificationSMTPPassword(mailNotifPassword->text()); pref->setAutoRunEnabled(autoRunBox->isChecked()); - pref->setAutoRunProgram(autoRun_txt->text()); + pref->setAutoRunProgram(autoRun_txt->text().trimmed()); pref->setActionOnDblClOnTorrentDl(getActionOnDblClOnTorrentDl()); pref->setActionOnDblClOnTorrentFn(getActionOnDblClOnTorrentFn()); // End Downloads preferences