Browse Source

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

adaptive-webui-19844
Chocobo1 9 years ago
parent
commit
3baec1c327
  1. 16
      src/app/application.cpp
  2. 17
      src/gui/options.ui
  3. 13
      src/gui/options_imp.cpp

16
src/app/application.cpp

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

17
src/gui/options.ui

@ -520,7 +520,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>487</width> <width>487</width>
<height>1005</height> <height>965</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
@ -990,7 +990,7 @@
<item> <item>
<widget class="QGroupBox" name="autoRunBox"> <widget class="QGroupBox" name="autoRunBox">
<property name="title"> <property name="title">
<string>Run an external program on torrent completion</string> <string>Run external program on torrent completion</string>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
@ -1003,18 +1003,7 @@
<widget class="QLineEdit" name="autoRun_txt"/> <widget class="QLineEdit" name="autoRun_txt"/>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="autoRun_param"/>
<property name="text">
<string>The following parameters are supported:
&lt;ul&gt;
&lt;li&gt;%f: Torrent path&lt;/li&gt;
&lt;li&gt;%n: Torrent name&lt;/li&gt;
&lt;/ul&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>

13
src/gui/options_imp.cpp

@ -180,6 +180,19 @@ options_imp::options_imp(QWidget *parent):
connect(mailNotifPassword, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton())); connect(mailNotifPassword, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
connect(autoRunBox, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(autoRunBox, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(autoRun_txt, SIGNAL(textChanged(QString)), 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 // Connection tab
connect(spinPort, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); connect(spinPort, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(checkRandomPort, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkRandomPort, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));

Loading…
Cancel
Save