Merge pull request #3457 from Chocobo1/ext_param

Add more "Run External Program" parameters
This commit is contained in:
sledgehammer999 2015-07-29 23:17:19 +03:00
commit fce3a2d5c0
3 changed files with 55 additions and 45 deletions

View file

@ -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);
}

View file

@ -85,7 +85,7 @@
<string>Behavior</string>
</property>
<property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
<set>AlignCenter</set>
</property>
<property name="flags">
<set>ItemIsSelectable|ItemIsEnabled</set>
@ -96,7 +96,7 @@
<string>Downloads</string>
</property>
<property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
<set>AlignCenter</set>
</property>
<property name="flags">
<set>ItemIsSelectable|ItemIsEnabled</set>
@ -107,7 +107,7 @@
<string>Connection</string>
</property>
<property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
<set>AlignCenter</set>
</property>
<property name="flags">
<set>ItemIsSelectable|ItemIsEnabled</set>
@ -118,7 +118,7 @@
<string>Speed</string>
</property>
<property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
<set>AlignCenter</set>
</property>
<property name="flags">
<set>ItemIsSelectable|ItemIsEnabled</set>
@ -129,7 +129,7 @@
<string>BitTorrent</string>
</property>
<property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
<set>AlignCenter</set>
</property>
<property name="flags">
<set>ItemIsSelectable|ItemIsEnabled</set>
@ -140,7 +140,7 @@
<string>Web UI</string>
</property>
<property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
<set>AlignCenter</set>
</property>
<property name="flags">
<set>ItemIsSelectable|ItemIsEnabled</set>
@ -151,7 +151,7 @@
<string>Advanced</string>
</property>
<property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
<set>AlignCenter</set>
</property>
<property name="flags">
<set>ItemIsSelectable|ItemIsEnabled</set>
@ -520,7 +520,7 @@
<x>0</x>
<y>0</y>
<width>487</width>
<height>1005</height>
<height>965</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
@ -990,7 +990,7 @@
<item>
<widget class="QGroupBox" name="autoRunBox">
<property name="title">
<string>Run an external program on torrent completion</string>
<string>Run external program on torrent completion</string>
</property>
<property name="checkable">
<bool>true</bool>
@ -1003,18 +1003,7 @@
<widget class="QLineEdit" name="autoRun_txt"/>
</item>
<item>
<widget class="QLabel" name="label_4">
<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>
<widget class="QLabel" name="autoRun_param"/>
</item>
</layout>
</widget>
@ -1037,8 +1026,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>474</width>
<height>640</height>
<width>450</width>
<height>632</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_20">
@ -1545,8 +1534,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>474</width>
<height>438</height>
<width>376</width>
<height>431</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_33">
@ -1826,6 +1815,12 @@
<property name="wrapping">
<bool>true</bool>
</property>
<property name="displayFormat">
<string notr="true">hh:mm</string>
</property>
<property name="calendarPopup">
<bool>false</bool>
</property>
<property name="time">
<time>
<hour>8</hour>
@ -1833,12 +1828,6 @@
<second>0</second>
</time>
</property>
<property name="displayFormat">
<string notr="true">hh:mm</string>
</property>
<property name="calendarPopup">
<bool>false</bool>
</property>
</widget>
</item>
<item>
@ -1856,6 +1845,9 @@
<property name="wrapping">
<bool>true</bool>
</property>
<property name="displayFormat">
<string notr="true">hh:mm</string>
</property>
<property name="time">
<time>
<hour>20</hour>
@ -1863,9 +1855,6 @@
<second>0</second>
</time>
</property>
<property name="displayFormat">
<string notr="true">hh:mm</string>
</property>
</widget>
</item>
<item>
@ -1966,8 +1955,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>556</width>
<height>418</height>
<width>555</width>
<height>410</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
@ -2320,7 +2309,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>474</width>
<width>419</width>
<height>537</height>
</rect>
</property>
@ -2697,8 +2686,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>487</width>
<height>342</height>
<width>98</width>
<height>28</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_36"/>

View file

@ -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