correct full screen menu item state after using OS fullscreen button
This commit is contained in:
27
index.js
27
index.js
@@ -21,7 +21,7 @@ app.on('open-file', onOpen)
|
|||||||
app.on('open-url', onOpen)
|
app.on('open-url', onOpen)
|
||||||
|
|
||||||
app.on('ready', function () {
|
app.on('ready', function () {
|
||||||
mainWindow = createMainWindow()
|
createMainWindow()
|
||||||
|
|
||||||
menu = electron.Menu.buildFromTemplate(getMenuTemplate())
|
menu = electron.Menu.buildFromTemplate(getMenuTemplate())
|
||||||
electron.Menu.setApplicationMenu(menu)
|
electron.Menu.setApplicationMenu(menu)
|
||||||
@@ -31,7 +31,7 @@ app.on('activate', function () {
|
|||||||
if (mainWindow) {
|
if (mainWindow) {
|
||||||
mainWindow.show()
|
mainWindow.show()
|
||||||
} else {
|
} else {
|
||||||
mainWindow = createMainWindow()
|
createMainWindow()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ electron.ipcMain.on('setProgress', function (e, progress) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
function createMainWindow () {
|
function createMainWindow () {
|
||||||
var win = new electron.BrowserWindow({
|
mainWindow = new electron.BrowserWindow({
|
||||||
backgroundColor: '#282828',
|
backgroundColor: '#282828',
|
||||||
darkTheme: true,
|
darkTheme: true,
|
||||||
minWidth: 375,
|
minWidth: 375,
|
||||||
@@ -78,23 +78,24 @@ function createMainWindow () {
|
|||||||
width: 450,
|
width: 450,
|
||||||
height: 300
|
height: 300
|
||||||
})
|
})
|
||||||
win.loadURL('file://' + path.join(__dirname, 'main', 'index.html'))
|
mainWindow.loadURL('file://' + path.join(__dirname, 'main', 'index.html'))
|
||||||
win.webContents.on('did-finish-load', function () {
|
mainWindow.webContents.on('did-finish-load', function () {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
debug('startup time: %sms', Date.now() - startTime)
|
debug('startup time: %sms', Date.now() - startTime)
|
||||||
win.show()
|
mainWindow.show()
|
||||||
}, 50)
|
}, 50)
|
||||||
})
|
})
|
||||||
win.on('close', function (e) {
|
mainWindow.on('enter-full-screen', onToggleFullScreen)
|
||||||
|
mainWindow.on('leave-full-screen', onToggleFullScreen)
|
||||||
|
mainWindow.on('close', function (e) {
|
||||||
if (process.platform === 'darwin' && !isQuitting) {
|
if (process.platform === 'darwin' && !isQuitting) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
win.hide()
|
mainWindow.hide()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
win.once('closed', function () {
|
mainWindow.once('closed', function () {
|
||||||
mainWindow = null
|
mainWindow = null
|
||||||
})
|
})
|
||||||
return win
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onOpen (e, torrentId) {
|
function onOpen (e, torrentId) {
|
||||||
@@ -144,10 +145,14 @@ function toggleFullScreen () {
|
|||||||
debug('toggleFullScreen')
|
debug('toggleFullScreen')
|
||||||
if (mainWindow) {
|
if (mainWindow) {
|
||||||
mainWindow.setFullScreen(!mainWindow.isFullScreen())
|
mainWindow.setFullScreen(!mainWindow.isFullScreen())
|
||||||
getMenuItem('Full Screen').checked = mainWindow.isFullScreen()
|
onToggleFullScreen()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onToggleFullScreen () {
|
||||||
|
getMenuItem('Full Screen').checked = mainWindow.isFullScreen()
|
||||||
|
}
|
||||||
|
|
||||||
// Sets whether the window should always show on top of other windows
|
// Sets whether the window should always show on top of other windows
|
||||||
function toggleAlwaysOnTop () {
|
function toggleAlwaysOnTop () {
|
||||||
debug('toggleAlwaysOnTop %s')
|
debug('toggleAlwaysOnTop %s')
|
||||||
|
|||||||
Reference in New Issue
Block a user