mirror of
https://github.com/Fabio286/antares.git
synced 2025-02-09 08:18:43 +01:00
fix(Linux): ctrl+space shortcut not working
This commit is contained in:
parent
e0946f04f7
commit
ed3d35f131
13
src/common/shortcuts.ts
Normal file
13
src/common/shortcuts.ts
Normal file
@ -0,0 +1,13 @@
|
||||
interface ShortcutRecord {
|
||||
event: string;
|
||||
keys: Electron.Accelerator;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export const shortcuts: ShortcutRecord[] = [
|
||||
{
|
||||
event: 'open-connections-modal',
|
||||
keys: 'CommandOrControl+Space',
|
||||
description: 'Show all connections'
|
||||
}
|
||||
];
|
@ -1,10 +1,11 @@
|
||||
import { app, BrowserWindow, /* session, */ nativeImage, Menu, ipcMain } from 'electron';
|
||||
import { app, BrowserWindow, globalShortcut, nativeImage, Menu, ipcMain } from 'electron';
|
||||
import * as path from 'path';
|
||||
import * as Store from 'electron-store';
|
||||
import * as windowStateKeeper from 'electron-window-state';
|
||||
import * as remoteMain from '@electron/remote/main';
|
||||
|
||||
import ipcHandlers from './ipc-handlers';
|
||||
import { shortcuts } from 'common/shortcuts';
|
||||
|
||||
Store.initRenderer();
|
||||
const persistentStore = new Store({ name: 'settings' });
|
||||
@ -142,6 +143,27 @@ else {
|
||||
window.webContents.session.loadExtension(extensionPath, { allowFileAccess: true }).catch(console.error);
|
||||
}
|
||||
});
|
||||
|
||||
app.on('browser-window-focus', () => {
|
||||
// Send registered shortcut events to window
|
||||
for (const shortcut of shortcuts) {
|
||||
globalShortcut.register(shortcut.keys, () => {
|
||||
mainWindow.webContents.send(shortcut.event);
|
||||
if (isDevelopment) console.log('EVENT:', shortcut);
|
||||
});
|
||||
}
|
||||
|
||||
// Main process shortcuts
|
||||
if (isDevelopment) {
|
||||
globalShortcut.register('CommandOrControl+F12', () => {
|
||||
mainWindow.webContents.openDevTools();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
app.on('browser-window-blur', () => {
|
||||
globalShortcut.unregisterAll();
|
||||
});
|
||||
}
|
||||
|
||||
function createAppMenu () {
|
||||
|
@ -26,7 +26,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineAsyncComponent, onBeforeUnmount, onMounted, Ref, ref } from 'vue';
|
||||
import { defineAsyncComponent, onMounted, Ref, ref } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { ipcRenderer } from 'electron';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
@ -67,14 +67,9 @@ const { changeApplicationTheme } = settingsStore;
|
||||
|
||||
const isAllConnectionsModal: Ref<boolean> = ref(false);
|
||||
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
if (e.ctrlKey || e.metaKey) {
|
||||
if (e.code === 'Space') {
|
||||
isAllConnectionsModal.value = true;
|
||||
e.stopPropagation();
|
||||
}
|
||||
}
|
||||
};
|
||||
ipcRenderer.on('open-connections-modal', () => {
|
||||
isAllConnectionsModal.value = true;
|
||||
});
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
setTimeout(() => {
|
||||
@ -82,8 +77,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
window.addEventListener('keypress', onKey);
|
||||
|
||||
onMounted(() => {
|
||||
ipcRenderer.send('check-for-updates');
|
||||
checkVersionUpdate();
|
||||
@ -126,10 +119,6 @@ onMounted(() => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener('keydown', onKey);
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
Loading…
x
Reference in New Issue
Block a user