Add ability to run external program on torrent added

PR #17646.
This commit is contained in:
Vladimir Golovnev
2022-09-04 07:51:50 +03:00
committed by GitHub
parent 459d1cf82c
commit 4318de6dc5
8 changed files with 144 additions and 49 deletions

View File

@@ -601,7 +601,15 @@ void OptionsDialog::loadDownloadsTabOptions()
m_ui->mailNotifUsername->setText(pref->getMailNotificationSMTPUsername());
m_ui->mailNotifPassword->setText(pref->getMailNotificationSMTPPassword());
m_ui->autoRunBox->setChecked(pref->isAutoRunEnabled());
m_ui->groupBoxRunOnAdded->setChecked(pref->isAutoRunOnTorrentAddedEnabled());
m_ui->groupBoxRunOnFinished->setChecked(pref->isAutoRunOnTorrentFinishedEnabled());
m_ui->lineEditRunOnAdded->setText(pref->getAutoRunOnTorrentAddedProgram());
m_ui->lineEditRunOnFinished->setText(pref->getAutoRunOnTorrentFinishedProgram());
#if defined(Q_OS_WIN)
m_ui->autoRunConsole->setChecked(pref->isAutoRunConsoleEnabled());
#else
m_ui->autoRunConsole->hide();
#endif
const auto autoRunStr = u"%1\n %2\n %3\n %4\n %5\n %6\n %7\n %8\n %9\n %10\n %11\n %12\n %13\n%14"_qs
.arg(tr("Supported parameters (case sensitive):")
, tr("%N: Torrent name")
@@ -618,12 +626,6 @@ void OptionsDialog::loadDownloadsTabOptions()
, tr("%K: Torrent ID (either sha-1 info hash for v1 torrent or truncated sha-256 info hash for v2/hybrid torrent)")
, tr("Tip: Encapsulate parameter with quotation marks to avoid text being cut off at whitespace (e.g., \"%N\")"));
m_ui->labelAutoRunParam->setText(autoRunStr);
m_ui->lineEditAutoRun->setText(pref->getAutoRunProgram());
#if defined(Q_OS_WIN)
m_ui->autoRunConsole->setChecked(pref->isAutoRunConsoleEnabled());
#else
m_ui->autoRunConsole->hide();
#endif
connect(m_ui->checkAdditionDialog, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->checkAdditionDialogFront, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
@@ -674,7 +676,8 @@ void OptionsDialog::loadDownloadsTabOptions()
connect(m_ui->mailNotifPassword, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
connect(m_ui->autoRunBox, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->lineEditAutoRun, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
connect(m_ui->lineEditRunOnAdded, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
connect(m_ui->lineEditRunOnFinished, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
connect(m_ui->autoRunConsole, &QCheckBox::toggled, this, &ThisType::enableApplyButton);
}
@@ -726,8 +729,10 @@ void OptionsDialog::saveDownloadsTabOptions() const
pref->setMailNotificationSMTPUsername(m_ui->mailNotifUsername->text());
pref->setMailNotificationSMTPPassword(m_ui->mailNotifPassword->text());
pref->setAutoRunEnabled(m_ui->autoRunBox->isChecked());
pref->setAutoRunProgram(m_ui->lineEditAutoRun->text().trimmed());
pref->setAutoRunOnTorrentAddedEnabled(m_ui->groupBoxRunOnAdded->isChecked());
pref->setAutoRunOnTorrentAddedProgram(m_ui->lineEditRunOnAdded->text().trimmed());
pref->setAutoRunOnTorrentFinishedEnabled(m_ui->groupBoxRunOnFinished->isChecked());
pref->setAutoRunOnTorrentFinishedProgram(m_ui->lineEditRunOnFinished->text().trimmed());
#if defined(Q_OS_WIN)
pref->setAutoRunConsoleEnabled(m_ui->autoRunConsole->isChecked());
#endif

View File

@@ -1395,17 +1395,44 @@ readme[0-9].txt: filter 'readme1.txt', 'readme2.txt' but not 'readme10.txt'.</st
<item>
<widget class="QGroupBox" name="autoRunBox">
<property name="title">
<string>Run e&amp;xternal program on torrent completion</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
<string>Run external program</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_19">
<item>
<widget class="QLineEdit" name="lineEditAutoRun"/>
<widget class="QGroupBox" name="groupBoxRunOnAdded">
<property name="title">
<string>Run on torrent added</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_39">
<item>
<widget class="QLineEdit" name="lineEditRunOnAdded"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxRunOnFinished">
<property name="title">
<string>Run on torrent finished</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_36">
<item>
<widget class="QLineEdit" name="lineEditRunOnFinished"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="autoRunConsole">
@@ -3576,8 +3603,8 @@ Use ';' to split multiple entries. Can use wildcard '*'.</string>
<tabstop>mailNotifUsername</tabstop>
<tabstop>mailNotifPassword</tabstop>
<tabstop>checkSmtpSSL</tabstop>
<tabstop>autoRunBox</tabstop>
<tabstop>lineEditAutoRun</tabstop>
<tabstop>lineEditRunOnAdded</tabstop>
<tabstop>lineEditRunOnFinished</tabstop>
<tabstop>scrollArea_3</tabstop>
<tabstop>randomButton</tabstop>
<tabstop>checkMaxConnections</tabstop>