feat: global shortcut for quick entry dialog
This commit is contained in:
20
src/App.vue
20
src/App.vue
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, watch } from 'vue'
|
||||
import { onMounted, ref, watch } from 'vue'
|
||||
import { invoke } from '@tauri-apps/api/core'
|
||||
import TitleBar from './components/TitleBar.vue'
|
||||
import NavRail from './components/NavRail.vue'
|
||||
@@ -16,6 +16,7 @@ import type { SoundEvent } from './utils/audio'
|
||||
import TourOverlay from './components/TourOverlay.vue'
|
||||
import RecurringPromptDialog from './components/RecurringPromptDialog.vue'
|
||||
import TimerSaveDialog from './components/TimerSaveDialog.vue'
|
||||
import QuickEntryDialog from './components/QuickEntryDialog.vue'
|
||||
import { useOnboardingStore } from './stores/onboarding'
|
||||
import { useProjectsStore } from './stores/projects'
|
||||
import { useInvoicesStore } from './stores/invoices'
|
||||
@@ -24,6 +25,7 @@ const settingsStore = useSettingsStore()
|
||||
const recurringStore = useRecurringStore()
|
||||
const timerStore = useTimerStore()
|
||||
const { announcement } = useAnnouncer()
|
||||
const showQuickEntry = ref(false)
|
||||
|
||||
function getProjectName(projectId?: number): string {
|
||||
if (!projectId) return ''
|
||||
@@ -59,6 +61,15 @@ async function registerShortcuts() {
|
||||
await win.show()
|
||||
await win.setFocus()
|
||||
})
|
||||
|
||||
const quickEntryKey = settingsStore.settings.shortcut_quick_entry || 'CmdOrCtrl+Shift+N'
|
||||
await register(quickEntryKey, async () => {
|
||||
const { getCurrentWindow } = await import('@tauri-apps/api/window')
|
||||
const win = getCurrentWindow()
|
||||
await win.show()
|
||||
await win.setFocus()
|
||||
showQuickEntry.value = true
|
||||
})
|
||||
} catch (e) {
|
||||
console.error('Failed to register shortcuts:', e)
|
||||
}
|
||||
@@ -215,7 +226,7 @@ watch(() => settingsStore.settings.ui_font, (newFont) => {
|
||||
}
|
||||
})
|
||||
|
||||
watch(() => [settingsStore.settings.shortcut_toggle_timer, settingsStore.settings.shortcut_show_app], () => {
|
||||
watch(() => [settingsStore.settings.shortcut_toggle_timer, settingsStore.settings.shortcut_show_app, settingsStore.settings.shortcut_quick_entry], () => {
|
||||
registerShortcuts()
|
||||
})
|
||||
|
||||
@@ -284,6 +295,11 @@ watch(() => settingsStore.settings.persistent_notifications, (val) => {
|
||||
@discard="timerStore.handleSaveDialogDiscard"
|
||||
@cancel="timerStore.handleSaveDialogCancel"
|
||||
/>
|
||||
<QuickEntryDialog
|
||||
:show="showQuickEntry"
|
||||
@close="showQuickEntry = false"
|
||||
@saved="showQuickEntry = false"
|
||||
/>
|
||||
<div id="route-announcer" class="sr-only" aria-live="polite" aria-atomic="true"></div>
|
||||
<div id="announcer" class="sr-only" aria-live="assertive" aria-atomic="true">{{ announcement }}</div>
|
||||
<TourOverlay />
|
||||
|
||||
Reference in New Issue
Block a user