Make add button accept non .torrent files

This commit is contained in:
Mathias Rasmussen
2016-05-31 03:04:02 +02:00
parent 1b8f180255
commit 556d0cb1c5
4 changed files with 25 additions and 2 deletions

View File

@@ -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.
*/

View File

@@ -46,6 +46,7 @@ function init () {
*/
ipc.on('openTorrentFile', () => dialog.openTorrentFile())
ipc.on('openAddFiles', () => dialog.openAddFiles())
/**
* Dock

View File

@@ -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 */)
}

View File

@@ -39,7 +39,7 @@ function Header (state) {
<i
class='icon add'
title='Add torrent'
onclick=${dispatcher('openTorrentFile')}>
onclick=${dispatcher('openAddFiles')}>
add
</i>
`