open-stage-control/app/main/electron-app.js

109 lines
2.8 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var {app, Menu, shell, dialog} = require('electron'),
settings = require('./settings'),
path = require('path'),
infos = require('../package.json')
app.commandLine.appendSwitch('--touch-events')
if (settings.read('noVsync') || (!settings.cli && settings.read('argv')['disable-vsync'])) {
app.commandLine.appendSwitch('--disable-gpu-vsync')
}
if (settings.read('noGpu') || (!settings.cli && settings.read('argv')['disable-gpu'])) {
app.disableHardwareAcceleration()
}
app.on('window-all-closed', function() {
if (process.platform != 'darwin') {
app.quit()
}
})
var template = [{
label: 'Edit',
submenu: [
{role: 'undo', accelerator: "CmdOrCtrl+Z"},
{role: 'redo', accelerator: "Shift+CmdOrCtrl+Z"},
{type: 'separator'},
{role: 'cut', accelerator: "CmdOrCtrl+X"},
{role: 'copy', accelerator: "CmdOrCtrl+C"},
{role: 'paste', accelerator: "CmdOrCtrl+V"}
]
}]
if (process.platform === 'darwin') {
// Add app menu (OS X)
template.unshift({
label: settings.read('appName'),
submenu: [
{
label: 'Hide ' + infos.productName,
accelerator: 'Command+H',
role: 'hide'
},
{
label: 'Hide Others',
accelerator: 'Command+Alt+H',
role: 'hideothers'
},
{
label: 'Show All',
role: 'unhide'
},
{
type: 'separator'
},
{
label: 'Quit',
accelerator: 'Command+Q',
click: () => app.quit()
}
]
})
// Add Window menu (OS X)
template.push(
{
label: 'Window',
role: 'window',
submenu: [
{
label: 'Minimize',
accelerator: 'CmdOrCtrl+M',
role: 'minimize'
},
{
type: 'separator'
},
{
label: 'Bring All to Front',
role: 'front'
}
]
},
{
label: 'Help',
role: 'help',
submenu: [
{
label: 'Documentation',
click: () => shell.openExternal(infos.homepage)
},
{
type: 'separator'
},
{
label: 'Report an Issue',
click: () => shell.openExternal(infos.repository.url + '/issues')
}
]
}
)
}
var menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)
module.exports = app