Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 書き出し先を固定を有効にしたときに書き出し先が未選択の場合は自動的にダイアログを表示する #1881

Merged
merged 5 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading