From 8fcfa3b97a6f33bcb9cc5f54974a0279bbda2071 Mon Sep 17 00:00:00 2001 From: gabriel Date: Sat, 7 May 2016 22:05:46 +0200 Subject: [PATCH 1/2] Allow to torrent a single file --- main/menu.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/main/menu.js b/main/menu.js index 5b06d8e0..7c5c33cf 100644 --- a/main/menu.js +++ b/main/menu.js @@ -108,6 +108,18 @@ function getMenuItem (label) { } } +// Prompts the user for a file, then makes a torrent out of the data +function showOpenSeedFile () { + electron.dialog.showOpenDialog({ + title: 'Select a file for the torrent file', + properties: ['openFile'] + }, function (filenames) { + if (!Array.isArray(filenames)) return + var file = filenames[0] + windows.main.send('dispatch', 'showCreateTorrent', file) + }) +} + // Prompts the user for a file or folder, then makes a torrent out of the data function showOpenSeedFiles () { // Allow only a single selection @@ -144,7 +156,12 @@ function showOpenTorrentAddress () { function getAppMenuTemplate () { var fileMenu = [ { - label: 'Create New Torrent...', + label: 'Create New Torrent from File', + accelerator: 'CmdOrCtrl+F', + click: showOpenSeedFile + }, + { + label: 'Create New Torrent from Folder', accelerator: 'CmdOrCtrl+N', click: showOpenSeedFiles }, From 41910aea9c9dfa4d75970b61d316771fc45966d0 Mon Sep 17 00:00:00 2001 From: gabriel Date: Sun, 8 May 2016 23:39:32 +0200 Subject: [PATCH 2/2] Do not show torrent file option on OS X --- main/menu.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/main/menu.js b/main/menu.js index 7c5c33cf..0c883ac7 100644 --- a/main/menu.js +++ b/main/menu.js @@ -156,12 +156,7 @@ function showOpenTorrentAddress () { function getAppMenuTemplate () { var fileMenu = [ { - label: 'Create New Torrent from File', - accelerator: 'CmdOrCtrl+F', - click: showOpenSeedFile - }, - { - label: 'Create New Torrent from Folder', + label: process.platform === 'darwin' ? 'Create New Torrent...' : 'Create New Torrent from Folder...', accelerator: 'CmdOrCtrl+N', click: showOpenSeedFiles }, @@ -185,6 +180,13 @@ function getAppMenuTemplate () { } ] + // In Linux and Windows it is not possible to open both folders and files + if (process.platform !== 'darwin') { + fileMenu.unshift({ + label: 'Create New Torrent from File...', + click: showOpenSeedFile + }) + } // File > Quit for Linux users with distros where the system tray is broken if (process.platform === 'linux') { fileMenu.push({