From d46343fb9c8a5474db4775b5d811f2306e147bfe Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 26 Nov 2020 15:48:44 +0800 Subject: [PATCH] Add ability to use 'shift+delete' to delete torrents in WebUI Closes #13827. --- src/webui/www/private/confirmdeletion.html | 3 +++ src/webui/www/private/scripts/client.js | 4 ++++ src/webui/www/private/scripts/mocha-init.js | 4 ++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/webui/www/private/confirmdeletion.html b/src/webui/www/private/confirmdeletion.html index 34334ebd4..60aa45f16 100644 --- a/src/webui/www/private/confirmdeletion.html +++ b/src/webui/www/private/confirmdeletion.html @@ -11,6 +11,9 @@ 'use strict'; window.addEvent('domready', function() { + const isDeletingFiles = (new URI().getData('deleteFiles') === "true"); + $('deleteFromDiskCB').checked = isDeletingFiles; + const hashes = new URI().getData('hashes').split('|'); $('cancelBtn').focus(); $('cancelBtn').addEvent('click', function(e) { diff --git a/src/webui/www/private/scripts/client.js b/src/webui/www/private/scripts/client.js index d30967b45..4600f40fa 100644 --- a/src/webui/www/private/scripts/client.js +++ b/src/webui/www/private/scripts/client.js @@ -1225,6 +1225,10 @@ new Keyboard({ 'delete': function(event) { deleteFN(); event.preventDefault(); + }, + 'shift+delete': (event) => { + deleteFN(true); + event.preventDefault(); } } }).activate(); diff --git a/src/webui/www/private/scripts/mocha-init.js b/src/webui/www/private/scripts/mocha-init.js index fed0a579b..51b345b55 100644 --- a/src/webui/www/private/scripts/mocha-init.js +++ b/src/webui/www/private/scripts/mocha-init.js @@ -376,14 +376,14 @@ const initializeWindows = function() { } }; - deleteFN = function() { + deleteFN = function(deleteFiles = false) { const hashes = torrentsTable.selectedRowsIds(); if (hashes.length) { new MochaUI.Window({ id: 'confirmDeletionPage', title: "QBT_TR(Deletion confirmation)QBT_TR[CONTEXT=confirmDeletionDlg]", loadMethod: 'iframe', - contentURL: 'confirmdeletion.html?hashes=' + hashes.join("|"), + contentURL: ('confirmdeletion.html?hashes=' + hashes.join("|") + '&deleteFiles=' + deleteFiles), scrollbars: false, resizable: false, maximizable: false,