Skip to content

Commit

Permalink
feat: 書き出し先を固定を有効にしたときに書き出し先が未選択の場合は自動的にダイアログを表示する
Browse files Browse the repository at this point in the history
  • Loading branch information
sabonerune committed Feb 27, 2024
1 parent 8b959ab commit 6cbc2d6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
9 changes: 9 additions & 0 deletions src/backend/common/ConfigManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ const migrations: [string, (store: Record<string, unknown>) => unknown][] = [
return config;
},
],
[
">=0.16",
(config) => {
// 書き出し先のディレクトリが空文字の場合書き出し先固定を無効化する
if (config.fixedExportEnabled && config.fixedExportDir === "") {
config.fixedExportEnabled = false;
}
},
],
];

export type Metadata = {
Expand Down
34 changes: 26 additions & 8 deletions src/components/Dialog/SettingDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@
flat
color="primary"
icon="folder_open"
@click="openFileExplore"
@click="selectFixedExportDir()"
>
<QTooltip :delay="500" anchor="bottom left">
フォルダ選択
Expand Down Expand Up @@ -1011,7 +1011,7 @@
</template>

<script setup lang="ts">
import { computed, ref } from "vue";
import { computed, ref, watchEffect } from "vue";
import FileNamePatternDialog from "./FileNamePatternDialog.vue";
import { useStore } from "@/store";
import {
Expand Down Expand Up @@ -1289,17 +1289,35 @@ const outputSamplingRate = computed({
},
});
const openFileExplore = async () => {
const path = await window.backend.showSaveDirectoryDialog({
const openFileExplore = () => {
return window.backend.showSaveDirectoryDialog({
title: "書き出し先のフォルダを選択",
});
if (path) {
store.dispatch("SET_SAVING_SETTING", {
data: { ...savingSetting.value, fixedExportDir: path },
});
};
const selectFixedExportDir = async () => {
const path = await openFileExplore();
if (path != undefined) {
handleSavingSettingChange("fixedExportDir", path);
}
};
// 書き出し先を固定を有効にしたときに書き出し先が未選択の場合は自動的にダイアログを表示する
watchEffect(async () => {
if (
savingSetting.value.fixedExportEnabled &&
savingSetting.value.fixedExportDir === ""
) {
const path = await openFileExplore();
if (path != undefined) {
handleSavingSettingChange("fixedExportDir", path);
} else {
// キャンセルした場合書き出し先の固定を無効化する
handleSavingSettingChange("fixedExportEnabled", false);
}
}
});
const [splitTextWhenPaste, changeSplitTextWhenPaste] =
useRootMiscSetting("splitTextWhenPaste");
Expand Down

0 comments on commit 6cbc2d6

Please sign in to comment.