mirror of
https://github.com/Fabio286/antares.git
synced 2025-02-10 00:30:48 +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 path from 'path';
|
||||||
import * as Store from 'electron-store';
|
import * as Store from 'electron-store';
|
||||||
import * as windowStateKeeper from 'electron-window-state';
|
import * as windowStateKeeper from 'electron-window-state';
|
||||||
import * as remoteMain from '@electron/remote/main';
|
import * as remoteMain from '@electron/remote/main';
|
||||||
|
|
||||||
import ipcHandlers from './ipc-handlers';
|
import ipcHandlers from './ipc-handlers';
|
||||||
|
import { shortcuts } from 'common/shortcuts';
|
||||||
|
|
||||||
Store.initRenderer();
|
Store.initRenderer();
|
||||||
const persistentStore = new Store({ name: 'settings' });
|
const persistentStore = new Store({ name: 'settings' });
|
||||||
@ -142,6 +143,27 @@ else {
|
|||||||
window.webContents.session.loadExtension(extensionPath, { allowFileAccess: true }).catch(console.error);
|
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 () {
|
function createAppMenu () {
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { defineAsyncComponent, onBeforeUnmount, onMounted, Ref, ref } from 'vue';
|
import { defineAsyncComponent, onMounted, Ref, ref } from 'vue';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { ipcRenderer } from 'electron';
|
import { ipcRenderer } from 'electron';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
@ -67,14 +67,9 @@ const { changeApplicationTheme } = settingsStore;
|
|||||||
|
|
||||||
const isAllConnectionsModal: Ref<boolean> = ref(false);
|
const isAllConnectionsModal: Ref<boolean> = ref(false);
|
||||||
|
|
||||||
const onKey = (e: KeyboardEvent) => {
|
ipcRenderer.on('open-connections-modal', () => {
|
||||||
if (e.ctrlKey || e.metaKey) {
|
isAllConnectionsModal.value = true;
|
||||||
if (e.code === 'Space') {
|
});
|
||||||
isAllConnectionsModal.value = true;
|
|
||||||
e.stopPropagation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@ -82,8 +77,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener('keypress', onKey);
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
ipcRenderer.send('check-for-updates');
|
ipcRenderer.send('check-for-updates');
|
||||||
checkVersionUpdate();
|
checkVersionUpdate();
|
||||||
@ -126,10 +119,6 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
window.removeEventListener('keydown', onKey);
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user