Skip to content

Commit

Permalink
feat: 書き出し先を固定を有効にしたときに書き出し先が未選択の場合は自動的にダイアログを表示する (#1881)
Browse files Browse the repository at this point in the history
* feat: 書き出し先を固定を有効にしたときに書き出し先が未選択の場合は自動的にダイアログを表示する

* fix: ミス修正

* fix: FIXMEコメント追加

* FIX: コメント修正

Co-authored-by: Hiroshiba <[email protected]>

* FIX: 最新バージョンに追従

Co-authored-by: Hiroshiba <[email protected]>

---------

Co-authored-by: Hiroshiba <[email protected]>
  • Loading branch information
sabonerune and Hiroshiba authored Mar 20, 2024
1 parent 1790938 commit 05926fb
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
14 changes: 14 additions & 0 deletions src/backend/common/ConfigManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,20 @@ const migrations: [string, (store: Record<string, unknown>) => unknown][] = [
return config;
},
],
[
">=0.17",
(config) => {
// 書き出し先のディレクトリが空文字の場合書き出し先固定を無効化する
// FIXME: 勝手に書き換えるのは少し不親切なので、ダイアログで書き換えたことを案内する
const savingSetting = config.savingSetting as ConfigType["savingSetting"];
if (
savingSetting.fixedExportEnabled &&
savingSetting.fixedExportDir === ""
) {
savingSetting.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 05926fb

Please sign in to comment.