Add "Skip hash check" option for watched folders

Closes #15388.
PR #15433.
This commit is contained in:
Vladimir Golovnev 2021-09-09 07:00:51 +03:00 committed by GitHub
parent 8f02fe0cc6
commit 90296b3ef0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 24 deletions

View file

@ -76,6 +76,7 @@ const QString PARAM_TAGS {QStringLiteral("tags")};
const QString PARAM_SAVEPATH {QStringLiteral("save_path")};
const QString PARAM_OPERATINGMODE {QStringLiteral("operating_mode")};
const QString PARAM_STOPPED {QStringLiteral("stopped")};
const QString PARAM_SKIPCHECKING {QStringLiteral("skip_checking")};
const QString PARAM_CONTENTLAYOUT {QStringLiteral("content_layout")};
const QString PARAM_AUTOTMM {QStringLiteral("use_auto_tmm")};
const QString PARAM_UPLOADLIMIT {QStringLiteral("upload_limit")};
@ -137,6 +138,7 @@ namespace
params.savePath = jsonObj.value(PARAM_SAVEPATH).toString();
params.addForced = (getEnum<BitTorrent::TorrentOperatingMode>(jsonObj, PARAM_OPERATINGMODE) == BitTorrent::TorrentOperatingMode::Forced);
params.addPaused = getOptionalBool(jsonObj, PARAM_STOPPED);
params.skipChecking = jsonObj.value(PARAM_SKIPCHECKING).toBool();
params.contentLayout = getOptionalEnum<BitTorrent::TorrentContentLayout>(jsonObj, PARAM_CONTENTLAYOUT);
params.useAutoTMM = getOptionalBool(jsonObj, PARAM_AUTOTMM);
params.uploadLimit = jsonObj.value(PARAM_UPLOADLIMIT).toInt(-1);
@ -155,6 +157,7 @@ namespace
{PARAM_SAVEPATH, params.savePath},
{PARAM_OPERATINGMODE, Utils::String::fromEnum(params.addForced
? BitTorrent::TorrentOperatingMode::Forced : BitTorrent::TorrentOperatingMode::AutoManaged)},
{PARAM_SKIPCHECKING, params.skipChecking},
{PARAM_UPLOADLIMIT, params.uploadLimit},
{PARAM_DOWNLOADLIMIT, params.downloadLimit},
{PARAM_SEEDINGTIMELIMIT, params.seedingTimeLimit},

View file

@ -61,6 +61,7 @@ WatchedFolderOptionsDialog::WatchedFolderOptionsDialog(
const auto *session = BitTorrent::Session::instance();
const BitTorrent::AddTorrentParams &torrentParams = watchedFolderOptions.addTorrentParams;
m_ui->startTorrentCheckBox->setChecked(!torrentParams.addPaused.value_or(session->isAddTorrentPaused()));
m_ui->skipCheckingCheckBox->setChecked(torrentParams.skipChecking);
m_ui->comboTTM->setCurrentIndex(torrentParams.useAutoTMM.value_or(!session->isAutoTMMDisabledByDefault()));
m_ui->contentLayoutComboBox->setCurrentIndex(
static_cast<int>(torrentParams.contentLayout.value_or(session->torrentContentLayout())));
@ -101,6 +102,7 @@ TorrentFilesWatcher::WatchedFolderOptions WatchedFolderOptionsDialog::watchedFol
params.savePath = m_ui->savePath->selectedPath();
params.category = m_ui->categoryComboBox->currentText();;
params.addPaused = !m_ui->startTorrentCheckBox->isChecked();
params.skipChecking = m_ui->skipCheckingCheckBox->isChecked();
params.contentLayout = static_cast<BitTorrent::TorrentContentLayout>(m_ui->contentLayoutComboBox->currentIndex());
return watchedFolderOptions;

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>462</width>
<height>306</height>
<height>325</height>
</rect>
</property>
<property name="windowTitle">
@ -163,30 +163,50 @@
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="startTorrentCheckBox">
<property name="text">
<string>Start torrent</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
<widget class="QCheckBox" name="startTorrentCheckBox">
<property name="text">
<string>Start torrent</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="skipCheckingLayout">
<item>
<widget class="QCheckBox" name="skipCheckingCheckBox">
<property name="text">
<string>Skip hash check</string>
</property>
</widget>
</item>
<item>
<spacer name="skipCheckingSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>