diff --git a/main/dialog.js b/main/dialog.js index 6fe06ab1..b37329e7 100644 --- a/main/dialog.js +++ b/main/dialog.js @@ -2,7 +2,8 @@ module.exports = { openSeedFile, openSeedDirectory, openTorrentFile, - openTorrentAddress + openTorrentAddress, + openAddFiles } var electron = require('electron') @@ -83,6 +84,24 @@ function openTorrentAddress () { windows.main.dispatch('openTorrentAddress') } +/* + * Show open dialog for all file types (.torrent, files to seed) + */ +function openAddFiles () { + if (!windows.main.win) return + log('openAddFiles') + var opts = { + title: 'Select a .torrent file to open or start seeding files.', + properties: [ 'openFile', 'multiSelections' ] + } + setTitle(opts.title) + electron.dialog.showOpenDialog(windows.main.win, opts, function (selectedPaths) { + resetTitle() + if (!Array.isArray(selectedPaths)) return + windows.main.dispatch('onOpen', selectedPaths) + }) +} + /** * Dialogs on do not show a title on OS X, so the window title is used instead. */ diff --git a/main/ipc.js b/main/ipc.js index b9c4c59a..fd598118 100644 --- a/main/ipc.js +++ b/main/ipc.js @@ -46,6 +46,7 @@ function init () { */ ipc.on('openTorrentFile', () => dialog.openTorrentFile()) + ipc.on('openAddFiles', () => dialog.openAddFiles()) /** * Dock diff --git a/renderer/main.js b/renderer/main.js index bf762730..441287d1 100644 --- a/renderer/main.js +++ b/renderer/main.js @@ -227,6 +227,9 @@ function dispatch (action, ...args) { if (action === 'openTorrentFile') { ipcRenderer.send('openTorrentFile') /* open torrent file */ } + if (action === 'openAddFiles') { + ipcRenderer.send('openAddFiles') /* add files with dialog */ + } if (action === 'showCreateTorrent') { showCreateTorrent(args[0] /* paths */) } diff --git a/renderer/views/header.js b/renderer/views/header.js index 31e36bb6..11e3c398 100644 --- a/renderer/views/header.js +++ b/renderer/views/header.js @@ -39,7 +39,7 @@ function Header (state) { + onclick=${dispatcher('openAddFiles')}> add `