Dialogs on do not show a title on OS X, so the window title is used instead.
This commit is contained in:
@@ -5,6 +5,7 @@ module.exports = {
|
|||||||
openTorrentAddress
|
openTorrentAddress
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var config = require('../config')
|
||||||
var electron = require('electron')
|
var electron = require('electron')
|
||||||
var windows = require('./windows')
|
var windows = require('./windows')
|
||||||
|
|
||||||
@@ -12,11 +13,14 @@ var windows = require('./windows')
|
|||||||
* Show open dialog to create a single-file torrent.
|
* Show open dialog to create a single-file torrent.
|
||||||
*/
|
*/
|
||||||
function openSeedFile () {
|
function openSeedFile () {
|
||||||
|
if (!windows.main.win) return
|
||||||
var opts = {
|
var opts = {
|
||||||
title: 'Select a file for the torrent file.',
|
title: 'Select a file for the torrent.',
|
||||||
properties: [ 'openFile' ]
|
properties: [ 'openFile' ]
|
||||||
}
|
}
|
||||||
electron.dialog.showOpenDialog(opts, function (selectedPaths) {
|
setTitle(opts.title)
|
||||||
|
electron.dialog.showOpenDialog(windows.main.win, opts, function (selectedPaths) {
|
||||||
|
resetTitle()
|
||||||
if (!Array.isArray(selectedPaths)) return
|
if (!Array.isArray(selectedPaths)) return
|
||||||
windows.main.send('dispatch', 'showCreateTorrent', selectedPaths)
|
windows.main.send('dispatch', 'showCreateTorrent', selectedPaths)
|
||||||
})
|
})
|
||||||
@@ -24,15 +28,23 @@ function openSeedFile () {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Show open dialog to create a single-file or single-directory torrent. On
|
* Show open dialog to create a single-file or single-directory torrent. On
|
||||||
* Windows and Linux, open dialogs are for files *or* directories only, not both.
|
* Windows and Linux, open dialogs are for files *or* directories only, not both,
|
||||||
* This function shows a directory dialog.
|
* so this function shows a directory dialog on those platforms.
|
||||||
*/
|
*/
|
||||||
function openSeedDirectory () {
|
function openSeedDirectory () {
|
||||||
var opts = {
|
if (!windows.main.win) return
|
||||||
title: 'Select a file or folder for the torrent file.',
|
var opts = process.platform === 'darwin'
|
||||||
properties: [ 'openFile', 'openDirectory' ]
|
? {
|
||||||
}
|
title: 'Select a file or folder for the torrent.',
|
||||||
electron.dialog.showOpenDialog(opts, function (selectedPaths) {
|
properties: [ 'openFile', 'openDirectory' ]
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
title: 'Select a folder for the torrent.',
|
||||||
|
properties: [ 'openDirectory' ]
|
||||||
|
}
|
||||||
|
setTitle(opts.title)
|
||||||
|
electron.dialog.showOpenDialog(windows.main.win, opts, function (selectedPaths) {
|
||||||
|
resetTitle()
|
||||||
if (!Array.isArray(selectedPaths)) return
|
if (!Array.isArray(selectedPaths)) return
|
||||||
windows.main.send('dispatch', 'showCreateTorrent', selectedPaths)
|
windows.main.send('dispatch', 'showCreateTorrent', selectedPaths)
|
||||||
})
|
})
|
||||||
@@ -42,12 +54,15 @@ function openSeedDirectory () {
|
|||||||
* Show open dialog to open a .torrent file.
|
* Show open dialog to open a .torrent file.
|
||||||
*/
|
*/
|
||||||
function openTorrentFile () {
|
function openTorrentFile () {
|
||||||
|
if (!windows.main.win) return
|
||||||
var opts = {
|
var opts = {
|
||||||
title: 'Select a .torrent file to open.',
|
title: 'Select a .torrent file to open.',
|
||||||
filters: [{ name: 'Torrent Files', extensions: ['torrent'] }],
|
filters: [{ name: 'Torrent Files', extensions: ['torrent'] }],
|
||||||
properties: [ 'openFile', 'multiSelections' ]
|
properties: [ 'openFile', 'multiSelections' ]
|
||||||
}
|
}
|
||||||
|
setTitle(opts.title)
|
||||||
electron.dialog.showOpenDialog(windows.main.win, opts, function (selectedPaths) {
|
electron.dialog.showOpenDialog(windows.main.win, opts, function (selectedPaths) {
|
||||||
|
resetTitle()
|
||||||
if (!Array.isArray(selectedPaths)) return
|
if (!Array.isArray(selectedPaths)) return
|
||||||
selectedPaths.forEach(function (selectedPath) {
|
selectedPaths.forEach(function (selectedPath) {
|
||||||
windows.main.send('dispatch', 'addTorrent', selectedPath)
|
windows.main.send('dispatch', 'addTorrent', selectedPath)
|
||||||
@@ -61,3 +76,16 @@ function openTorrentFile () {
|
|||||||
function openTorrentAddress () {
|
function openTorrentAddress () {
|
||||||
windows.main.send('showOpenTorrentAddress')
|
windows.main.send('showOpenTorrentAddress')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dialogs on do not show a title on OS X, so the window title is used instead.
|
||||||
|
*/
|
||||||
|
function setTitle (title) {
|
||||||
|
if (process.platform === 'darwin') {
|
||||||
|
windows.main.send('dispatch', 'setTitle', title)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetTitle () {
|
||||||
|
setTitle(config.APP_WINDOW_TITLE)
|
||||||
|
}
|
||||||
|
|||||||
@@ -377,6 +377,9 @@ function dispatch (action, ...args) {
|
|||||||
if (action === 'saveState') {
|
if (action === 'saveState') {
|
||||||
saveState()
|
saveState()
|
||||||
}
|
}
|
||||||
|
if (action === 'setTitle') {
|
||||||
|
state.window.title = args[0] /* title */
|
||||||
|
}
|
||||||
|
|
||||||
// Update the virtual-dom, unless it's just a mouse move event
|
// Update the virtual-dom, unless it's just a mouse move event
|
||||||
if (action !== 'mediaMouseMoved' || showOrHidePlayerControls()) {
|
if (action !== 'mediaMouseMoved' || showOrHidePlayerControls()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user