Set confirm_torrent_deletion to true if it isn't set

This commit is contained in:
Carve 2024-10-17 16:04:14 -04:00
parent d73cd9cb9b
commit 3534e5fbbc
5 changed files with 1258 additions and 1442 deletions

View File

@ -233,8 +233,23 @@ dd {
/* Forms */ /* Forms */
fieldset { fieldset {
border: 1px solid var(--color-border-default); border: solid 1px var(--darkmode-line-color);
border-radius: 5px; border-radius: 8px;
padding: 4px 4px 4px 10px;
}
fieldset legend {
font-weight: bold;
margin-left: 8px;
padding: 4px;
}
fieldset label {
padding: 2px;
}
fieldset+div.formRow {
margin-top: 10px;
} }
/* Code */ /* Code */
@ -613,30 +628,6 @@ label.partial {
background-position: 0 -26px; background-position: 0 -26px;
} }
fieldset {
border-color: var(--darkmode-line-color);
}
fieldset.settings {
border: solid 1px var(--darkmode-line-color);
border-radius: 8px;
padding: 4px 4px 4px 10px;
}
fieldset.settings legend {
font-weight: bold;
margin-left: 8px;
padding: 4px;
}
fieldset.settings label {
padding: 2px;
}
fieldset.settings+div.formRow {
margin-top: 10px;
}
div.formRow { div.formRow {
clear: left; clear: left;
display: block; display: block;

View File

@ -1647,7 +1647,7 @@ window.addEventListener("DOMContentLoaded", () => {
return; return;
if (event.target.isContentEditable) if (event.target.isContentEditable)
return; return;
deleteFN(); deleteSelectedTorrentsFN();
event.preventDefault(); event.preventDefault();
}, },
"shift+delete": (event) => { "shift+delete": (event) => {
@ -1655,7 +1655,7 @@ window.addEventListener("DOMContentLoaded", () => {
return; return;
if (event.target.isContentEditable) if (event.target.isContentEditable)
return; return;
deleteFN(true); deleteSelectedTorrentsFN(true);
event.preventDefault(); event.preventDefault();
} }
} }

View File

@ -115,7 +115,7 @@ let setForceStartFN = function() {};
let globalDownloadLimitFN = function() {}; let globalDownloadLimitFN = function() {};
let StatisticsLinkFN = function() {}; let StatisticsLinkFN = function() {};
let downloadLimitFN = function() {}; let downloadLimitFN = function() {};
let deleteFN = function() {}; let deleteSelectedTorrentsFN = function() {};
let stopFN = function() {}; let stopFN = function() {};
let startFN = function() {}; let startFN = function() {};
let autoTorrentManagementFN = function() {}; let autoTorrentManagementFN = function() {};
@ -124,6 +124,9 @@ let reannounceFN = function() {};
let setLocationFN = function() {}; let setLocationFN = function() {};
let renameFN = function() {}; let renameFN = function() {};
let renameFilesFN = function() {}; let renameFilesFN = function() {};
let startVisibleTorrentsFN = function() {};
let stopVisibleTorrentsFN = function() {};
let deleteVisibleTorrentsFN = function() {};
let torrentNewCategoryFN = function() {}; let torrentNewCategoryFN = function() {};
let torrentSetCategoryFN = function() {}; let torrentSetCategoryFN = function() {};
let createCategoryFN = function() {}; let createCategoryFN = function() {};
@ -131,21 +134,12 @@ let createSubcategoryFN = function() {};
let editCategoryFN = function() {}; let editCategoryFN = function() {};
let removeCategoryFN = function() {}; let removeCategoryFN = function() {};
let deleteUnusedCategoriesFN = function() {}; let deleteUnusedCategoriesFN = function() {};
let startTorrentsByCategoryFN = function() {};
let stopTorrentsByCategoryFN = function() {};
let deleteTorrentsByCategoryFN = function() {};
let torrentAddTagsFN = function() {}; let torrentAddTagsFN = function() {};
let torrentSetTagsFN = function() {}; let torrentSetTagsFN = function() {};
let torrentRemoveAllTagsFN = function() {}; let torrentRemoveAllTagsFN = function() {};
let createTagFN = function() {}; let createTagFN = function() {};
let removeTagFN = function() {}; let removeTagFN = function() {};
let deleteUnusedTagsFN = function() {}; let deleteUnusedTagsFN = function() {};
let startTorrentsByTagFN = function() {};
let stopTorrentsByTagFN = function() {};
let deleteTorrentsByTagFN = function() {};
let startTorrentsByTrackerFN = function() {};
let stopTorrentsByTrackerFN = function() {};
let deleteTorrentsByTrackerFN = function() {};
let deleteTrackerFN = function() {}; let deleteTrackerFN = function() {};
let copyNameFN = function() {}; let copyNameFN = function() {};
let copyInfohashFN = function(policy) {}; let copyInfohashFN = function(policy) {};
@ -193,7 +187,7 @@ const initializeWindows = function() {
new MochaUI.Window({ new MochaUI.Window({
id: id, id: id,
icon: "images/qbittorrent-tray.svg", icon: "images/qbittorrent-tray.svg",
title: "Download from URLs", title: "QBT_TR(Download from URLs)QBT_TR[CONTEXT=downloadFromURL]",
loadMethod: "iframe", loadMethod: "iframe",
contentURL: contentUri.toString(), contentURL: contentUri.toString(),
addClass: "windowFrame", // fixes iframe scrolling on iOS Safari addClass: "windowFrame", // fixes iframe scrolling on iOS Safari
@ -219,7 +213,7 @@ const initializeWindows = function() {
new MochaUI.Window({ new MochaUI.Window({
id: id, id: id,
icon: "images/qbittorrent-tray.svg", icon: "images/qbittorrent-tray.svg",
title: "Options", title: "QBT_TR(Options)QBT_TR[CONTEXT=OptionsDialog]",
loadMethod: "xhr", loadMethod: "xhr",
toolbar: true, toolbar: true,
contentURL: new URI("views/preferences.html").toString(), contentURL: new URI("views/preferences.html").toString(),
@ -231,7 +225,7 @@ const initializeWindows = function() {
closable: true, closable: true,
paddingVertical: 0, paddingVertical: 0,
paddingHorizontal: 0, paddingHorizontal: 0,
width: loadWindowWidth(id, 700), width: loadWindowWidth(id, 730),
height: loadWindowHeight(id, 600), height: loadWindowHeight(id, 600),
onResize: window.qBittorrent.Misc.createDebounceHandler(500, (e) => { onResize: window.qBittorrent.Misc.createDebounceHandler(500, (e) => {
saveWindowSize(id); saveWindowSize(id);
@ -246,7 +240,7 @@ const initializeWindows = function() {
const id = "cookiesPage"; const id = "cookiesPage";
new MochaUI.Window({ new MochaUI.Window({
id: id, id: id,
title: "Manage Cookies", title: "QBT_TR(Manage Cookies)QBT_TR[CONTEXT=CookiesDialog]",
loadMethod: "xhr", loadMethod: "xhr",
contentURL: new URI("views/cookies.html").toString(), contentURL: new URI("views/cookies.html").toString(),
maximizable: false, maximizable: false,
@ -268,7 +262,7 @@ const initializeWindows = function() {
new MochaUI.Window({ new MochaUI.Window({
id: id, id: id,
icon: "images/qbittorrent-tray.svg", icon: "images/qbittorrent-tray.svg",
title: "Upload local torrent", title: "QBT_TR(Upload local torrent)QBT_TR[CONTEXT=HttpServer]",
loadMethod: "iframe", loadMethod: "iframe",
contentURL: new URI("upload.html").toString(), contentURL: new URI("upload.html").toString(),
addClass: "windowFrame", // fixes iframe scrolling on iOS Safari addClass: "windowFrame", // fixes iframe scrolling on iOS Safari
@ -289,7 +283,7 @@ const initializeWindows = function() {
new MochaUI.Window({ new MochaUI.Window({
id: "uploadLimitPage", id: "uploadLimitPage",
icon: "images/qbittorrent-tray.svg", icon: "images/qbittorrent-tray.svg",
title: "Global Upload Speed Limit", title: "QBT_TR(Global Upload Speed Limit)QBT_TR[CONTEXT=MainWindow]",
loadMethod: "iframe", loadMethod: "iframe",
contentURL: new URI("uploadlimit.html").setData("hashes", "global").toString(), contentURL: new URI("uploadlimit.html").setData("hashes", "global").toString(),
scrollbars: false, scrollbars: false,
@ -298,7 +292,7 @@ const initializeWindows = function() {
paddingVertical: 0, paddingVertical: 0,
paddingHorizontal: 0, paddingHorizontal: 0,
width: 424, width: 424,
height: 80 height: 100
}); });
}; };
@ -308,7 +302,7 @@ const initializeWindows = function() {
new MochaUI.Window({ new MochaUI.Window({
id: "uploadLimitPage", id: "uploadLimitPage",
icon: "images/qbittorrent-tray.svg", icon: "images/qbittorrent-tray.svg",
title: "Torrent Upload Speed Limiting", title: "QBT_TR(Torrent Upload Speed Limiting)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: "iframe", loadMethod: "iframe",
contentURL: new URI("uploadlimit.html").setData("hashes", hashes.join("|")).toString(), contentURL: new URI("uploadlimit.html").setData("hashes", hashes.join("|")).toString(),
scrollbars: false, scrollbars: false,
@ -317,7 +311,7 @@ const initializeWindows = function() {
paddingVertical: 0, paddingVertical: 0,
paddingHorizontal: 0, paddingHorizontal: 0,
width: 424, width: 424,
height: 80 height: 100
}); });
} }
}; };
@ -350,7 +344,7 @@ const initializeWindows = function() {
new MochaUI.Window({ new MochaUI.Window({
id: "shareRatioPage", id: "shareRatioPage",
icon: "images/qbittorrent-tray.svg", icon: "images/qbittorrent-tray.svg",
title: "Torrent Upload/Download Ratio Limiting", title: "QBT_TR(Torrent Upload/Download Ratio Limiting)QBT_TR[CONTEXT=UpDownRatioDialog]",
loadMethod: "iframe", loadMethod: "iframe",
contentURL: new URI("shareratio.html").setData("hashes", hashes.join("|")).setData("orig", orig).toString(), contentURL: new URI("shareratio.html").setData("hashes", hashes.join("|")).setData("orig", orig).toString(),
scrollbars: false, scrollbars: false,
@ -358,7 +352,7 @@ const initializeWindows = function() {
paddingVertical: 0, paddingVertical: 0,
paddingHorizontal: 0, paddingHorizontal: 0,
width: 424, width: 424,
height: 200 height: 220
}); });
} }
}; };
@ -425,7 +419,7 @@ const initializeWindows = function() {
new MochaUI.Window({ new MochaUI.Window({
id: "downloadLimitPage", id: "downloadLimitPage",
icon: "images/qbittorrent-tray.svg", icon: "images/qbittorrent-tray.svg",
title: "Global Download Speed Limit", title: "QBT_TR(Global Download Speed Limit)QBT_TR[CONTEXT=MainWindow]",
loadMethod: "iframe", loadMethod: "iframe",
contentURL: new URI("downloadlimit.html").setData("hashes", "global").toString(), contentURL: new URI("downloadlimit.html").setData("hashes", "global").toString(),
scrollbars: false, scrollbars: false,
@ -434,7 +428,7 @@ const initializeWindows = function() {
paddingVertical: 0, paddingVertical: 0,
paddingHorizontal: 0, paddingHorizontal: 0,
width: 424, width: 424,
height: 80 height: 100
}); });
}; };
@ -443,7 +437,7 @@ const initializeWindows = function() {
new MochaUI.Window({ new MochaUI.Window({
id: id, id: id,
icon: "images/qbittorrent-tray.svg", icon: "images/qbittorrent-tray.svg",
title: "Statistics", title: "QBT_TR(Statistics)QBT_TR[CONTEXT=StatsDialog]",
loadMethod: "xhr", loadMethod: "xhr",
contentURL: new URI("views/statistics.html").toString(), contentURL: new URI("views/statistics.html").toString(),
maximizable: false, maximizable: false,
@ -462,7 +456,7 @@ const initializeWindows = function() {
new MochaUI.Window({ new MochaUI.Window({
id: "downloadLimitPage", id: "downloadLimitPage",
icon: "images/qbittorrent-tray.svg", icon: "images/qbittorrent-tray.svg",
title: "Torrent Download Speed Limiting", title: "QBT_TR(Torrent Download Speed Limiting)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: "iframe", loadMethod: "iframe",
contentURL: new URI("downloadlimit.html").setData("hashes", hashes.join("|")).toString(), contentURL: new URI("downloadlimit.html").setData("hashes", hashes.join("|")).toString(),
scrollbars: false, scrollbars: false,
@ -471,12 +465,12 @@ const initializeWindows = function() {
paddingVertical: 0, paddingVertical: 0,
paddingHorizontal: 0, paddingHorizontal: 0,
width: 424, width: 424,
height: 80 height: 100
}); });
} }
}; };
deleteFN = function(forceDeleteFiles = false) { deleteSelectedTorrentsFN = function(forceDeleteFiles = false) {
const hashes = torrentsTable.selectedRowsIds(); const hashes = torrentsTable.selectedRowsIds();
if (hashes.length > 0) { if (hashes.length > 0) {
if (window.qBittorrent.Cache.preferences.get().confirm_torrent_deletion) { if (window.qBittorrent.Cache.preferences.get().confirm_torrent_deletion) {
@ -510,6 +504,7 @@ const initializeWindows = function() {
onSuccess: function() { onSuccess: function() {
torrentsTable.deselectAll(); torrentsTable.deselectAll();
updateMainData(); updateMainData();
updatePropertiesPanel();
}, },
onFailure: function() { onFailure: function() {
alert("Unable to delete torrents."); alert("Unable to delete torrents.");
@ -522,7 +517,7 @@ const initializeWindows = function() {
addClickEvent("delete", (e) => { addClickEvent("delete", (e) => {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
deleteFN(); deleteSelectedTorrentsFN();
}); });
stopFN = function() { stopFN = function() {
@ -555,22 +550,36 @@ const initializeWindows = function() {
autoTorrentManagementFN = function() { autoTorrentManagementFN = function() {
const hashes = torrentsTable.selectedRowsIds(); const hashes = torrentsTable.selectedRowsIds();
if (hashes.length) { if (hashes.length > 0) {
let enable = false; const enableAutoTMM = hashes.some((hash) => !(torrentsTable.getRow(hash).full_data.auto_tmm));
hashes.each((hash, index) => { if (enableAutoTMM) {
const row = torrentsTable.getRow(hash); new MochaUI.Modal({
if (!row.full_data.auto_tmm) ...window.qBittorrent.Dialog.baseModalOptions,
enable = true; id: "confirmAutoTMMDialog",
title: "QBT_TR(Enable automatic torrent management)QBT_TR[CONTEXT=confirmAutoTMMDialog]",
data: {
hashes: hashes,
enable: enableAutoTMM
},
contentURL: "views/confirmAutoTMM.html"
}); });
}
else {
new Request({ new Request({
url: "api/v2/torrents/setAutoManagement", url: "api/v2/torrents/setAutoManagement",
method: "post", method: "post",
data: { data: {
hashes: hashes.join("|"), hashes: hashes.join("|"),
enable: enable enable: enableAutoTMM
},
onSuccess: () => {
updateMainData();
},
onFailure: () => {
alert("QBT_TR(Unable to set Auto Torrent Management for the selected torrents.)QBT_TR[CONTEXT=HttpServer]");
} }
}).send(); }).send();
updateMainData(); }
} }
}; };
@ -581,7 +590,7 @@ const initializeWindows = function() {
new MochaUI.Modal({ new MochaUI.Modal({
...window.qBittorrent.Dialog.baseModalOptions, ...window.qBittorrent.Dialog.baseModalOptions,
id: "confirmRecheckDialog", id: "confirmRecheckDialog",
title: "Recheck confirmation", title: "QBT_TR(Recheck confirmation)QBT_TR[CONTEXT=confirmRecheckDialog]",
data: { hashes: hashes }, data: { hashes: hashes },
contentURL: "views/confirmRecheck.html" contentURL: "views/confirmRecheck.html"
}); });
@ -597,7 +606,7 @@ const initializeWindows = function() {
updateMainData(); updateMainData();
}, },
onFailure: function() { onFailure: function() {
alert("Unable to recheck torrents."); alert("QBT_TR(Unable to recheck torrents.)QBT_TR[CONTEXT=HttpServer]");
} }
}).send(); }).send();
} }
@ -627,7 +636,7 @@ const initializeWindows = function() {
new MochaUI.Window({ new MochaUI.Window({
id: "setLocationPage", id: "setLocationPage",
icon: "images/qbittorrent-tray.svg", icon: "images/qbittorrent-tray.svg",
title: "Set location", title: "QBT_TR(Set location)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: "iframe", loadMethod: "iframe",
contentURL: new URI("setlocation.html").setData("hashes", hashes.join("|")).setData("path", encodeURIComponent(row.full_data.save_path)).toString(), contentURL: new URI("setlocation.html").setData("hashes", hashes.join("|")).setData("path", encodeURIComponent(row.full_data.save_path)).toString(),
scrollbars: false, scrollbars: false,
@ -650,7 +659,7 @@ const initializeWindows = function() {
new MochaUI.Window({ new MochaUI.Window({
id: "renamePage", id: "renamePage",
icon: "images/qbittorrent-tray.svg", icon: "images/qbittorrent-tray.svg",
title: "Rename", title: "QBT_TR(Rename)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: "iframe", loadMethod: "iframe",
contentURL: new URI("rename.html").setData("hash", hash).setData("name", row.full_data.name).toString(), contentURL: new URI("rename.html").setData("hash", hash).setData("name", row.full_data.name).toString(),
scrollbars: false, scrollbars: false,
@ -674,7 +683,7 @@ const initializeWindows = function() {
new MochaUI.Window({ new MochaUI.Window({
id: "multiRenamePage", id: "multiRenamePage",
icon: "images/qbittorrent-tray.svg", icon: "images/qbittorrent-tray.svg",
title: "Renaming", title: "QBT_TR(Renaming)QBT_TR[CONTEXT=TransferListWidget]",
data: { hash: hash, selectedRows: [] }, data: { hash: hash, selectedRows: [] },
loadMethod: "xhr", loadMethod: "xhr",
contentURL: "rename_files.html", contentURL: "rename_files.html",
@ -691,6 +700,86 @@ const initializeWindows = function() {
} }
}; };
startVisibleTorrentsFN = function() {
const hashes = torrentsTable.getFilteredTorrentsHashes(selectedStatus, selectedCategory, selectedTag, selectedTracker);
if (hashes.length > 0) {
new Request({
url: "api/v2/torrents/start",
method: "post",
data: {
hashes: hashes.join("|")
},
onSuccess: () => {
updateMainData();
updatePropertiesPanel();
},
onFailure: () => {
alert("QBT_TR(Unable to start torrents.)QBT_TR[CONTEXT=HttpServer]");
}
}).send();
}
};
stopVisibleTorrentsFN = function() {
const hashes = torrentsTable.getFilteredTorrentsHashes(selectedStatus, selectedCategory, selectedTag, selectedTracker);
if (hashes.length > 0) {
new Request({
url: "api/v2/torrents/stop",
method: "post",
data: {
hashes: hashes.join("|")
},
onSuccess: () => {
updateMainData();
updatePropertiesPanel();
},
onFailure: () => {
alert("QBT_TR(Unable to stop torrents.)QBT_TR[CONTEXT=HttpServer]");
}
}).send();
}
};
deleteVisibleTorrentsFN = function() {
const hashes = torrentsTable.getFilteredTorrentsHashes(selectedStatus, selectedCategory, selectedTag, selectedTracker);
if (hashes.length > 0) {
if (window.qBittorrent.Cache.preferences.get().confirm_torrent_deletion) {
new MochaUI.Modal({
...window.qBittorrent.Dialog.baseModalOptions,
id: "confirmDeletionPage",
title: "QBT_TR(Remove torrent(s))QBT_TR[CONTEXT=confirmDeletionDlg]",
data: {
hashes: hashes,
isDeletingVisibleTorrents: true
},
contentURL: "views/confirmdeletion.html",
onContentLoaded: function(w) {
MochaUI.resizeWindow(w, { centered: true });
MochaUI.centerWindow(w);
}
});
}
else {
new Request({
url: "api/v2/torrents/delete",
method: "post",
data: {
hashes: hashes.join("|"),
deleteFiles: false,
},
onSuccess: () => {
torrentsTable.deselectAll();
updateMainData();
updatePropertiesPanel();
},
onFailure: () => {
alert("QBT_TR(Unable to delete torrents.)QBT_TR[CONTEXT=HttpServer]");
}
}).send();
}
}
};
torrentNewCategoryFN = function() { torrentNewCategoryFN = function() {
const action = "set"; const action = "set";
const hashes = torrentsTable.selectedRowsIds(); const hashes = torrentsTable.selectedRowsIds();
@ -698,7 +787,7 @@ const initializeWindows = function() {
new MochaUI.Window({ new MochaUI.Window({
id: "newCategoryPage", id: "newCategoryPage",
icon: "images/qbittorrent-tray.svg", icon: "images/qbittorrent-tray.svg",
title: "New Category", title: "QBT_TR(New Category)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: "iframe", loadMethod: "iframe",
contentURL: new URI("newcategory.html").setData("action", action).setData("hashes", hashes.join("|")).toString(), contentURL: new URI("newcategory.html").setData("action", action).setData("hashes", hashes.join("|")).toString(),
scrollbars: false, scrollbars: false,
@ -738,7 +827,7 @@ const initializeWindows = function() {
new MochaUI.Window({ new MochaUI.Window({
id: "newCategoryPage", id: "newCategoryPage",
icon: "images/qbittorrent-tray.svg", icon: "images/qbittorrent-tray.svg",
title: "New Category", title: "QBT_TR(New Category)QBT_TR[CONTEXT=CategoryFilterWidget]",
loadMethod: "iframe", loadMethod: "iframe",
contentURL: new URI("newcategory.html").setData("action", action).toString(), contentURL: new URI("newcategory.html").setData("action", action).toString(),
scrollbars: false, scrollbars: false,
@ -757,7 +846,7 @@ const initializeWindows = function() {
new MochaUI.Window({ new MochaUI.Window({
id: "newSubcategoryPage", id: "newSubcategoryPage",
icon: "images/qbittorrent-tray.svg", icon: "images/qbittorrent-tray.svg",
title: "New Category", title: "QBT_TR(New Category)QBT_TR[CONTEXT=CategoryFilterWidget]",
loadMethod: "iframe", loadMethod: "iframe",
contentURL: new URI("newcategory.html").setData("action", action).setData("categoryName", categoryName).toString(), contentURL: new URI("newcategory.html").setData("action", action).setData("categoryName", categoryName).toString(),
scrollbars: false, scrollbars: false,
@ -776,7 +865,7 @@ const initializeWindows = function() {
new MochaUI.Window({ new MochaUI.Window({
id: "editCategoryPage", id: "editCategoryPage",
icon: "images/qbittorrent-tray.svg", icon: "images/qbittorrent-tray.svg",
title: "Edit Category", title: "QBT_TR(Edit Category)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: "iframe", loadMethod: "iframe",
contentURL: new URI("newcategory.html").setData("action", action).setData("categoryName", category.name).setData("savePath", category.savePath).toString(), contentURL: new URI("newcategory.html").setData("action", action).setData("categoryName", category.name).setData("savePath", category.savePath).toString(),
scrollbars: false, scrollbars: false,
@ -824,74 +913,6 @@ const initializeWindows = function() {
}).send(); }).send();
}; };
startTorrentsByCategoryFN = function(categoryHash) {
const hashes = torrentsTable.getFilteredTorrentsHashes("all", categoryHash, TAGS_ALL, TRACKERS_ALL);
if (hashes.length) {
new Request({
url: "api/v2/torrents/start",
method: "post",
data: {
hashes: hashes.join("|")
}
}).send();
updateMainData();
}
};
stopTorrentsByCategoryFN = function(categoryHash) {
const hashes = torrentsTable.getFilteredTorrentsHashes("all", categoryHash, TAGS_ALL, TRACKERS_ALL);
if (hashes.length) {
new Request({
url: "api/v2/torrents/stop",
method: "post",
data: {
hashes: hashes.join("|")
}
}).send();
updateMainData();
}
};
deleteTorrentsByCategoryFN = function(categoryHash) {
const hashes = torrentsTable.getFilteredTorrentsHashes("all", categoryHash, TAGS_ALL, TRACKERS_ALL);
if (hashes.length > 0) {
if (window.qBittorrent.Cache.preferences.get().confirm_torrent_deletion) {
new MochaUI.Modal({
...window.qBittorrent.Dialog.baseModalOptions,
id: "confirmDeletionPage",
title: "Remove torrent(s)",
data: { hashes: hashes },
contentURL: "views/confirmdeletion.html",
onContentLoaded: function(w) {
MochaUI.resizeWindow(w, { centered: true });
MochaUI.centerWindow(w);
},
onCloseComplete: function() {
// make sure overlay is properly hidden upon modal closing
document.getElementById("modalOverlay").style.display = "none";
}
});
}
else {
new Request({
url: "api/v2/torrents/delete",
method: "post",
data: {
hashes: hashes.join("|"),
deleteFiles: false,
},
onSuccess: function() {
torrentsTable.deselectAll();
updateMainData();
},
onFailure: function() {
alert("Unable to delete torrents.");
}
}).send();
}
}
};
torrentAddTagsFN = function() { torrentAddTagsFN = function() {
const action = "set"; const action = "set";
const hashes = torrentsTable.selectedRowsIds(); const hashes = torrentsTable.selectedRowsIds();
@ -899,7 +920,7 @@ const initializeWindows = function() {
new MochaUI.Window({ new MochaUI.Window({
id: "newTagPage", id: "newTagPage",
icon: "images/qbittorrent-tray.svg", icon: "images/qbittorrent-tray.svg",
title: "Add tags", title: "QBT_TR(Add tags)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: "iframe", loadMethod: "iframe",
contentURL: new URI("newtag.html").setData("action", action).setData("hashes", hashes.join("|")).toString(), contentURL: new URI("newtag.html").setData("action", action).setData("hashes", hashes.join("|")).toString(),
scrollbars: false, scrollbars: false,
@ -947,7 +968,7 @@ const initializeWindows = function() {
new MochaUI.Window({ new MochaUI.Window({
id: "newTagPage", id: "newTagPage",
icon: "images/qbittorrent-tray.svg", icon: "images/qbittorrent-tray.svg",
title: "New Tag", title: "QBT_TR(New Tag)QBT_TR[CONTEXT=TagFilterWidget]",
loadMethod: "iframe", loadMethod: "iframe",
contentURL: new URI("newtag.html").setData("action", action).toString(), contentURL: new URI("newtag.html").setData("action", action).toString(),
scrollbars: false, scrollbars: false,
@ -989,203 +1010,6 @@ const initializeWindows = function() {
setTagFilter(TAGS_ALL); setTagFilter(TAGS_ALL);
}; };
startTorrentsByTagFN = function(tagHash) {
const hashes = torrentsTable.getFilteredTorrentsHashes("all", CATEGORIES_ALL, tagHash, TRACKERS_ALL);
if (hashes.length) {
new Request({
url: "api/v2/torrents/start",
method: "post",
data: {
hashes: hashes.join("|")
}
}).send();
updateMainData();
}
};
stopTorrentsByTagFN = function(tagHash) {
const hashes = torrentsTable.getFilteredTorrentsHashes("all", CATEGORIES_ALL, tagHash, TRACKERS_ALL);
if (hashes.length) {
new Request({
url: "api/v2/torrents/stop",
method: "post",
data: {
hashes: hashes.join("|")
}
}).send();
updateMainData();
}
};
deleteTorrentsByTagFN = function(tagHash) {
const hashes = torrentsTable.getFilteredTorrentsHashes("all", CATEGORIES_ALL, tagHash, TRACKERS_ALL);
if (hashes.length > 0) {
if (window.qBittorrent.Cache.preferences.get().confirm_torrent_deletion) {
new MochaUI.Modal({
...window.qBittorrent.Dialog.baseModalOptions,
id: "confirmDeletionPage",
title: "Remove torrent(s)",
data: { hashes: hashes },
contentURL: "views/confirmdeletion.html",
onContentLoaded: function(w) {
MochaUI.resizeWindow(w, { centered: true });
MochaUI.centerWindow(w);
},
onCloseComplete: function() {
// make sure overlay is properly hidden upon modal closing
document.getElementById("modalOverlay").style.display = "none";
}
});
}
else {
new Request({
url: "api/v2/torrents/delete",
method: "post",
data: {
hashes: hashes.join("|"),
deleteFiles: false,
},
onSuccess: function() {
torrentsTable.deselectAll();
updateMainData();
},
onFailure: function() {
alert("Unable to delete torrents.");
}
}).send();
}
}
};
startTorrentsByTrackerFN = function(trackerHash) {
const trackerHashInt = Number.parseInt(trackerHash, 10);
let hashes = [];
switch (trackerHashInt) {
case TRACKERS_ALL:
hashes = torrentsTable.getFilteredTorrentsHashes("all", CATEGORIES_ALL, TAGS_ALL, TRACKERS_ALL);
break;
case TRACKERS_TRACKERLESS:
hashes = torrentsTable.getFilteredTorrentsHashes("all", CATEGORIES_ALL, TAGS_ALL, TRACKERS_TRACKERLESS);
break;
default: {
const uniqueTorrents = new Set();
for (const torrents of trackerList.get(trackerHashInt).trackerTorrentMap.values()) {
for (const torrent of torrents)
uniqueTorrents.add(torrent);
}
hashes = [...uniqueTorrents];
break;
}
}
if (hashes.length > 0) {
new Request({
url: "api/v2/torrents/start",
method: "post",
data: {
hashes: hashes.join("|")
}
}).send();
updateMainData();
}
};
stopTorrentsByTrackerFN = function(trackerHash) {
const trackerHashInt = Number.parseInt(trackerHash, 10);
let hashes = [];
switch (trackerHashInt) {
case TRACKERS_ALL:
hashes = torrentsTable.getFilteredTorrentsHashes("all", CATEGORIES_ALL, TAGS_ALL, TRACKERS_ALL);
break;
case TRACKERS_TRACKERLESS:
hashes = torrentsTable.getFilteredTorrentsHashes("all", CATEGORIES_ALL, TAGS_ALL, TRACKERS_TRACKERLESS);
break;
default: {
const uniqueTorrents = new Set();
for (const torrents of trackerList.get(trackerHashInt).trackerTorrentMap.values()) {
for (const torrent of torrents)
uniqueTorrents.add(torrent);
}
hashes = [...uniqueTorrents];
break;
}
}
if (hashes.length) {
new Request({
url: "api/v2/torrents/stop",
method: "post",
data: {
hashes: hashes.join("|")
}
}).send();
updateMainData();
}
};
deleteTorrentsByTrackerFN = function(trackerHash) {
const trackerHashInt = Number.parseInt(trackerHash, 10);
let hashes = [];
switch (trackerHashInt) {
case TRACKERS_ALL:
hashes = torrentsTable.getFilteredTorrentsHashes("all", CATEGORIES_ALL, TAGS_ALL, TRACKERS_ALL);
break;
case TRACKERS_TRACKERLESS:
hashes = torrentsTable.getFilteredTorrentsHashes("all", CATEGORIES_ALL, TAGS_ALL, TRACKERS_TRACKERLESS);
break;
default: {
const uniqueTorrents = new Set();
for (const torrents of trackerList.get(trackerHashInt).trackerTorrentMap.values()) {
for (const torrent of torrents)
uniqueTorrents.add(torrent);
}
hashes = [...uniqueTorrents];
break;
}
}
if (hashes.length > 0) {
if (window.qBittorrent.Cache.preferences.get().confirm_torrent_deletion) {
new MochaUI.Modal({
...window.qBittorrent.Dialog.baseModalOptions,
id: "confirmDeletionPage",
title: "Remove torrent(s)",
data: {
hashes: hashes,
filterList: "tracker"
},
contentURL: "views/confirmdeletion.html",
onContentLoaded: function(w) {
MochaUI.resizeWindow(w, { centered: true });
MochaUI.centerWindow(w);
},
onCloseComplete: function() {
// make sure overlay is properly hidden upon modal closing
document.getElementById("modalOverlay").style.display = "none";
}
});
}
else {
new Request({
url: "api/v2/torrents/delete",
method: "post",
data: {
hashes: hashes.join("|"),
deleteFiles: false,
},
onSuccess: function() {
torrentsTable.deselectAll();
setTrackerFilter(TRACKERS_ALL);
updateMainData();
},
onFailure: function() {
alert("Unable to delete torrents.");
},
}).send();
}
}
};
deleteTrackerFN = function(trackerHash) { deleteTrackerFN = function(trackerHash) {
const trackerHashInt = Number.parseInt(trackerHash, 10); const trackerHashInt = Number.parseInt(trackerHash, 10);
if ((trackerHashInt === TRACKERS_ALL) || (trackerHashInt === TRACKERS_TRACKERLESS)) if ((trackerHashInt === TRACKERS_ALL) || (trackerHashInt === TRACKERS_TRACKERLESS))
@ -1197,7 +1021,7 @@ const initializeWindows = function() {
new MochaUI.Window({ new MochaUI.Window({
id: "confirmDeletionPage", id: "confirmDeletionPage",
title: "Remove tracker", title: "QBT_TR(Remove tracker)QBT_TR[CONTEXT=confirmDeletionDlg]",
loadMethod: "iframe", loadMethod: "iframe",
contentURL: new URI("confirmtrackerdeletion.html").setData("host", host).setData("urls", urls.map(encodeURIComponent).join("|")).toString(), contentURL: new URI("confirmtrackerdeletion.html").setData("host", host).setData("urls", urls.map(encodeURIComponent).join("|")).toString(),
scrollbars: false, scrollbars: false,
@ -1311,7 +1135,7 @@ const initializeWindows = function() {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
if (confirm("Would you like to stop all torrents?")) { if (confirm("QBT_TR(Would you like to stop all torrents?)QBT_TR[CONTEXT=MainWindow]")) {
new Request({ new Request({
url: "api/v2/torrents/stop", url: "api/v2/torrents/stop",
method: "post", method: "post",
@ -1327,7 +1151,7 @@ const initializeWindows = function() {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
if (confirm("Would you like to start all torrents?")) { if (confirm("QBT_TR(Would you like to start all torrents?)QBT_TR[CONTEXT=MainWindow]")) {
new Request({ new Request({
url: "api/v2/torrents/start", url: "api/v2/torrents/start",
method: "post", method: "post",
@ -1390,7 +1214,7 @@ const initializeWindows = function() {
new MochaUI.Window({ new MochaUI.Window({
id: id, id: id,
icon: "images/qbittorrent-tray.svg", icon: "images/qbittorrent-tray.svg",
title: "About qBittorrent", title: "QBT_TR(About qBittorrent)QBT_TR[CONTEXT=AboutDialog]",
loadMethod: "xhr", loadMethod: "xhr",
contentURL: new URI("views/about.html").toString(), contentURL: new URI("views/about.html").toString(),
require: { require: {
@ -1399,7 +1223,7 @@ const initializeWindows = function() {
toolbar: true, toolbar: true,
toolbarURL: "views/aboutToolbar.html", toolbarURL: "views/aboutToolbar.html",
padding: 10, padding: 10,
width: loadWindowWidth(id, 550), width: loadWindowWidth(id, 570),
height: loadWindowHeight(id, 360), height: loadWindowHeight(id, 360),
onResize: window.qBittorrent.Misc.createDebounceHandler(500, (e) => { onResize: window.qBittorrent.Misc.createDebounceHandler(500, (e) => {
saveWindowSize(id); saveWindowSize(id);
@ -1424,12 +1248,12 @@ const initializeWindows = function() {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
if (confirm("Are you sure you want to quit qBittorrent?")) { if (confirm("QBT_TR(Are you sure you want to quit qBittorrent?)QBT_TR[CONTEXT=MainWindow]")) {
new Request({ new Request({
url: "api/v2/app/shutdown", url: "api/v2/app/shutdown",
method: "post", method: "post",
onSuccess: function() { onSuccess: function() {
const shutdownMessage = "%1 has been shutdown".replace("%1", window.qBittorrent.Client.mainTitle()); const shutdownMessage = "QBT_TR(%1 has been shutdown)QBT_TR[CONTEXT=HttpServer]".replace("%1", window.qBittorrent.Client.mainTitle());
document.write(`<!doctype html><html lang="${LANG}"><head> <meta charset="UTF-8"> <meta name="color-scheme" content="light dark"> <title>${shutdownMessage}</title> <style>* {font-family: Arial, Helvetica, sans-serif;}</style></head><body> <h1 style="text-align: center;">${shutdownMessage}</h1></body></html>`); document.write(`<!doctype html><html lang="${LANG}"><head> <meta charset="UTF-8"> <meta name="color-scheme" content="light dark"> <title>${shutdownMessage}</title> <style>* {font-family: Arial, Helvetica, sans-serif;}</style></head><body> <h1 style="text-align: center;">${shutdownMessage}</h1></body></html>`);
document.close(); document.close();
window.stop(); window.stop();
@ -1447,3 +1271,4 @@ const initializeWindows = function() {
}); });
}); });
}; };

View File

@ -2127,7 +2127,7 @@ Use ';' to split multiple entries. Can use wildcard '*'."></textarea>
document.getElementById("hideZeroFiltersCheckbox").checked = (LocalPreferences.get("hide_zero_status_filters", "false") === "true"); document.getElementById("hideZeroFiltersCheckbox").checked = (LocalPreferences.get("hide_zero_status_filters", "false") === "true");
$("dblclickDownloadSelect").value = LocalPreferences.get("dblclick_download", "1"); $("dblclickDownloadSelect").value = LocalPreferences.get("dblclick_download", "1");
$("dblclickCompleteSelect").value = LocalPreferences.get("dblclick_complete", "1"); $("dblclickCompleteSelect").value = LocalPreferences.get("dblclick_complete", "1");
document.getElementById("confirmTorrentDeletion").checked = pref.confirm_torrent_deletion; document.getElementById("confirmTorrentDeletion").checked = pref.confirm_torrent_deletion ?? true;
document.getElementById("useAltRowColorsInput").checked = (LocalPreferences.get("use_alt_row_colors", "true") === "true"); document.getElementById("useAltRowColorsInput").checked = (LocalPreferences.get("use_alt_row_colors", "true") === "true");
$("filelog_checkbox").checked = pref.file_log_enabled; $("filelog_checkbox").checked = pref.file_log_enabled;
$("filelog_save_path_input").value = pref.file_log_path; $("filelog_save_path_input").value = pref.file_log_path;
@ -2545,7 +2545,7 @@ Use ';' to split multiple entries. Can use wildcard '*'."></textarea>
LocalPreferences.set("hide_zero_status_filters", document.getElementById("hideZeroFiltersCheckbox").checked.toString()); LocalPreferences.set("hide_zero_status_filters", document.getElementById("hideZeroFiltersCheckbox").checked.toString());
LocalPreferences.set("dblclick_download", $("dblclickDownloadSelect").value); LocalPreferences.set("dblclick_download", $("dblclickDownloadSelect").value);
LocalPreferences.set("dblclick_complete", $("dblclickCompleteSelect").value); LocalPreferences.set("dblclick_complete", $("dblclickCompleteSelect").value);
settings["confirm_torrent_deletion"] = document.getElementById("confirmTorrentDeletion").checked; settings["confirm_torrent_deletion"] = document.getElementById("confirmTorrentDeletion").checked ?? true;
LocalPreferences.set("use_alt_row_colors", document.getElementById("useAltRowColorsInput").checked.toString()); LocalPreferences.set("use_alt_row_colors", document.getElementById("useAltRowColorsInput").checked.toString());
settings["file_log_enabled"] = $("filelog_checkbox").checked; settings["file_log_enabled"] = $("filelog_checkbox").checked;
settings["file_log_path"] = $("filelog_save_path_input").value; settings["file_log_path"] = $("filelog_save_path_input").value;

View File

@ -43,7 +43,7 @@
}, },
delete: function(element, ref) { delete: function(element, ref) {
deleteFN(); deleteSelectedTorrentsFN();
}, },
setLocation: function(element, ref) { setLocation: function(element, ref) {