From e69f85782881a4b831ed97694263f027ecfa568d Mon Sep 17 00:00:00 2001 From: David Date: Sun, 7 Jan 2024 21:39:51 -0900 Subject: [PATCH] Allow to remember torrent content files deletion in WebUI Add a 'remember choice' button to the WebUI Torrent Deletion dialog that sets the default file deletion setting. The setting is shared with GUI, so if you set it in WebUI and open the Qt app, the 'delete files' checkbox will match WebUI (checked or unchecked). PR #20150. --------- Co-authored-by: Chocobo1 --- src/webui/api/appcontroller.cpp | 5 ++ src/webui/webapplication.h | 2 +- src/webui/www/.eslintrc.json | 2 +- src/webui/www/private/confirmdeletion.html | 61 ++++++++++++++++++- src/webui/www/private/css/style.css | 4 ++ .../www/private/images/object-locked.svg | 1 + src/webui/www/private/scripts/mocha-init.js | 16 ++--- src/webui/www/webui.qrc | 1 + 8 files changed, 81 insertions(+), 11 deletions(-) create mode 100644 src/webui/www/private/images/object-locked.svg diff --git a/src/webui/api/appcontroller.cpp b/src/webui/api/appcontroller.cpp index 4f917409a..49070f5ee 100644 --- a/src/webui/api/appcontroller.cpp +++ b/src/webui/api/appcontroller.cpp @@ -119,6 +119,8 @@ void AppController::preferencesAction() data[u"file_log_delete_old"_s] = app()->isFileLoggerDeleteOld(); data[u"file_log_age"_s] = app()->fileLoggerAge(); data[u"file_log_age_type"_s] = app()->fileLoggerAgeType(); + // Delete torrent contents files on torrent removal + data[u"delete_torrent_content_files"_s] = pref->deleteTorrentFilesAsDefault(); // Downloads // When adding a torrent @@ -494,6 +496,9 @@ void AppController::setPreferencesAction() app()->setFileLoggerAge(it.value().toInt()); if (hasKey(u"file_log_age_type"_s)) app()->setFileLoggerAgeType(it.value().toInt()); + // Delete torrent content files on torrent removal + if (hasKey(u"delete_torrent_content_files"_s)) + pref->setDeleteTorrentFilesAsDefault(it.value().toBool()); // Downloads // When adding a torrent diff --git a/src/webui/webapplication.h b/src/webui/webapplication.h index 15549eb5c..bdbe78e8d 100644 --- a/src/webui/webapplication.h +++ b/src/webui/webapplication.h @@ -53,7 +53,7 @@ #include "base/utils/version.h" #include "api/isessionmanager.h" -inline const Utils::Version<3, 2> API_VERSION {2, 10, 1}; +inline const Utils::Version<3, 2> API_VERSION {2, 10, 2}; class QTimer; diff --git a/src/webui/www/.eslintrc.json b/src/webui/www/.eslintrc.json index 92f607d69..315a4f82f 100644 --- a/src/webui/www/.eslintrc.json +++ b/src/webui/www/.eslintrc.json @@ -1,7 +1,7 @@ { "env": { "browser": true, - "es2020": true + "es2021": true }, "extends": "eslint:recommended", "plugins": [ diff --git a/src/webui/www/private/confirmdeletion.html b/src/webui/www/private/confirmdeletion.html index 6ce0174e8..2170d9b51 100644 --- a/src/webui/www/private/confirmdeletion.html +++ b/src/webui/www/private/confirmdeletion.html @@ -10,10 +10,67 @@