diff --git a/src/background.ts b/src/background.ts index d475a48f7a..27350306c8 100644 --- a/src/background.ts +++ b/src/background.ts @@ -60,6 +60,77 @@ protocol.registerSchemesAsPrivileged([ { scheme: "app", privileges: { secure: true, standard: true, stream: true } }, ]); +const defaultHotkeySettings: HotkeySetting[] = [ + { + action: "音声書き出し", + combination: "Ctrl E", + }, + { + action: "一つだけ書き出し", + combination: "E", + }, + { + action: "再生/停止", + combination: "Space", + }, + { + action: "連続再生/停止", + combination: "Shift Space", + }, + { + action: "アクセント欄を表示", + combination: "1", + }, + { + action: "イントネーション欄を表示", + combination: "2", + }, + { + action: "テキスト欄を追加", + combination: "Shift Enter", + }, + { + action: "テキスト欄を削除", + combination: "Shift Delete", + }, + { + action: "テキスト欄からフォーカスを外す", + combination: "Escape", + }, + { + action: "テキスト欄にフォーカスを戻す", + combination: "Enter", + }, + { + action: "元に戻す", + combination: "Ctrl Z", + }, + { + action: "やり直す", + combination: "Ctrl Y", + }, + { + action: "新規プロジェクト", + combination: "Ctrl N", + }, + { + action: "プロジェクトを名前を付けて保存", + combination: "Ctrl Shift S", + }, + { + action: "プロジェクトを上書き保存", + combination: "Ctrl S", + }, + { + action: "プロジェクト読み込み", + combination: "Ctrl O", + }, + { + action: "テキスト読み込む", + combination: "", + }, +]; + // 設定ファイル const store = new Store<{ useGpu: boolean; @@ -118,76 +189,7 @@ const store = new Store<{ combination: { type: "string" }, }, }, - default: [ - { - action: "音声書き出し", - combination: "Ctrl E", - }, - { - action: "一つだけ書き出し", - combination: "E", - }, - { - action: "再生/停止", - combination: "Space", - }, - { - action: "連続再生/停止", - combination: "Shift Space", - }, - { - action: "アクセント欄を表示", - combination: "1", - }, - { - action: "イントネーション欄を表示", - combination: "2", - }, - { - action: "テキスト欄を追加", - combination: "Shift Enter", - }, - { - action: "テキスト欄を削除", - combination: "Shift Delete", - }, - { - action: "テキスト欄からフォーカスを外す", - combination: "Escape", - }, - { - action: "テキスト欄にフォーカスを戻す", - combination: "Enter", - }, - { - action: "元に戻す", - combination: "Ctrl Z", - }, - { - action: "やり直す", - combination: "Ctrl Y", - }, - { - action: "新規プロジェクト", - combination: "Ctrl N", - }, - { - action: "プロジェクトを名前を付けて保存", - combination: "Ctrl Shift S", - }, - { - action: "プロジェクトを上書き保存", - combination: "Ctrl S", - }, - { - action: "プロジェクト読み込み", - combination: "Ctrl O", - }, - { - action: "テキスト読み込む", - combination: "", - }, - ], + default: defaultHotkeySettings, }, defaultStyleIds: { type: "array", @@ -697,6 +699,10 @@ ipcMainHandle("SET_DEFAULT_STYLE_IDS", (_, defaultStyleIds) => { store.set("defaultStyleIds", defaultStyleIds); }); +ipcMainHandle("GET_DEFAULT_HOTKEY_SETTINGS", () => { + return defaultHotkeySettings; +}); + // app callback app.on("web-contents-created", (e, contents) => { // リンククリック時はブラウザを開く diff --git a/src/components/HotkeySettingDialog.vue b/src/components/HotkeySettingDialog.vue index b94532cd76..0bac4695fc 100644 --- a/src/components/HotkeySettingDialog.vue +++ b/src/components/HotkeySettingDialog.vue @@ -87,6 +87,17 @@ " @click="openHotkeyDialog(props.row.action)" /> + + デフォルトに戻す + @@ -182,7 +193,8 @@ import { defineComponent, computed, ref } from "vue"; import { useStore } from "@/store"; import { parseCombo } from "@/store/setting"; -import { HotkeyAction } from "@/type/preload"; +import { HotkeyAction, HotkeySetting } from "@/type/preload"; +import { useQuasar } from "quasar"; export default defineComponent({ name: "HotkeySettingDialog", @@ -196,6 +208,7 @@ export default defineComponent({ setup(props, { emit }) { const store = useStore(); + const $q = useQuasar(); const hotkeySettingDialogOpenComputed = computed({ get: () => props.modelValue, @@ -308,6 +321,35 @@ export default defineComponent({ ); }); + const resetHotkey = (action: string) => { + $q.dialog({ + title: "ショートカットキーを初期値に戻します", + message: `${action}のショートカットキーを初期値に戻します。
本当に戻しますか?`, + html: true, + ok: { + label: "初期値に戻す", + flat: true, + textColor: "secondary", + }, + cancel: { + label: "初期値に戻さない", + flat: true, + textColor: "secondary", + }, + }).onOk(() => { + window.electron + .getDefaultHotkeySettings() + .then((defaultSettings: HotkeySetting[]) => { + const setting = defaultSettings.find( + (value) => value.action == action + ); + if (setting) { + changeHotkeySettings(action, setting.combination); + } + }); + }); + }; + return { hotkeySettingDialogOpenComputed, isHotkeyDialogOpened, @@ -326,6 +368,7 @@ export default defineComponent({ changeHotkeySettings, confirmBtnEnabled, checkHotkeyReadonly, + resetHotkey, }; }, }); @@ -351,6 +394,21 @@ export default defineComponent({ overflow-x: hidden; } + tbody tr { + td button:last-child { + float: right; + display: none; + } + &:hover td button:last-child { + display: inline-flex; + color: var(--color-display); + opacity: 0.5; + &:hover { + opacity: 1; + } + } + } + thead tr th { position: sticky; top: 0; diff --git a/src/electron/preload.ts b/src/electron/preload.ts index 0a3735ddee..9f1b99b26d 100644 --- a/src/electron/preload.ts +++ b/src/electron/preload.ts @@ -196,6 +196,10 @@ const api: Sandbox = { await ipcRendererInvoke("SET_DEFAULT_STYLE_IDS", defaultStyleIds); }, + getDefaultHotkeySettings: async () => { + return await ipcRendererInvoke("GET_DEFAULT_HOTKEY_SETTINGS"); + }, + theme: (newData) => { return ipcRenderer.invoke("THEME", { newData }); }, diff --git a/src/type/ipc.d.ts b/src/type/ipc.d.ts index c763a67054..0777220c6e 100644 --- a/src/type/ipc.d.ts +++ b/src/type/ipc.d.ts @@ -167,6 +167,11 @@ type IpcIHData = { return: void; }; + GET_DEFAULT_HOTKEY_SETTINGS: { + args: []; + return: import("@/type/preload").HotkeySetting[]; + }; + THEME: { args: [obj: { newData?: string }]; return: import("@/type/preload").ThemeSetting | void; diff --git a/src/type/preload.d.ts b/src/type/preload.d.ts index 8b609f63cf..851c4584f9 100644 --- a/src/type/preload.d.ts +++ b/src/type/preload.d.ts @@ -53,6 +53,7 @@ export interface Sandbox { setDefaultStyleIds( defaultStyleIds: { speakerUuid: string; defaultStyleId: number }[] ): Promise; + getDefaultHotkeySettings(): Promise; theme(newData?: string): Promise; vuexReady(): void; }