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 // AutoRun program
if (pref->isAutoRunEnabled()) { if (pref->isAutoRunEnabled()) {
QString program = pref->getAutoRunProgram().trimmed(); 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);
} }

View file

@ -85,7 +85,7 @@
<string>Behavior</string> <string>Behavior</string>
</property> </property>
<property name="textAlignment"> <property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set> <set>AlignCenter</set>
</property> </property>
<property name="flags"> <property name="flags">
<set>ItemIsSelectable|ItemIsEnabled</set> <set>ItemIsSelectable|ItemIsEnabled</set>
@ -96,7 +96,7 @@
<string>Downloads</string> <string>Downloads</string>
</property> </property>
<property name="textAlignment"> <property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set> <set>AlignCenter</set>
</property> </property>
<property name="flags"> <property name="flags">
<set>ItemIsSelectable|ItemIsEnabled</set> <set>ItemIsSelectable|ItemIsEnabled</set>
@ -107,7 +107,7 @@
<string>Connection</string> <string>Connection</string>
</property> </property>
<property name="textAlignment"> <property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set> <set>AlignCenter</set>
</property> </property>
<property name="flags"> <property name="flags">
<set>ItemIsSelectable|ItemIsEnabled</set> <set>ItemIsSelectable|ItemIsEnabled</set>
@ -118,7 +118,7 @@
<string>Speed</string> <string>Speed</string>
</property> </property>
<property name="textAlignment"> <property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set> <set>AlignCenter</set>
</property> </property>
<property name="flags"> <property name="flags">
<set>ItemIsSelectable|ItemIsEnabled</set> <set>ItemIsSelectable|ItemIsEnabled</set>
@ -129,7 +129,7 @@
<string>BitTorrent</string> <string>BitTorrent</string>
</property> </property>
<property name="textAlignment"> <property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set> <set>AlignCenter</set>
</property> </property>
<property name="flags"> <property name="flags">
<set>ItemIsSelectable|ItemIsEnabled</set> <set>ItemIsSelectable|ItemIsEnabled</set>
@ -140,7 +140,7 @@
<string>Web UI</string> <string>Web UI</string>
</property> </property>
<property name="textAlignment"> <property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set> <set>AlignCenter</set>
</property> </property>
<property name="flags"> <property name="flags">
<set>ItemIsSelectable|ItemIsEnabled</set> <set>ItemIsSelectable|ItemIsEnabled</set>
@ -151,7 +151,7 @@
<string>Advanced</string> <string>Advanced</string>
</property> </property>
<property name="textAlignment"> <property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set> <set>AlignCenter</set>
</property> </property>
<property name="flags"> <property name="flags">
<set>ItemIsSelectable|ItemIsEnabled</set> <set>ItemIsSelectable|ItemIsEnabled</set>
@ -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>
@ -1037,8 +1026,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>474</width> <width>450</width>
<height>640</height> <height>632</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_20"> <layout class="QVBoxLayout" name="verticalLayout_20">
@ -1545,8 +1534,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>474</width> <width>376</width>
<height>438</height> <height>431</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_33"> <layout class="QVBoxLayout" name="verticalLayout_33">
@ -1826,6 +1815,12 @@
<property name="wrapping"> <property name="wrapping">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="displayFormat">
<string notr="true">hh:mm</string>
</property>
<property name="calendarPopup">
<bool>false</bool>
</property>
<property name="time"> <property name="time">
<time> <time>
<hour>8</hour> <hour>8</hour>
@ -1833,12 +1828,6 @@
<second>0</second> <second>0</second>
</time> </time>
</property> </property>
<property name="displayFormat">
<string notr="true">hh:mm</string>
</property>
<property name="calendarPopup">
<bool>false</bool>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -1856,6 +1845,9 @@
<property name="wrapping"> <property name="wrapping">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="displayFormat">
<string notr="true">hh:mm</string>
</property>
<property name="time"> <property name="time">
<time> <time>
<hour>20</hour> <hour>20</hour>
@ -1863,9 +1855,6 @@
<second>0</second> <second>0</second>
</time> </time>
</property> </property>
<property name="displayFormat">
<string notr="true">hh:mm</string>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -1966,8 +1955,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>556</width> <width>555</width>
<height>418</height> <height>410</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_7"> <layout class="QVBoxLayout" name="verticalLayout_7">
@ -2320,7 +2309,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>474</width> <width>419</width>
<height>537</height> <height>537</height>
</rect> </rect>
</property> </property>
@ -2697,8 +2686,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>487</width> <width>98</width>
<height>342</height> <height>28</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_36"/> <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(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()));
@ -402,7 +415,7 @@ void options_imp::saveOptions() {
pref->setMailNotificationSMTPUsername(mailNotifUsername->text()); pref->setMailNotificationSMTPUsername(mailNotifUsername->text());
pref->setMailNotificationSMTPPassword(mailNotifPassword->text()); pref->setMailNotificationSMTPPassword(mailNotifPassword->text());
pref->setAutoRunEnabled(autoRunBox->isChecked()); pref->setAutoRunEnabled(autoRunBox->isChecked());
pref->setAutoRunProgram(autoRun_txt->text()); pref->setAutoRunProgram(autoRun_txt->text().trimmed());
pref->setActionOnDblClOnTorrentDl(getActionOnDblClOnTorrentDl()); pref->setActionOnDblClOnTorrentDl(getActionOnDblClOnTorrentDl());
pref->setActionOnDblClOnTorrentFn(getActionOnDblClOnTorrentFn()); pref->setActionOnDblClOnTorrentFn(getActionOnDblClOnTorrentFn());
// End Downloads preferences // End Downloads preferences