From 6721363f8cb78ddf75b18ddd58523eac51a08674 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 19 Jul 2015 16:04:25 +0800 Subject: [PATCH 1/3] Resave in Qt designer --- src/gui/options.ui | 50 +++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/gui/options.ui b/src/gui/options.ui index b6ea58855..0a659ece5 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 @@ -1037,8 +1037,8 @@ 0 0 - 474 - 640 + 450 + 632 @@ -1545,8 +1545,8 @@ 0 0 - 474 - 438 + 376 + 431 @@ -1826,6 +1826,12 @@ true + + hh:mm + + + false + - - hh:mm - - - false - @@ -1856,6 +1856,9 @@ true + + hh:mm + - - hh:mm - @@ -1966,8 +1966,8 @@ 0 0 - 556 - 418 + 555 + 410 @@ -2320,7 +2320,7 @@ 0 0 - 474 + 419 537 @@ -2697,8 +2697,8 @@ 0 0 - 487 - 342 + 98 + 28 From ff8f37b262e7e5b35b48cb0ef3d9caaed461d0d5 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 19 Jul 2015 16:37:02 +0800 Subject: [PATCH 2/3] Save trimmed string in preference --- src/app/application.cpp | 2 +- src/gui/options_imp.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/application.cpp b/src/app/application.cpp index 332082f5c..30072668f 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -139,7 +139,7 @@ void Application::torrentFinished(BitTorrent::TorrentHandle *const torrent) // AutoRun program if (pref->isAutoRunEnabled()) { - QString program = pref->getAutoRunProgram().trimmed(); + QString program = pref->getAutoRunProgram(); // Replace %f by torrent path program.replace("%f", torrent->savePathParsed()); // Replace %n by torrent name diff --git a/src/gui/options_imp.cpp b/src/gui/options_imp.cpp index 4b76ae595..8400bcedf 100644 --- a/src/gui/options_imp.cpp +++ b/src/gui/options_imp.cpp @@ -411,7 +411,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 From 3baec1c327930f239c654044646f402d2c97ffa7 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 19 Jul 2015 16:06:32 +0800 Subject: [PATCH 3/3] Add more "Run External Program" parameters, closes #3053, #238, #1291, #1522. --- src/app/application.cpp | 16 ++++++++++++---- src/gui/options.ui | 17 +++-------------- src/gui/options_imp.cpp | 13 +++++++++++++ 3 files changed, 28 insertions(+), 18 deletions(-) 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()));