diff --git a/src/main/menu.js b/src/main/menu.js index 1b7fd479..8268cf10 100644 --- a/src/main/menu.js +++ b/src/main/menu.js @@ -278,6 +278,22 @@ function getMenuTemplate () { } ] }, + { + label: 'Transfers', + submenu: [ + { + label: 'Pause All', + click: () => windows.main.dispatch('pauseAllTorrents') + }, + { + type: 'separator' + }, + { + label: 'Resume All', + click: () => windows.main.dispatch('resumeAllTorrents') + } + ] + }, { label: 'Help', role: 'help', diff --git a/src/renderer/controllers/torrent-list-controller.js b/src/renderer/controllers/torrent-list-controller.js index d9bbb045..567df8f0 100644 --- a/src/renderer/controllers/torrent-list-controller.js +++ b/src/renderer/controllers/torrent-list-controller.js @@ -128,6 +128,26 @@ module.exports = class TorrentListController { } } + pauseAllTorrents () { + this.state.saved.torrents.forEach((torrentSummary) => { + if (torrentSummary.status === 'downloading') { + torrentSummary.status = 'paused' + ipcRenderer.send('wt-stop-torrenting', torrentSummary.infoHash) + sound.play('DISABLE') + } + }) + } + + resumeAllTorrents () { + this.state.saved.torrents.forEach((torrentSummary) => { + if (torrentSummary.status === 'paused') { + torrentSummary.status = 'downloading' + this.startTorrentingSummary(torrentSummary.torrentKey) + sound.play('ENABLE') + } + }) + } + toggleTorrentFile (infoHash, index) { const torrentSummary = TorrentSummary.getByKey(this.state, infoHash) torrentSummary.selections[index] = !torrentSummary.selections[index] diff --git a/src/renderer/main.js b/src/renderer/main.js index 26611d5c..8afe2ef6 100644 --- a/src/renderer/main.js +++ b/src/renderer/main.js @@ -225,6 +225,8 @@ const dispatchHandlers = { 'showCreateTorrent': (paths) => controllers.torrentList().showCreateTorrent(paths), 'createTorrent': (options) => controllers.torrentList().createTorrent(options), 'toggleTorrent': (infoHash) => controllers.torrentList().toggleTorrent(infoHash), + 'pauseAllTorrents': () => controllers.torrentList().pauseAllTorrents(), + 'resumeAllTorrents': () => controllers.torrentList().resumeAllTorrents(), 'toggleTorrentFile': (infoHash, index) => controllers.torrentList().toggleTorrentFile(infoHash, index), 'confirmDeleteTorrent': (infoHash, deleteData) =>