mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-23 08:48:07 -06:00
Allow to move content files to Trash instead of deleting them
PR #20252.
This commit is contained in:
committed by
GitHub
parent
c5fa05299b
commit
4e27e88f6a
@@ -136,7 +136,7 @@ void AppController::preferencesAction()
|
||||
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();
|
||||
data[u"delete_torrent_content_files"_s] = pref->removeTorrentContent();
|
||||
|
||||
// Downloads
|
||||
// When adding a torrent
|
||||
@@ -350,6 +350,8 @@ void AppController::preferencesAction()
|
||||
// qBitorrent preferences
|
||||
// Resume data storage type
|
||||
data[u"resume_data_storage_type"_s] = Utils::String::fromEnum(session->resumeDataStorageType());
|
||||
// Torrent content removing mode
|
||||
data[u"torrent_content_remove_option"_s] = Utils::String::fromEnum(session->torrentContentRemoveOption());
|
||||
// Physical memory (RAM) usage limit
|
||||
data[u"memory_working_set_limit"_s] = app()->memoryWorkingSetLimit();
|
||||
// Current network interface
|
||||
@@ -519,7 +521,7 @@ void AppController::setPreferencesAction()
|
||||
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());
|
||||
pref->setRemoveTorrentContent(it.value().toBool());
|
||||
|
||||
// Downloads
|
||||
// When adding a torrent
|
||||
@@ -931,6 +933,9 @@ void AppController::setPreferencesAction()
|
||||
// Resume data storage type
|
||||
if (hasKey(u"resume_data_storage_type"_s))
|
||||
session->setResumeDataStorageType(Utils::String::toEnum(it.value().toString(), BitTorrent::ResumeDataStorageType::Legacy));
|
||||
// Torrent content removing mode
|
||||
if (hasKey(u"torrent_content_remove_option"_s))
|
||||
session->setTorrentContentRemoveOption(Utils::String::toEnum(it.value().toString(), BitTorrent::TorrentContentRemoveOption::MoveToTrash));
|
||||
// Physical memory (RAM) usage limit
|
||||
if (hasKey(u"memory_working_set_limit"_s))
|
||||
app()->setMemoryWorkingSetLimit(it.value().toInt());
|
||||
|
||||
@@ -1096,11 +1096,11 @@ void TorrentsController::deleteAction()
|
||||
requireParams({u"hashes"_s, u"deleteFiles"_s});
|
||||
|
||||
const QStringList hashes {params()[u"hashes"_s].split(u'|')};
|
||||
const DeleteOption deleteOption = parseBool(params()[u"deleteFiles"_s]).value_or(false)
|
||||
? DeleteTorrentAndFiles : DeleteTorrent;
|
||||
const BitTorrent::TorrentRemoveOption deleteOption = parseBool(params()[u"deleteFiles"_s]).value_or(false)
|
||||
? BitTorrent::TorrentRemoveOption::RemoveContent : BitTorrent::TorrentRemoveOption::KeepContent;
|
||||
applyToTorrents(hashes, [deleteOption](const BitTorrent::Torrent *torrent)
|
||||
{
|
||||
BitTorrent::Session::instance()->deleteTorrent(torrent->id(), deleteOption);
|
||||
BitTorrent::Session::instance()->removeTorrent(torrent->id(), deleteOption);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user