1
1
mirror of https://github.com/Fabio286/antares.git synced 2025-02-09 08:18:43 +01:00

fix: disable ctrl+alt+(left/right) shortcut on linux

This commit is contained in:
Fabio Di Stasio 2022-07-21 11:01:10 +02:00
parent 8c83b3f144
commit 8ecaedbf6c
2 changed files with 34 additions and 12 deletions

View File

@ -2,38 +2,57 @@ interface ShortcutRecord {
event: string; event: string;
keys: Electron.Accelerator[]; keys: Electron.Accelerator[];
description: string; description: string;
os: NodeJS.Platform[];
} }
const shortcuts: ShortcutRecord[] = [ const shortcuts: ShortcutRecord[] = [
{ {
event: 'open-new-tab', event: 'open-new-tab',
keys: ['CommandOrControl+T'], keys: ['CommandOrControl+T'],
description: 'Open a new query tab' description: 'Open a new query tab',
os: ['darwin', 'linux', 'win32']
}, },
{ {
event: 'close-tab', event: 'close-tab',
keys: ['CommandOrControl+W'], keys: ['CommandOrControl+W'],
description: 'Close tab' description: 'Close tab',
os: ['darwin', 'linux', 'win32']
}, },
{ {
event: 'next-tab', event: 'next-tab',
keys: ['Alt+CommandOrControl+Right', 'CommandOrControl+PageDown'], keys: ['Alt+CommandOrControl+Right', 'CommandOrControl+PageDown'],
description: 'Next tab' description: 'Next tab',
os: ['darwin', 'win32']
}, },
{ {
event: 'prev-tab', event: 'prev-tab',
keys: ['Alt+CommandOrControl+Left', 'CommandOrControl+PageUp'], keys: ['Alt+CommandOrControl+Left', 'CommandOrControl+PageUp'],
description: 'Previous tab' description: 'Previous tab',
os: ['darwin', 'win32']
},
{
event: 'next-tab',
keys: ['CommandOrControl+PageDown'],
description: 'Next tab',
os: ['linux']
},
{
event: 'prev-tab',
keys: ['CommandOrControl+PageUp'],
description: 'Previous tab',
os: ['linux']
}, },
{ {
event: 'open-connections-modal', event: 'open-connections-modal',
keys: ['Shift+CommandOrControl+Space'], keys: ['Shift+CommandOrControl+Space'],
description: 'Show all connections' description: 'Show all connections',
os: ['darwin', 'linux', 'win32']
}, },
{ {
event: 'toggle-console', event: 'toggle-console',
keys: ['CommandOrControl+F12', 'CommandOrControl+`'], keys: ['CommandOrControl+F12', 'CommandOrControl+`'],
description: 'Toggle console' description: 'Toggle console',
os: ['darwin', 'linux', 'win32']
} }
]; ];
@ -42,7 +61,8 @@ for (let i = 1; i <= 9; i++) {
{ {
event: `select-tab-${i}`, event: `select-tab-${i}`,
keys: [`CommandOrControl+${i}`], keys: [`CommandOrControl+${i}`],
description: `Select tab number ${i}` description: `Select tab number ${i}`,
os: ['darwin', 'linux', 'win32']
}); });
} }

View File

@ -147,6 +147,7 @@ else {
app.on('browser-window-focus', () => { app.on('browser-window-focus', () => {
// Send registered shortcut events to window // Send registered shortcut events to window
for (const shortcut of shortcuts) { for (const shortcut of shortcuts) {
if (shortcut.os.includes(process.platform)) {
for (const key of shortcut.keys) { for (const key of shortcut.keys) {
globalShortcut.register(key, () => { globalShortcut.register(key, () => {
mainWindow.webContents.send(shortcut.event); mainWindow.webContents.send(shortcut.event);
@ -154,6 +155,7 @@ else {
}); });
} }
} }
}
if (isDevelopment) { // Dev shortcuts if (isDevelopment) { // Dev shortcuts
globalShortcut.register('Shift+CommandOrControl+F5', () => { globalShortcut.register('Shift+CommandOrControl+F5', () => {