Skip to content

Commit

Permalink
fix: preset周りのコードを実験的機能から通常機能に変更する (#2269)
Browse files Browse the repository at this point in the history
* preset周りのコードを実験的機能から通常機能に変更する

* メモ:useRootMiscSettingを使ってpreset周りの設定を変える;

* 多分大丈夫

* 初期値ミス
  • Loading branch information
Hiroshiba authored Sep 28, 2024
1 parent 1ac88a7 commit 90c6023
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 30 deletions.
19 changes: 19 additions & 0 deletions src/backend/common/ConfigManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,25 @@ const migrations: [string, (store: Record<string, unknown>) => unknown][] = [
delete experimentalSetting.enablePitchEditInSongEditor;
}

return config;
},
],
[
">=0.21",
(config) => {
// プリセット機能を実験的機能から通常機能に
const experimentalSetting =
config.experimentalSetting as ExperimentalSettingType;
if ("enablePreset" in experimentalSetting) {
config.enablePreset = experimentalSetting.enablePreset;
delete experimentalSetting.enablePreset;
}
if ("shouldApplyDefaultPresetOnVoiceChanged" in experimentalSetting) {
config.shouldApplyDefaultPresetOnVoiceChanged =
experimentalSetting.shouldApplyDefaultPresetOnVoiceChanged;
delete experimentalSetting.shouldApplyDefaultPresetOnVoiceChanged;
}

return config;
},
],
Expand Down
34 changes: 15 additions & 19 deletions src/components/Dialog/SettingDialog/SettingDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,24 +96,19 @@
<ToggleCell
title="プリセット機能"
description="ONの場合、プリセット機能を有効にします。パラメータを登録したり適用したりできます。"
:modelValue="experimentalSetting.enablePreset"
:modelValue="enablePreset"
@update:modelValue="changeEnablePreset"
/>
<QSlideTransition>
<!-- q-slide-transitionはheightだけをアニメーションするのでdivで囲う -->
<div v-show="experimentalSetting.enablePreset">
<div v-show="enablePreset">
<ToggleCell
title="スタイル変更時にデフォルトプリセットを適用"
description="ONの場合、キャラやスタイルの変更時にデフォルトプリセットが自動的に適用されます。"
class="in-slide-transition-workaround"
:modelValue="
experimentalSetting.shouldApplyDefaultPresetOnVoiceChanged
"
:modelValue="shouldApplyDefaultPresetOnVoiceChanged"
@update:modelValue="
changeExperimentalSetting(
'shouldApplyDefaultPresetOnVoiceChanged',
$event,
)
changeShouldApplyDefaultPresetOnVoiceChanged($event)
"
/>
</div>
Expand Down Expand Up @@ -709,6 +704,13 @@ const [enableMemoNotation, changeEnableMemoNotation] =
const [enableRubyNotation, changeEnableRubyNotation] =
useRootMiscSetting("enableRubyNotation");
const [enablePreset, _changeEnablePreset] = useRootMiscSetting("enablePreset");
const [
shouldApplyDefaultPresetOnVoiceChanged,
changeShouldApplyDefaultPresetOnVoiceChanged,
] = useRootMiscSetting("shouldApplyDefaultPresetOnVoiceChanged");
const canSetAudioOutputDevice = computed(() => {
return !!HTMLAudioElement.prototype.setSinkId;
});
Expand Down Expand Up @@ -799,17 +801,11 @@ const changeinheritAudioInfo = async (inheritAudioInfo: boolean) => {
const changeEnablePreset = (value: boolean) => {
if (value) {
// プリセット機能をONにしたときは「デフォルトプリセットを自動で適用」もONにする
void changeExperimentalSetting("enablePreset", true);
void changeExperimentalSetting(
"shouldApplyDefaultPresetOnVoiceChanged",
true,
);
_changeEnablePreset(true);
changeShouldApplyDefaultPresetOnVoiceChanged(true);
} else {
void changeExperimentalSetting("enablePreset", false);
void changeExperimentalSetting(
"shouldApplyDefaultPresetOnVoiceChanged",
false,
);
_changeEnablePreset(false);
changeShouldApplyDefaultPresetOnVoiceChanged(false);
}
};
Expand Down
4 changes: 1 addition & 3 deletions src/components/Talk/AudioInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -640,9 +640,7 @@ const morphingRateSlider = previewSliderHelper({
});
// プリセット
const enablePreset = computed(
() => store.state.experimentalSetting.enablePreset,
);
const enablePreset = computed(() => store.state.enablePreset);
const presetItems = computed(() => store.state.presetItems);
const presetKeys = computed(() => store.state.presetKeys);
Expand Down
11 changes: 7 additions & 4 deletions src/store/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import { Preset, PresetKey, Voice, VoiceId } from "@/type/preload";
export function determineNextPresetKey(
state: Pick<
State,
"defaultPresetKeys" | "experimentalSetting" | "inheritAudioInfo"
| "defaultPresetKeys"
| "enablePreset"
| "shouldApplyDefaultPresetOnVoiceChanged"
| "inheritAudioInfo"
>,
voice: Voice,
presetKeyCandidate: PresetKey | undefined,
Expand All @@ -31,7 +34,7 @@ export function determineNextPresetKey(
// 初回作成時
return {
nextPresetKey: defaultPresetKeyForCurrentVoice,
shouldApplyPreset: state.experimentalSetting.enablePreset,
shouldApplyPreset: state.enablePreset,
};
}
case "copy": {
Expand All @@ -47,12 +50,12 @@ export function determineNextPresetKey(
// それ以外はデフォルトプリセットを割り当て、適用するかはプリセットのON/OFFに依存
return {
nextPresetKey: defaultPresetKeyForCurrentVoice,
shouldApplyPreset: state.experimentalSetting.enablePreset,
shouldApplyPreset: state.enablePreset,
};
}
case "changeVoice": {
// ボイス切り替え時
if (state.experimentalSetting.shouldApplyDefaultPresetOnVoiceChanged) {
if (state.shouldApplyDefaultPresetOnVoiceChanged) {
// デフォルトプリセットを適用する
return {
nextPresetKey: defaultPresetKeyForCurrentVoice,
Expand Down
6 changes: 4 additions & 2 deletions src/store/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ export const settingStoreState: SettingStoreState = {
acceptTerms: "Unconfirmed",
acceptRetrieveTelemetry: "Unconfirmed",
experimentalSetting: {
enablePreset: false,
shouldApplyDefaultPresetOnVoiceChanged: false,
enableInterrogativeUpspeak: false,
enableMorphing: false,
enableMultiSelect: false,
Expand All @@ -63,6 +61,8 @@ export const settingStoreState: SettingStoreState = {
notifyOnGenerate: false,
},
engineSettings: {},
enablePreset: false,
shouldApplyDefaultPresetOnVoiceChanged: false,
enableMultiEngine: false,
enableMemoNotation: false,
enableRubyNotation: false,
Expand Down Expand Up @@ -143,6 +143,8 @@ export const settingStore = createPartialStore<SettingStoreTypes>({
"showAddAudioItemButton",
"splitTextWhenPaste",
"splitterPosition",
"enablePreset",
"shouldApplyDefaultPresetOnVoiceChanged",
"enableMultiEngine",
"enableRubyNotation",
"enableMemoNotation",
Expand Down
4 changes: 2 additions & 2 deletions src/type/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,6 @@ export type ThemeSetting = {
};

export const experimentalSettingSchema = z.object({
enablePreset: z.boolean().default(false),
shouldApplyDefaultPresetOnVoiceChanged: z.boolean().default(false),
enableInterrogativeUpspeak: z.boolean().default(false),
enableMorphing: z.boolean().default(false),
enableMultiSelect: z.boolean().default(false),
Expand Down Expand Up @@ -592,6 +590,8 @@ export const rootMiscSettingSchema = z.object({
.enum(["PERIOD_AND_NEW_LINE", "NEW_LINE", "OFF"])
.default("PERIOD_AND_NEW_LINE"),
splitterPosition: splitterPositionSchema.default({}),
enablePreset: z.boolean().default(false), // プリセット機能
shouldApplyDefaultPresetOnVoiceChanged: z.boolean().default(false), // スタイル変更時にデフォルトプリセットを適用するか
enableMultiEngine: z.boolean().default(false),
enableMemoNotation: z.boolean().default(false), // メモ記法を有効にするか
enableRubyNotation: z.boolean().default(false), // ルビ記法を有効にするか
Expand Down

0 comments on commit 90c6023

Please sign in to comment.