From 49b63bc6f28fc6031e6a892d0a48cd35ae2f26cd Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Tue, 9 Aug 2022 16:10:08 +0200 Subject: [PATCH] feat(UI): shortcuts setting UI improved --- src/common/shortcuts.ts | 31 ++++- src/main/libs/ShortcutRegister.ts | 3 +- .../components/ModalAllConnections.vue | 118 +++++++++--------- src/renderer/components/ModalSettings.vue | 8 +- .../components/ModalSettingsShortcuts.vue | 58 ++++++++- src/renderer/components/TheSettingBar.vue | 6 +- .../WorkspaceAddConnectionPanel.vue | 2 +- .../WorkspaceEditConnectionPanel.vue | 2 +- .../components/WorkspaceQueryConsole.vue | 107 ++++++++-------- src/renderer/i18n/en-US.ts | 8 +- src/renderer/scss/_variables.scss | 15 +-- src/renderer/scss/main.scss | 3 +- src/renderer/scss/themes/dark-theme.scss | 8 +- src/renderer/scss/themes/light-theme.scss | 12 +- src/renderer/stores/settings.ts | 3 +- 15 files changed, 229 insertions(+), 155 deletions(-) diff --git a/src/common/shortcuts.ts b/src/common/shortcuts.ts index 4bbc8018..477e8300 100644 --- a/src/common/shortcuts.ts +++ b/src/common/shortcuts.ts @@ -1,7 +1,9 @@ interface ShortcutRecord { event: string; keys: Electron.Accelerator[]; - description: string; + description?: string; + l18nSlug: string; + l18nParam?: string | number; os: NodeJS.Platform[]; } @@ -10,48 +12,63 @@ const shortcuts: ShortcutRecord[] = [ event: 'open-new-tab', keys: ['CommandOrControl+T'], description: 'Open a new query tab', + l18nSlug: 'message.openNewTab', os: ['darwin', 'linux', 'win32'] }, { event: 'close-tab', keys: ['CommandOrControl+W'], description: 'Close tab', + l18nSlug: 'message.closeTab', os: ['darwin', 'linux', 'win32'] }, { event: 'next-tab', - keys: ['Alt+CommandOrControl+Right', 'CommandOrControl+PageDown'], + keys: ['Alt+CommandOrControl+Right'], description: 'Next tab', + l18nSlug: 'message.nextTab', os: ['darwin', 'win32'] }, { event: 'prev-tab', - keys: ['Alt+CommandOrControl+Left', 'CommandOrControl+PageUp'], + keys: ['Alt+CommandOrControl+Left'], description: 'Previous tab', + l18nSlug: 'message.previousTab', os: ['darwin', 'win32'] }, { event: 'next-tab', keys: ['CommandOrControl+PageDown'], description: 'Next tab', - os: ['linux'] + l18nSlug: 'message.nextTab', + os: ['linux', 'win32'] }, { event: 'prev-tab', keys: ['CommandOrControl+PageUp'], description: 'Previous tab', - os: ['linux'] + l18nSlug: 'message.previousTab', + os: ['linux', 'win32'] }, { event: 'open-connections-modal', keys: ['Shift+CommandOrControl+Space'], description: 'Show all connections', + l18nSlug: 'message.allConnections', os: ['darwin', 'linux', 'win32'] }, { event: 'toggle-console', - keys: ['CommandOrControl+F12', 'CommandOrControl+`'], + keys: ['CommandOrControl+F12'], description: 'Toggle console', + l18nSlug: 'message.toggleConsole', + os: ['darwin', 'linux', 'win32'] + }, + { + event: 'toggle-console', + keys: ['CommandOrControl+`'], + description: 'Toggle console', + l18nSlug: 'message.toggleConsole', os: ['darwin', 'linux', 'win32'] } ]; @@ -62,6 +79,8 @@ for (let i = 1; i <= 9; i++) { event: `select-tab-${i}`, keys: [`CommandOrControl+${i}`], description: `Select tab number ${i}`, + l18nSlug: 'message.selectTabNumber', + l18nParam: i, os: ['darwin', 'linux', 'win32'] }); } diff --git a/src/main/libs/ShortcutRegister.ts b/src/main/libs/ShortcutRegister.ts index dd689c50..9fb2db36 100644 --- a/src/main/libs/ShortcutRegister.ts +++ b/src/main/libs/ShortcutRegister.ts @@ -1,8 +1,9 @@ import { BrowserWindow, globalShortcut } from 'electron'; import * as Store from 'electron-store'; -import { ShortcutRecord, shortcuts as defaultShortcuts } from 'common/shortcuts'; +import { ShortcutRecord, shortcuts } from 'common/shortcuts'; const shortcutsStore = new Store({ name: 'shortcuts' }); const isDevelopment = process.env.NODE_ENV !== 'production'; +const defaultShortcuts = shortcuts.filter(s => s.os.includes(process.platform)); export class ShortcutRegister { private _shortcuts: ShortcutRecord[]; diff --git a/src/renderer/components/ModalAllConnections.vue b/src/renderer/components/ModalAllConnections.vue index 09910111..ea9f840a 100644 --- a/src/renderer/components/ModalAllConnections.vue +++ b/src/renderer/components/ModalAllConnections.vue @@ -126,7 +126,7 @@ key="trick" readonly class="p-absolute" - style="width: 1px; height: 1px; opacity: 0" + style="width: 1px; height: 1px; opacity: 0;" type="text" > @@ -270,89 +270,87 @@ onBeforeUnmount(() => { diff --git a/src/renderer/components/ModalSettings.vue b/src/renderer/components/ModalSettings.vue index 55e04835..c256be68 100644 --- a/src/renderer/components/ModalSettings.vue +++ b/src/renderer/components/ModalSettings.vue @@ -549,10 +549,10 @@ onBeforeUnmount(() => { .modal-body { overflow: hidden; - .tab-link{ - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; + .tab-link { + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; } .panel-body { diff --git a/src/renderer/components/ModalSettingsShortcuts.vue b/src/renderer/components/ModalSettingsShortcuts.vue index 7f84eaf7..97cc563c 100644 --- a/src/renderer/components/ModalSettingsShortcuts.vue +++ b/src/renderer/components/ModalSettingsShortcuts.vue @@ -1,5 +1,13 @@