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

実験:ツールバーにアイコンを追加 #2374

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
20,749 changes: 11,757 additions & 8,992 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"license:generate": "node build/generateLicenses.js",
"license:merge": "node build/mergeLicenses.js",
"storybook": "storybook dev --port 6006",
"storybook:build": "storybook build"
"storybook:build": "storybook build",
"generate-icons": "matex -r ./public/matexRecipes.yml -o public"
},
"dependencies": {
"@gtm-support/vue-gtm": "1.2.3",
Expand Down Expand Up @@ -81,6 +82,7 @@
"@openapitools/openapi-generator-cli": "2.15.3",
"@playwright/test": "1.48.2",
"@quasar/vite-plugin": "1.8.1",
"@sevenc-nanashi/matex": "1.1.2",
"@storybook/addon-essentials": "8.4.4",
"@storybook/addon-links": "8.4.4",
"@storybook/addon-themes": "8.4.4",
Expand Down Expand Up @@ -135,6 +137,7 @@
"vite-plugin-electron": "0.29.0",
"vite-tsconfig-paths": "5.1.2",
"vitest": "2.1.2",
"vue-component-type-helpers": "2.1.6",
"vue-tsc": "2.1.10",
"yargs": "17.2.1"
}
Expand Down
6 changes: 6 additions & 0 deletions public/matexRecipes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
toolbarIcons.svg:
playAll: filled:play_arrow + notes
exportSelected: filled:save + volume_up
exportConnectAll: filled:save + link
exportAll: filled:save + notes
importText: filled:upload + outlined:import_contacts
4 changes: 4 additions & 0 deletions public/toolbarIcons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/components/Base/BaseToggleGroup.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import BaseToggleGroup from "./BaseToggleGroup.vue";
import BaseToggleGroupItem from "./BaseToggleGroupItem.vue";

const meta: Meta<typeof BaseToggleGroup> = {
// @ts-expect-error どうやらGenericsと相性が悪いらしい?
component: BaseToggleGroup,
};

Expand Down
6 changes: 3 additions & 3 deletions src/components/Base/BaseToggleGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
</ToggleGroupRoot>
</template>

<script setup lang="ts">
<script setup lang="ts" generic="T extends 'single' | 'multiple'">
import { ToggleGroupRoot } from "radix-vue";

defineProps<{
type: "single" | "multiple";
modelValue: string | string[];
type: T;
modelValue: T extends "single" ? string : string[];
disabled?: boolean;
}>();

Expand Down
2 changes: 1 addition & 1 deletion src/components/Dialog/SettingDialog/ButtonToggleCell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ defineProps<{
disable?: boolean;
}>();

const model = defineModel<string | string[]>({ required: true });
const model = defineModel<T>({ required: true });
</script>
16 changes: 16 additions & 0 deletions src/components/Dialog/SettingDialog/SettingDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,17 @@
:modelValue="showAddAudioItemButton"
@update:modelValue="changeShowAddAudioItemButton"
/>
<ButtonToggleCell
title="ツールバーの表示"
description="ツールバーの表示を選べます。"
:modelValue="toolbarButtonDisplay"
:options="[
{ label: 'アイコンのみ', value: 'ICON_ONLY' },
{ label: 'アイコンとテキスト', value: 'ICON_AND_TEXT' },
{ label: 'テキストのみ', value: 'TEXT_ONLY' },
]"
@update:modelValue="changeToolbarButtonDisplay"
/>
</div>

<!-- Advanced Card -->
Expand Down Expand Up @@ -603,6 +614,11 @@ const [enablePreset, _changeEnablePreset] = useRootMiscSetting(
"enablePreset",
);

const [toolbarButtonDisplay, changeToolbarButtonDisplay] = useRootMiscSetting(
store,
"toolbarButtonDisplay",
);

const [
shouldApplyDefaultPresetOnVoiceChanged,
changeShouldApplyDefaultPresetOnVoiceChanged,
Expand Down
59 changes: 49 additions & 10 deletions src/components/Talk/ToolBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,37 @@
<QToolbar>
<template v-for="button in buttons" :key="button.text">
<QSpace v-if="button.text === null" />
<QBtn
v-else
unelevated
color="toolbar-button"
textColor="toolbar-button-display"
class="text-no-wrap text-bold q-mr-sm"
:disable="button.disable.value"
@click="button.click"
>{{ button.text }}</QBtn
<template v-else>
<QBtn
v-if="toolbarButtonDisplay === 'ICON_ONLY'"
unelevated
:icon="buttonIcons[button.tag]"
color="toolbar-button"
textColor="toolbar-button-display"
class="text-no-wrap text-bold q-mr-sm"
padding="sm"
:disable="button.disable.value"
@click="button.click"
>
<QTooltip>
{{ button.text }}
</QTooltip>
</QBtn>
<QBtn
v-else
unelevated
:icon="
toolbarButtonDisplay === 'ICON_AND_TEXT'
? buttonIcons[button.tag]
: undefined
"
color="toolbar-button"
textColor="toolbar-button-display"
class="text-no-wrap text-bold q-mr-sm"
:disable="button.disable.value"
@click="button.click"
>{{ button.text }}</QBtn
></template
>
</template>
</QToolbar>
Expand All @@ -33,6 +55,7 @@ import { handlePossiblyNotMorphableError } from "@/store/audioGenerate";

type ButtonContent = {
text: string;
tag: ToolbarButtonTagType;
click(): void;
disable: ComputedRef<boolean>;
};
Expand All @@ -51,6 +74,7 @@ const activeAudioKey = computed(() => store.getters.ACTIVE_AUDIO_KEY);
const nowPlayingContinuously = computed(
() => store.state.nowPlayingContinuously,
);
const toolbarButtonDisplay = computed(() => store.state.toolbarButtonDisplay);

const { registerHotkeyWithCleanup } = useHotkeyManager();
registerHotkeyWithCleanup({
Expand Down Expand Up @@ -150,7 +174,7 @@ const importTextFile = () => {

const usableButtons: Record<
ToolbarButtonTagType,
Omit<ButtonContent, "text"> | null
Omit<ButtonContent, "text" | "tag"> | null
> = {
PLAY_CONTINUOUSLY: {
click: playContinuously,
Expand Down Expand Up @@ -197,13 +221,28 @@ const buttons = computed(() =>
if (buttonContent) {
return {
...buttonContent,
tag,
text: getToolbarButtonName(tag),
};
} else {
return {
tag,
text: null,
};
}
}),
);

const buttonIcons: Record<ToolbarButtonTagType, string> = {
PLAY_CONTINUOUSLY: "playlist_play",
STOP: "stop",
EXPORT_AUDIO_SELECTED: "svguse:toolbarIcons.svg#exportSelected",
EXPORT_AUDIO_ALL: "svguse:toolbarIcons.svg#exportAll",
EXPORT_AUDIO_CONNECT_ALL: "svguse:toolbarIcons.svg#exportConnectAll",
UNDO: "undo",
REDO: "redo",
IMPORT_TEXT: "svguse:toolbarIcons.svg#importText",
SAVE_PROJECT: "save",
EMPTY: "",
};
</script>
2 changes: 2 additions & 0 deletions src/store/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const settingStoreState: SettingStoreState = {
},
showSingCharacterPortrait: true,
playheadPositionDisplayFormat: "MINUTES_SECONDS",
toolbarButtonDisplay: "TEXT_ONLY",
};

export const settingStore = createPartialStore<SettingStoreTypes>({
Expand Down Expand Up @@ -150,6 +151,7 @@ export const settingStore = createPartialStore<SettingStoreTypes>({
"showSingCharacterPortrait",
"playheadPositionDisplayFormat",
"openedEditor",
"toolbarButtonDisplay",
] as const;

// rootMiscSettingKeysに値を足し忘れていたときに型エラーを出す検出用コード
Expand Down
3 changes: 3 additions & 0 deletions src/type/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,9 @@ export const rootMiscSettingSchema = z.object({
playheadPositionDisplayFormat: z
.enum(["MINUTES_SECONDS", "MEASURES_BEATS"])
.default("MINUTES_SECONDS"), // 再生ヘッド位置の表示モード
toolbarButtonDisplay: z
.enum(["ICON_ONLY", "ICON_AND_TEXT", "TEXT_ONLY"])
.default("TEXT_ONLY"), // ツールバーボタンの表示モード
});
export type RootMiscSettingType = z.infer<typeof rootMiscSettingSchema>;

Expand Down
Loading