From 19ccd8c7d3001a7405943f245f395f0dfbac4239 Mon Sep 17 00:00:00 2001 From: Thomas Piccirello Date: Wed, 17 Oct 2018 03:23:43 -0400 Subject: [PATCH] Add "When adding a torrent" options --- src/webui/api/appcontroller.cpp | 13 ++++++++++ .../www/private/preferences_content.html | 26 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/webui/api/appcontroller.cpp b/src/webui/api/appcontroller.cpp index 6a0d9e75e..cc170904b 100644 --- a/src/webui/api/appcontroller.cpp +++ b/src/webui/api/appcontroller.cpp @@ -52,6 +52,7 @@ #include "base/rss/rss_autodownloader.h" #include "base/rss/rss_session.h" #include "base/scanfoldersmodel.h" +#include "base/torrentfileguard.h" #include "base/utils/fs.h" #include "base/utils/net.h" #include "base/utils/password.h" @@ -84,6 +85,10 @@ void AppController::preferencesAction() QVariantMap data; // Downloads + // When adding a torrent + data["create_subfolder_enabled"] = session->isCreateTorrentSubfolder(); + data["start_paused_enabled"] = session->isAddTorrentPaused(); + data["auto_delete_mode"] = static_cast(TorrentFileGuard::autoDeleteMode()); data["preallocate_all"] = session->isPreallocationEnabled(); data["incomplete_files_ext"] = session->isAppendExtensionEnabled(); // Saving Management @@ -240,6 +245,14 @@ void AppController::setPreferencesAction() QVariantMap::ConstIterator it; // Downloads + // When adding a torrent + if ((it = m.find(QLatin1String("create_subfolder_enabled"))) != m.constEnd()) + session->setCreateTorrentSubfolder(it.value().toBool()); + if ((it = m.find(QLatin1String("start_paused_enabled"))) != m.constEnd()) + session->setAddTorrentPaused(it.value().toBool()); + if ((it = m.find(QLatin1String("auto_delete_mode"))) != m.constEnd()) + TorrentFileGuard::setAutoDeleteMode(static_cast(it.value().toInt())); + if ((it = m.find(QLatin1String("preallocate_all"))) != m.constEnd()) session->setPreallocationEnabled(it.value().toBool()); if ((it = m.find(QLatin1String("incomplete_files_ext"))) != m.constEnd()) diff --git a/src/webui/www/private/preferences_content.html b/src/webui/www/private/preferences_content.html index 3c7b75c76..c2451b70d 100644 --- a/src/webui/www/private/preferences_content.html +++ b/src/webui/www/private/preferences_content.html @@ -1,4 +1,20 @@
+
+ QBT_TR(When adding a torrent)QBT_TR[CONTEXT=OptionsDialog] +
+ + +
+
+ + +
+
+ + +
+
+
@@ -1026,6 +1042,11 @@ onSuccess: function(pref) { if (pref) { // Downloads tab + // When adding a torrent + $('createsubfolder_checkbox').setProperty('checked', pref.create_subfolder_enabled); + $('dontstartdownloads_checkbox').setProperty('checked', pref.start_paused_enabled); + $('deletetorrentfileafter_checkbox').setProperty('checked', pref.auto_delete_mode); + $('preallocateall_checkbox').setProperty('checked', pref.preallocate_all); $('appendext_checkbox').setProperty('checked', pref.incomplete_files_ext); @@ -1274,6 +1295,11 @@ var settings = new Hash(); // Validate form data // Downloads tab + // When adding a torrent + settings.set('create_subfolder_enabled', $('createsubfolder_checkbox').getProperty('checked')); + settings.set('start_paused_enabled', $('dontstartdownloads_checkbox').getProperty('checked')); + settings.set('auto_delete_mode', $('deletetorrentfileafter_checkbox').getProperty('checked')); + settings.set('preallocate_all', $('preallocateall_checkbox').getProperty('checked')); settings.set('incomplete_files_ext', $('appendext_checkbox').getProperty('checked'));