Skip to content

Commit

Permalink
Ctrl+Q closes app (#4107)
Browse files Browse the repository at this point in the history
- handle ctrl+q when main window is focused to properly close the app

- #4084 tested on Windows, need further testing
  • Loading branch information
maxphilippov authored Sep 9, 2024
1 parent dc1cc6f commit 598d7f5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
### Fixed
- fix newlines in messages with WebXDC attachments #4079
- being unable to delete a nonfunctional account imported from ArcaneChat #4104
- Ctrl/Cmd+Q (also File->Quit) now should properly close the app when focus is on main window

<a id="1_46_7"></a>

Expand Down
28 changes: 15 additions & 13 deletions src/main/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import * as mainWindow from './windows/main.js'
import { DesktopSettings } from './desktop_settings.js'
import { getCurrentLocaleDate, tx } from './load-translations.js'
import { mapPackagePath } from './isAppx.js'
import { quitDeltaChat } from './tray.js'

const __dirname = dirname(fileURLToPath(import.meta.url))

Expand Down Expand Up @@ -181,29 +182,30 @@ export function getFileMenu(
const fileMenuNonMac: Electron.MenuItemConstructorOptions = {
label: tx('global_menu_file_desktop'),
submenu: (() => {
let result = [
{
label:
window === mainWindow.window
? tx('global_menu_file_quit_desktop')
: tx('close_window'),
click: () => window?.close(),
accelerator: 'Ctrl+q',
},
]
if (window === mainWindow.window) {
result = [
return [
{
label: tx('menu_settings'),
click: () => {
mainWindow.send('showSettingsDialog')
},
accelerator: 'Ctrl+,',
},
...result,
{
label: tx('global_menu_file_quit_desktop'),
click: quitDeltaChat,
accelerator: 'Ctrl+q',
},
]
} else {
return [
{
label: tx('close_window'),
click: () => window?.close(),
accelerator: 'Ctrl+q',
},
]
}
return result
})(),
}
const fileMenuMac: Electron.MenuItemConstructorOptions = {
Expand Down
2 changes: 1 addition & 1 deletion src/main/tray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function hideOrShowDeltaChat() {
mainWindowIsVisible() ? hideDeltaChat(true) : showDeltaChat()
}

function quitDeltaChat() {
export function quitDeltaChat() {
globalShortcut.unregisterAll()
app.quit()
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/windows/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export function send(channel: string, ...args: any[]) {
return
}
if (window.isDestroyed()) {
log.warn('window is destroyed. not sending message', args)
log.info('window is destroyed. not sending message', args)
return
}
try {
Expand Down

0 comments on commit 598d7f5

Please sign in to comment.