diff --git a/src/renderer/components/ModalSettings.vue b/src/renderer/components/ModalSettings.vue index 68cec433..d4efc8da 100644 --- a/src/renderer/components/ModalSettings.vue +++ b/src/renderer/components/ModalSettings.vue @@ -210,6 +210,28 @@ +
+ {{ t('word.resultsTable') }} +
+
+
+
+ +
+
+ +
+
+
@@ -393,6 +415,7 @@ const { autoComplete: selectedAutoComplete, lineWrap: selectedLineWrap, executeSelected: selectedExecuteSelected, + defaultCopyType: selectedCopyType, notificationsTimeout, restoreTabs, disableBlur, @@ -416,7 +439,8 @@ const { changeApplicationTheme, changeEditorTheme, changeEditorFontSize, - updateNotificationsTimeout + updateNotificationsTimeout, + changeDefaultCopyType } = settingsStore; const { hideSettingModal: closeModal, @@ -432,7 +456,7 @@ const appLogo = require('../images/logo.svg'); const darkPreview = require('../images/dark.png'); const lightPreview = require('../images/light.png'); const exampleQuery = `-- This is an example -SELECT +SELECT employee.id, employee.first_name, employee.last_name, @@ -448,6 +472,7 @@ ORDER BY `; const localLocale: Ref = ref(null); +const defaultCopyType: Ref = ref(null); const localPageSize: Ref = ref(null); const localTimeout: Ref = ref(null); const localEditorTheme: Ref = ref(null); @@ -511,6 +536,14 @@ const locales = computed(() => { return locales; }); +const copyTypes = computed(() => [ + { code: 'cell', name: t('word.cell') }, + { code: 'html', name: t('word.table') }, + { code: 'json', name: 'JSON' }, + { code: 'csv', name: 'CSV' }, + { code: 'sql', name: 'SQL insert' } +]); + const hasUpdates = computed(() => ['available', 'downloading', 'downloaded', 'link'].includes(updateStatus.value)); const workspace = computed(() => { @@ -570,6 +603,7 @@ const toggleExecuteSelected = () => { }; localLocale.value = selectedLocale.value; +defaultCopyType.value = selectedCopyType.value; localPageSize.value = pageSize.value as number; localTimeout.value = notificationsTimeout.value as number; localEditorTheme.value = editorTheme.value as string; diff --git a/src/renderer/components/WorkspaceTabQueryTable.vue b/src/renderer/components/WorkspaceTabQueryTable.vue index bf415671..f4941eee 100644 --- a/src/renderer/components/WorkspaceTabQueryTable.vue +++ b/src/renderer/components/WorkspaceTabQueryTable.vue @@ -142,7 +142,7 @@ const settingsStore = useSettingsStore(); const consoleStore = useConsoleStore(); const { getWorkspace } = useWorkspacesStore(); -const { dataTabLimit: pageSize } = storeToRefs(settingsStore); +const { dataTabLimit: pageSize, defaultCopyType } = storeToRefs(settingsStore); const { consoleHeight } = storeToRefs(consoleStore); @@ -697,6 +697,18 @@ const onKey = async (e: KeyboardEvent) => { if ((e.ctrlKey || e.metaKey) && e.code === 'KeyA' && !e.altKey) selectAllRows(e); + if ((e.ctrlKey || e.metaKey) && e.code === 'KeyC' && !e.altKey) { + const copyType = defaultCopyType.value; + if (selectedRows.value.length >= 1) { + if (selectedRows.value.length === 1 && copyType === 'cell') + await navigator.clipboard.writeText(scrollElement.value.querySelector('.td.selected').innerText); + else if (selectedRows.value.length > 1 && copyType === 'cell') + copyRow('html'); + else + copyRow(copyType); + } + } + // row navigation stuff if (!(e.ctrlKey || e.metaKey) && (e.code.includes('Arrow') || e.code === 'Tab') && sortedResults.value.length > 0 && !e.altKey) { e.preventDefault(); diff --git a/src/renderer/i18n/en-US.ts b/src/renderer/i18n/en-US.ts index be51482d..f5192ef7 100644 --- a/src/renderer/i18n/en-US.ts +++ b/src/renderer/i18n/en-US.ts @@ -148,7 +148,8 @@ export const enUS = { appearence: 'Appearence', color: 'Color', label: 'Label', - icon: 'Icon' + icon: 'Icon', + resultsTable: 'Results table' }, message: { appWelcome: 'Welcome to Antares SQL Client!', @@ -333,7 +334,8 @@ export const enUS = { folderName: 'Folder name', deleteFolder: 'Delete folder', editConnectionAppearence: 'Edit connection appearence', - executeSelectedQuery: 'Execute selected query' + executeSelectedQuery: 'Execute selected query', + defaultCopyType: 'Default copy type' }, faker: { address: 'Address', diff --git a/src/renderer/i18n/id-ID.ts b/src/renderer/i18n/id-ID.ts index bf8aa1db..0982ed91 100644 --- a/src/renderer/i18n/id-ID.ts +++ b/src/renderer/i18n/id-ID.ts @@ -333,7 +333,8 @@ export const idID = { folderName: 'Nama folder', deleteFolder: 'Hapus folder', editConnectionAppearence: 'Ubah connection appearence', - executeSelectedQuery: 'Eksekusi query yang dipilih' + executeSelectedQuery: 'Eksekusi query yang dipilih', + defaultCopyType: 'Jenis salin default' }, faker: { address: 'Alamat', diff --git a/src/renderer/stores/settings.ts b/src/renderer/stores/settings.ts index cb1d551a..838d25df 100644 --- a/src/renderer/stores/settings.ts +++ b/src/renderer/stores/settings.ts @@ -29,7 +29,8 @@ export const useSettingsStore = defineStore('settings', { restoreTabs: settingsStore.get('restore_tabs', true) as boolean, disableBlur: settingsStore.get('disable_blur', false) as boolean, disableScratchpad: settingsStore.get('disable_scratchpad', false) as boolean, - shortcuts: shortcutsStore.get('shortcuts', []) as ShortcutRecord[] + shortcuts: shortcutsStore.get('shortcuts', []) as ShortcutRecord[], + defaultCopyType: settingsStore.get('default_copy_type', 'cell') as string }), actions: { changeLocale (locale: AvailableLocale) { @@ -92,6 +93,10 @@ export const useSettingsStore = defineStore('settings', { }, updateShortcuts (shortcuts: ShortcutRecord[]) { this.shortcuts = shortcuts; + }, + changeDefaultCopyType (type: string) { + this.defaultCopyType = type; + settingsStore.set('default_copy_type', this.defaultCopyType); } } });