tray: make it optional and disabled by default

This commit is contained in:
jean-emmanuel 2025-07-22 19:24:50 +02:00
parent 89b82d3c9b
commit 5cf59ea97c
3 changed files with 42 additions and 25 deletions

View file

@ -115,14 +115,6 @@ menu.append(new MenuItem({type: 'submenu' , label: 'Launcher', submenu: [
remote.getCurrentWindow().setAlwaysOnTop(e.checked)
}
}),
new MenuItem({
label: 'Start hidden (in tray)',
type: 'checkbox',
checked: settings.remote.read('startMinimized'),
click: (e)=>{
settings.remote.write('startMinimized', e.checked)
}
}),
new MenuItem({
label: 'Always on top',
type: 'checkbox',
@ -131,7 +123,23 @@ menu.append(new MenuItem({type: 'submenu' , label: 'Launcher', submenu: [
settings.remote.write('alwaysOnTop', e.checked)
remote.getCurrentWindow().setAlwaysOnTop(e.checked)
}
})
}),
new MenuItem({
label: 'Use tray icon',
type: 'checkbox',
checked: settings.remote.read('useTray'),
click: (e)=>{
settings.remote.write('useTray', e.checked)
}
}),
new MenuItem({
label: 'Start minimized',
type: 'checkbox',
checked: settings.remote.read('startMinimized'),
click: (e)=>{
settings.remote.write('startMinimized', e.checked)
}
}),
]}))
menu.append(new MenuItem({
type: 'separator'

View file

@ -62,7 +62,11 @@ module.exports = function(options={}) {
window.once('ready-to-show', ()=>{
if (options.id === 'launcher' && settings.read('startMinimized')) {
window.hide()
if (settings.read('useTray') || process.platform === 'darwin') {
window.hide()
} else {
window.minimize()
}
}
})

View file

@ -225,23 +225,28 @@ function startLauncher() {
launcher = require('./electron-window')({address:address, shortcuts:dev, width:680, height:(40 + 200 + 20 + 24 * Object.keys(settings.options).filter(x=>settings.options[x].launcher !== false).length / 2), node:true, color:'#151a24', id: 'launcher'})
require('@electron/remote/main').enable(launcher.webContents)
tray = require('./tray')({
window: launcher,
openClient: openClient,
app: app,
startServer: startServerProcess,
stopServer: stopServerProcess
})
if (settings.read('useTray')) {
tray = require('./tray')({
window: launcher,
openClient: openClient,
app: app,
startServer: startServerProcess,
stopServer: stopServerProcess
})
launcher.on('will-close', ()=>{
if (clientWindows.some(w=>w && !w.isDestroyed())) {
launcher.hide()
e.preventDefault()
}
})
}
launcher.on('will-close', ()=>{
if (clientWindows.some(w=>w && !w.isDestroyed())) {
launcher.hide()
e.preventDefault()
}
})
launcher.on('close', (e)=>{
if (clientWindows.some(w=>w && !w.isDestroyed()) && serverProcess) {
if (tray && clientWindows.some(w=>w && !w.isDestroyed()) && serverProcess) {
launcher.hide()
e.preventDefault()
return
@ -249,7 +254,7 @@ function startLauncher() {
process.stdout.write = stdoutWrite
process.stderr.write = stderrWrite
if (process.log) process.log = processLog
tray.destroy()
if (tray) tray.destroy()
})
})