Merge pull request #752 from feross/user-tasks
Add User Tasks for Windows.
This commit is contained in:
@@ -17,6 +17,7 @@ var menu = require('./menu')
|
||||
var squirrelWin32 = require('./squirrel-win32')
|
||||
var tray = require('./tray')
|
||||
var updater = require('./updater')
|
||||
var userTasks = require('./user-tasks')
|
||||
var windows = require('./windows')
|
||||
|
||||
var shouldQuit = false
|
||||
@@ -109,6 +110,7 @@ function delayedInit () {
|
||||
handlers.install()
|
||||
tray.init()
|
||||
updater.init()
|
||||
userTasks.init()
|
||||
}
|
||||
|
||||
function onOpen (e, torrentId) {
|
||||
|
||||
43
src/main/user-tasks.js
Normal file
43
src/main/user-tasks.js
Normal file
@@ -0,0 +1,43 @@
|
||||
module.exports = {
|
||||
init
|
||||
}
|
||||
|
||||
var electron = require('electron')
|
||||
|
||||
var app = electron.app
|
||||
|
||||
/**
|
||||
* Add a user task menu to the app icon on right-click. (Windows)
|
||||
*/
|
||||
function init () {
|
||||
if (process.platform !== 'win32') return
|
||||
app.setUserTasks(getUserTasks())
|
||||
}
|
||||
|
||||
function getUserTasks () {
|
||||
return [
|
||||
{
|
||||
arguments: '-n',
|
||||
title: 'Create New Torrent...',
|
||||
description: 'Create a new torrent'
|
||||
},
|
||||
{
|
||||
arguments: '-o',
|
||||
title: 'Open Torrent File...',
|
||||
description: 'Open a .torrent file'
|
||||
},
|
||||
{
|
||||
arguments: '-u',
|
||||
title: 'Open Torrent Address...',
|
||||
description: 'Open a torrent from a URL'
|
||||
}
|
||||
].map(getUserTasksItem)
|
||||
}
|
||||
|
||||
function getUserTasksItem (item) {
|
||||
return Object.assign(item, {
|
||||
program: process.execPath,
|
||||
iconPath: process.execPath,
|
||||
iconIndex: 0
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user