feat: option to disable scratchpad

This commit is contained in:
Fabio Di Stasio 2022-07-04 15:10:40 +02:00
parent a9a4344a71
commit 56b0a4815c
7 changed files with 53 additions and 12 deletions

View File

@ -67,21 +67,23 @@ const { changeApplicationTheme } = settingsStore;
const isAllConnectionsModal: Ref<boolean> = ref(false); const isAllConnectionsModal: Ref<boolean> = ref(false);
document.addEventListener('DOMContentLoaded', () => { const onKey = (e: KeyboardEvent) => {
setTimeout(() => {
changeApplicationTheme(applicationTheme.value);// Forces persistentStore to save on file and mail process
}, 1000);
});
window.addEventListener('keypress', (e: KeyboardEvent) => {
if (e.ctrlKey || e.metaKey) { if (e.ctrlKey || e.metaKey) {
if (e.code === 'Space') { if (e.code === 'Space') {
isAllConnectionsModal.value = true; isAllConnectionsModal.value = true;
e.stopPropagation(); e.stopPropagation();
} }
} }
};
document.addEventListener('DOMContentLoaded', () => {
setTimeout(() => {
changeApplicationTheme(applicationTheme.value);// Forces persistentStore to save on file and mail process
}, 1000);
}); });
window.addEventListener('keypress', onKey);
onMounted(() => { onMounted(() => {
ipcRenderer.send('check-for-updates'); ipcRenderer.send('check-for-updates');
checkVersionUpdate(); checkVersionUpdate();
@ -126,7 +128,7 @@ onMounted(() => {
}); });
onBeforeUnmount(() => { onBeforeUnmount(() => {
window.removeEventListener('keydown', console.log); window.removeEventListener('keydown', onKey);
}); });
</script> </script>

View File

@ -96,6 +96,12 @@
</div> </div>
</div> </div>
</div> </div>
<input
readonly
class="p-absolute"
style="width: 1px; height: 1px; opacity: 0"
type="text"
><!-- workaround for useFocusTrap $lastFocusable -->
</TransitionGroup> </TransitionGroup>
</div> </div>
</div> </div>

View File

@ -126,6 +126,19 @@
</label> </label>
</div> </div>
</div> </div>
<div class="form-group column col-12 mb-0">
<div class="col-5 col-sm-12">
<label class="form-label">
{{ t('message.disableScratchpad') }}
</label>
</div>
<div class="col-3 col-sm-12">
<label class="form-switch d-inline-block" @click.prevent="toggleDisableScratchpad">
<input type="checkbox" :checked="disableScratchpad">
<i class="form-icon" />
</label>
</div>
</div>
<div class="form-group column col-12"> <div class="form-group column col-12">
<div class="col-5 col-sm-12"> <div class="col-5 col-sm-12">
<label class="form-label"> <label class="form-label">
@ -337,6 +350,7 @@ const {
notificationsTimeout, notificationsTimeout,
restoreTabs, restoreTabs,
disableBlur, disableBlur,
disableScratchpad,
applicationTheme, applicationTheme,
editorTheme, editorTheme,
editorFontSize editorFontSize
@ -349,6 +363,7 @@ const {
changePageSize, changePageSize,
changeRestoreTabs, changeRestoreTabs,
changeDisableBlur, changeDisableBlur,
changeDisableScratchpad,
changeAutoComplete, changeAutoComplete,
changeLineWrap, changeLineWrap,
changeApplicationTheme, changeApplicationTheme,
@ -490,6 +505,10 @@ const toggleDisableBlur = () => {
changeDisableBlur(!disableBlur.value); changeDisableBlur(!disableBlur.value);
}; };
const toggleDisableScratchpad = () => {
changeDisableScratchpad(!disableScratchpad.value);
};
const toggleAutoComplete = () => { const toggleAutoComplete = () => {
changeAutoComplete(!selectedAutoComplete.value); changeAutoComplete(!selectedAutoComplete.value);
}; };

View File

@ -71,7 +71,11 @@
<div class="settingbar-bottom-elements"> <div class="settingbar-bottom-elements">
<ul class="settingbar-elements"> <ul class="settingbar-elements">
<li class="settingbar-element btn btn-link ex-tooltip" @click="showScratchpad"> <li
v-if="!disableScratchpad"
class="settingbar-element btn btn-link ex-tooltip"
@click="showScratchpad"
>
<i class="settingbar-element-icon mdi mdi-24px mdi-notebook-edit-outline text-light" /> <i class="settingbar-element-icon mdi mdi-24px mdi-notebook-edit-outline text-light" />
<span class="ex-tooltip-content">{{ $t('word.scratchpad') }}</span> <span class="ex-tooltip-content">{{ $t('word.scratchpad') }}</span>
</li> </li>
@ -90,6 +94,7 @@ import { storeToRefs } from 'pinia';
import { useApplicationStore } from '@/stores/application'; import { useApplicationStore } from '@/stores/application';
import { useConnectionsStore } from '@/stores/connections'; import { useConnectionsStore } from '@/stores/connections';
import { useWorkspacesStore } from '@/stores/workspaces'; import { useWorkspacesStore } from '@/stores/workspaces';
import { useSettingsStore } from '@/stores/settings';
import * as Draggable from 'vuedraggable'; import * as Draggable from 'vuedraggable';
import SettingBarContext from '@/components/SettingBarContext.vue'; import SettingBarContext from '@/components/SettingBarContext.vue';
import { ConnectionParams } from 'common/interfaces/antares'; import { ConnectionParams } from 'common/interfaces/antares';
@ -98,10 +103,12 @@ import { useElementBounding, useScroll } from '@vueuse/core';
const applicationStore = useApplicationStore(); const applicationStore = useApplicationStore();
const connectionsStore = useConnectionsStore(); const connectionsStore = useConnectionsStore();
const workspacesStore = useWorkspacesStore(); const workspacesStore = useWorkspacesStore();
const settingsStore = useSettingsStore();
const { updateStatus } = storeToRefs(applicationStore); const { updateStatus } = storeToRefs(applicationStore);
const { connections: storedConnections, pinnedConnections, lastConnections } = storeToRefs(connectionsStore); const { connections: storedConnections, pinnedConnections, lastConnections } = storeToRefs(connectionsStore);
const { getSelected: selectedWorkspace } = storeToRefs(workspacesStore); const { getSelected: selectedWorkspace } = storeToRefs(workspacesStore);
const { disableScratchpad } = storeToRefs(settingsStore);
const { showSettingModal, showScratchpad } = applicationStore; const { showSettingModal, showScratchpad } = applicationStore;
const { getConnectionName, updatePinnedConnections } = connectionsStore; const { getConnectionName, updatePinnedConnections } = connectionsStore;

View File

@ -56,7 +56,8 @@ const useFocusTrap = (args?: {disableAutofocus?: boolean}) => {
} }
function initFocusTrap () { function initFocusTrap () {
if (!trapRef.value || isInitiated.value) return; if (!trapRef.value || (isInitiated.value)) return;
focusableElements = (trapRef.value as HTMLElement).querySelectorAll( focusableElements = (trapRef.value as HTMLElement).querySelectorAll(
focusableElementsSelector focusableElementsSelector
); );

View File

@ -295,7 +295,8 @@ module.exports = {
findOutHowToContribute: 'Find out how to contribute', findOutHowToContribute: 'Find out how to contribute',
disableFKChecks: 'Disable foreigh key checks', disableFKChecks: 'Disable foreigh key checks',
allConnections: 'All connections', allConnections: 'All connections',
searchForConnections: 'Search for connections' searchForConnections: 'Search for connections',
disableScratchpad: 'Disable scratchpad'
}, },
faker: { faker: {
address: 'Address', address: 'Address',

View File

@ -23,7 +23,8 @@ export const useSettingsStore = defineStore('settings', {
editorTheme: persistentStore.get('editor_theme', defaultEditorTheme) as string, editorTheme: persistentStore.get('editor_theme', defaultEditorTheme) as string,
editorFontSize: persistentStore.get('editor_font_size', 'medium') as EditorFontSize, editorFontSize: persistentStore.get('editor_font_size', 'medium') as EditorFontSize,
restoreTabs: persistentStore.get('restore_tabs', true) as boolean, restoreTabs: persistentStore.get('restore_tabs', true) as boolean,
disableBlur: persistentStore.get('disable_blur', false) as boolean disableBlur: persistentStore.get('disable_blur', false) as boolean,
disableScratchpad: persistentStore.get('disable_scratchpad', false) as boolean
}), }),
actions: { actions: {
changeLocale (locale: string) { changeLocale (locale: string) {
@ -75,6 +76,10 @@ export const useSettingsStore = defineStore('settings', {
changeDisableBlur (val: boolean) { changeDisableBlur (val: boolean) {
this.disableBlur = val; this.disableBlur = val;
persistentStore.set('disable_blur', this.disableBlur); persistentStore.set('disable_blur', this.disableBlur);
},
changeDisableScratchpad (val: boolean) {
this.disableScratchpad = val;
persistentStore.set('disable_scratchpad', this.disableScratchpad);
} }
} }
}); });