Skip to content

Commit

Permalink
feat(keyboard-shortcuts): add modal showing keybindings
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulHax committed Oct 10, 2023
1 parent 2043d06 commit 9cdbcf9
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/components/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@
<closeable-dialog v-model="dataSecurityDialog">
<data-security-box />
</closeable-dialog>

<keyboard-shortcuts />
</v-app>
<persistent-overlay
:disabled="!dragHover"
Expand Down Expand Up @@ -254,6 +256,7 @@ import PersistentOverlay from './PersistentOverlay.vue';
import DataSecurityBox from './DataSecurityBox.vue';
import VolViewFullLogo from './icons/VolViewFullLogo.vue';
import VolViewLogo from './icons/VolViewLogo.vue';
import KeyboardShortcuts from './KeyboardShortcuts.vue';
import {
DataSource,
fileToDataSource,
Expand Down Expand Up @@ -349,6 +352,7 @@ export default defineComponent({
Settings,
SaveSession,
PersistentOverlay,
KeyboardShortcuts,
},
setup() {
Expand Down
32 changes: 32 additions & 0 deletions src/components/KeyboardShortcuts.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<template>
<closeable-dialog v-model="keyboardStore.settingsOpen">
<v-card>
<v-card-title class="d-flex flex-row align-center"
>Keyboard Shortcuts</v-card-title
>
<v-table class="pa-4">
<thead>
<th class="text-left">Command</th>
<th class="text-left">Keybinding</th>
</thead>
<tbody>
<tr v-for="[action, key] in bindings" :key="action">
<td>{{ action }}</td>
<td>{{ key }}</td>
</tr>
</tbody>
</v-table>
</v-card>
</closeable-dialog>
</template>

<script setup lang="ts">
import { computed } from 'vue';
import { actionToKey } from '@/src/composables/useKeyboardShortcuts';
import { useKeyboardShortcutsStore } from '@/src/store/keyboard-shortcuts';
import CloseableDialog from './CloseableDialog.vue';
const keyboardStore = useKeyboardShortcutsStore();
const bindings = computed(() => Object.entries(actionToKey.value));
</script>
16 changes: 16 additions & 0 deletions src/components/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
hide-details
></v-switch>

<v-btn
class="my-2"
@click="openKeyboardShortcuts"
prepend-icon="mdi-keyboard"
color="secondary"
>
Keyboard Shortcuts
</v-btn>

<v-divider class="mt-2 mb-6"></v-divider>
<dicom-web-settings />

Expand All @@ -33,6 +42,7 @@ import { defineComponent, ref, watch } from 'vue';
import { useTheme } from 'vuetify';
import { useLocalStorage } from '@vueuse/core';
import { useKeyboardShortcutsStore } from '@/src/store/keyboard-shortcuts';
import DicomWebSettings from './dicom-web/DicomWebSettings.vue';
import ServerSettings from './ServerSettings.vue';
import { DarkTheme, LightTheme, ThemeStorageKey } from '../constants';
Expand All @@ -58,10 +68,16 @@ export default defineComponent({
errorReportingStore.disableReporting = !enabled;
});
const keyboardStore = useKeyboardShortcutsStore();
const openKeyboardShortcuts = () => {
keyboardStore.settingsOpen = true;
};
return {
dark,
reportingEnabled,
errorReportingConfigured,
openKeyboardShortcuts,
};
},
components: {
Expand Down
13 changes: 13 additions & 0 deletions src/store/keyboard-shortcuts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ref } from 'vue';
import { defineStore } from 'pinia';

export const useKeyboardShortcutsStore = defineStore(
'keyboardShortcuts',
() => {
const settingsOpen = ref(false);

return {
settingsOpen,
};
}
);

0 comments on commit 9cdbcf9

Please sign in to comment.