Fixes for PR #607

This commit is contained in:
Feross Aboukhadijeh
2016-05-31 12:12:25 -07:00
parent 71b08304f2
commit c82bdbd39d
5 changed files with 34 additions and 28 deletions

View File

@@ -3,7 +3,7 @@ module.exports = {
openSeedDirectory,
openTorrentFile,
openTorrentAddress,
openAddFiles
openFiles
}
var electron = require('electron')
@@ -55,6 +55,30 @@ function openSeedDirectory () {
})
}
/*
* Show flexible open dialog that supports selecting .torrent files to add, or
* a file or folder to create a single-file or single-directory torrent.
*/
function openFiles () {
if (!windows.main.win) return
log('openFiles')
var opts = process.platform === 'darwin'
? {
title: 'Select a file or folder to add.',
properties: [ 'openFile', 'openDirectory' ]
}
: {
title: 'Select a file to add.',
properties: [ 'openFile' ]
}
setTitle(opts.title)
electron.dialog.showOpenDialog(windows.main.win, opts, function (selectedPaths) {
resetTitle()
if (!Array.isArray(selectedPaths)) return
windows.main.dispatch('onOpen', selectedPaths)
})
}
/*
* Show open dialog to open a .torrent file.
*/
@@ -62,7 +86,7 @@ function openTorrentFile () {
if (!windows.main.win) return
log('openTorrentFile')
var opts = {
title: 'Select a .torrent file to open.',
title: 'Select a .torrent file.',
filters: [{ name: 'Torrent Files', extensions: ['torrent'] }],
properties: [ 'openFile', 'multiSelections' ]
}
@@ -84,24 +108,6 @@ 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,7 +46,7 @@ function init () {
*/
ipc.on('openTorrentFile', () => dialog.openTorrentFile())
ipc.on('openAddFiles', () => dialog.openAddFiles())
ipc.on('openFiles', () => dialog.openFiles())
/**
* Dock