Skip to content

Commit

Permalink
Merge branch 'main' into いらないHotkeyデフォルト設定取得関数を失くす
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiroshiba authored Dec 5, 2024
2 parents e57dc90 + 8990841 commit 6bce5ba
Show file tree
Hide file tree
Showing 26 changed files with 898 additions and 256 deletions.
17 changes: 1 addition & 16 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ module.exports = {
plugins: ["import"],
parser: vueEslintParser,
parserOptions: vueEslintParserOptions,
ignorePatterns: [
"dist/**/*",
"dist_*/**/*",
"node_modules/**/*",
],
ignorePatterns: ["dist/**/*", "dist_*/**/*", "node_modules/**/*"],
rules: {
"linebreak-style":
process.env.NODE_ENV === "production" && process.platform !== "win32"
Expand All @@ -63,17 +59,6 @@ module.exports = {
endOfLine: "auto",
},
],
"vue/no-restricted-syntax": [
"error",
{
selector: "LogicalExpression[operator=??]",
message: `template内で"??"を使うとgithubのsyntax highlightが崩れるので\n三項演算子等を使って書き換えてください`,
},
{
selector: "MemberExpression[optional=true]",
message: `template内で"?."を使うとgithubのsyntax highlightが崩れるので\n三項演算子等を使って書き換えてください`,
},
],
"@typescript-eslint/no-unused-vars": [
process.env.NODE_ENV === "development" ? "warn" : "error", // 開発時のみwarn
{
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ jobs:
app_asar_dir: prepackage/VOICEVOX.app/Contents/Resources
installer_artifact_name: macos-x64-cpu-dmg
macos_artifact_name: "VOICEVOX.${version}-x64.${ext}"
os: macos-12
os: macos-13
# macOS CPU (arm64)
- artifact_name: macos-arm64-cpu-prepackage
artifact_path: dist_electron/mac-arm64
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,14 @@ jobs:
uses: actions/download-artifact@v4
with:
pattern: updated-snapshots-*
path: ${{ env.RUNNER_TEMP }}/patches
path: ${{ runner.temp }}/patches
merge-multiple: true

- name: Commit updated snapshots
id: commit-updated-snapshots
run: |
# パッチを適用
for patch in ${{ env.RUNNER_TEMP }}/patches/*.diff; do
for patch in ${{ runner.temp }}/patches/*.diff; do
git apply --allow-empty $patch
rm $patch
done
Expand Down
4 changes: 4 additions & 0 deletions public/howtouse.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ GPU をお持ちの方は、音声の生成がずっと速い GPU モードを
- 元に戻す
- `Ctrl` + `Y`
- やり直す
- `Ctrl` + `+`
- 拡大
- `Ctrl` + `-`
- 縮小
- `Esc`
- テキスト欄からカーソルを外す
- 1
Expand Down
17 changes: 15 additions & 2 deletions src/backend/browser/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,22 @@ export const api: Sandbox = {
minimizeWindow() {
throw new Error(`Not supported on Browser version: minimizeWindow`);
},
maximizeWindow() {
throw new Error(`Not supported on Browser version: maximizeWindow`);
toggleMaximizeWindow() {
throw new Error(`Not supported on Browser version: toggleMaximizeWindow`);
},
toggleFullScreen() {
throw new Error(`Not supported on Browser version: toggleFullScreen`);
},
zoomIn() {
throw new Error(`Not supported on Browser version: zoomIn`);
},
zoomOut() {
throw new Error(`Not supported on Browser version: zoomOut`);
},
zoomReset() {
throw new Error(`Not supported on Browser version: zoomReset`);
},

/* eslint-disable no-console */ // ログの吐き出し先は console ぐらいしかないので、ここでは特例で許可している
logError(...params: unknown[]) {
console.error(...params);
Expand Down
31 changes: 28 additions & 3 deletions src/backend/electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,14 +615,39 @@ registerIpcMainHandle<IpcMainHandle>({
MINIMIZE_WINDOW: () => {
win.minimize();
},
MAXIMIZE_WINDOW: () => {
if (win.isMaximized()) {
TOGGLE_MAXIMIZE_WINDOW: () => {
// 全画面表示中は、全画面表示解除のみを行い、最大化解除処理は実施しない
if (win.isFullScreen()) {
win.setFullScreen(false);
} else if (win.isMaximized()) {
win.unmaximize();
} else {
win.maximize();
}
},

TOGGLE_FULLSCREEN: () => {
if (win.isFullScreen()) {
win.setFullScreen(false);
} else {
win.setFullScreen(true);
}
},
/** UIの拡大 */
ZOOM_IN: () => {
win.webContents.setZoomFactor(
Math.min(Math.max(win.webContents.getZoomFactor() + 0.1, 0.5), 3),
);
},
/** UIの縮小 */
ZOOM_OUT: () => {
win.webContents.setZoomFactor(
Math.min(Math.max(win.webContents.getZoomFactor() - 0.1, 0.5), 3),
);
},
/** UIの拡大率リセット */
ZOOM_RESET: () => {
win.webContents.setZoomFactor(1);
},
OPEN_LOG_DIRECTORY: () => {
void shell.openPath(app.getPath("logs"));
},
Expand Down
18 changes: 16 additions & 2 deletions src/backend/electron/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,22 @@ const api: Sandbox = {
void ipcRendererInvokeProxy.MINIMIZE_WINDOW();
},

maximizeWindow: () => {
void ipcRendererInvokeProxy.MAXIMIZE_WINDOW();
toggleMaximizeWindow: () => {
void ipcRendererInvokeProxy.TOGGLE_MAXIMIZE_WINDOW();
},

toggleFullScreen: () => {
void ipcRendererInvokeProxy.TOGGLE_FULLSCREEN();
},

zoomIn: () => {
void ipcRendererInvokeProxy.ZOOM_IN();
},
zoomOut: () => {
void ipcRendererInvokeProxy.ZOOM_OUT();
},
zoomReset: () => {
void ipcRendererInvokeProxy.ZOOM_RESET();
},

logError: (...params) => {
Expand Down
22 changes: 10 additions & 12 deletions src/components/Dialog/HelpDialog/HelpLibraryPolicySection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
>
<!-- エンジンが一つだけの場合は名前を表示しない -->
<h2 v-if="engineInfos.size > 1" class="subtitle">
{{ mapNullablePipe(engineInfos.get(engineId), (v) => v.name) }}
{{ engineInfos.get(engineId)?.name }}
</h2>
<BaseRowCard
v-for="([, characterInfo], characterIndex) in mapNullablePipe(
engineInfos.get(engineId),
(v) => v.characterInfos,
)"
v-for="([, characterInfo], characterIndex) in getOrThrow(
engineInfos,
engineId,
).characterInfos"
:key="characterIndex"
:title="characterInfo.metas.speakerName"
clickable
Expand Down Expand Up @@ -49,12 +49,10 @@
</div>
<h1 class="title">
{{
mapNullablePipe(
engineInfos.get(selectedInfo.engine),
(v) => v.characterInfos,
(v) => mapNullablePipe(selectedInfo, (i) => v.get(i.character)),
(v) => v.metas.speakerName,
)
selectedInfo &&
engineInfos
.get(selectedInfo.engine)
?.characterInfos.get(selectedInfo.character)?.metas.speakerName
}}
</h1>
<BaseDocumentView>
Expand All @@ -75,7 +73,7 @@ import BaseDocumentView from "@/components/Base/BaseDocumentView.vue";
import { useStore } from "@/store";
import { useMarkdownIt } from "@/plugins/markdownItPlugin";
import { EngineId, SpeakerId } from "@/type/preload";
import { mapNullablePipe } from "@/helpers/map";
import { getOrThrow } from "@/helpers/mapHelper";
type DetailKey = { engine: EngineId; character: SpeakerId };
Expand Down
70 changes: 69 additions & 1 deletion src/components/Menu/MenuBar/MenuBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ const openHelpDialog = () => {
});
};
const toggleFullScreen = async () => {
window.backend.toggleFullScreen();
};
const createNewProject = async () => {
if (!uiLocked.value) {
await store.actions.CREATE_NEW_PROJECT({});
Expand All @@ -164,6 +168,21 @@ const importProject = () => {
}
};
/** UIの拡大 */
const zoomIn = async () => {
await store.actions.ZOOM_IN();
};
/** UIの縮小 */
const zoomOut = async () => {
await store.actions.ZOOM_OUT();
};
/** UIの拡大率リセット */
const zoomReset = async () => {
await store.actions.ZOOM_RESET();
};
// 「最近使ったプロジェクト」のメニュー
const recentProjectsSubMenuData = ref<MenuItemData[]>([]);
const updateRecentProjects = async () => {
Expand Down Expand Up @@ -400,7 +419,40 @@ const menudata = computed<MenuItemData[]>(() => [
closeAllDialog();
},
disableWhenUiLocked: false,
subMenu: [...props.viewSubMenuData],
subMenu: [
...props.viewSubMenuData,
{ type: "separator" },
{
type: "button",
label: "全画面表示を切り替え",
onClick: toggleFullScreen,
disableWhenUiLocked: false,
},
{
type: "button",
label: "拡大",
onClick: () => {
void zoomIn();
},
disableWhenUiLocked: false,
},
{
type: "button",
label: "縮小",
onClick: () => {
void zoomOut();
},
disableWhenUiLocked: false,
},
{
type: "button",
label: "拡大率のリセット",
onClick: () => {
void zoomReset();
},
disableWhenUiLocked: false,
},
],
},
{
type: "root",
Expand Down Expand Up @@ -547,6 +599,22 @@ registerHotkeyForAllEditors({
callback: importProject,
name: "プロジェクトを読み込む",
});
registerHotkeyForAllEditors({
callback: toggleFullScreen,
name: "全画面表示を切り替え",
});
registerHotkeyForAllEditors({
callback: zoomIn,
name: "拡大",
});
registerHotkeyForAllEditors({
callback: zoomOut,
name: "縮小",
});
registerHotkeyForAllEditors({
callback: zoomReset,
name: "拡大率のリセット",
});
</script>

<style lang="scss">
Expand Down
22 changes: 12 additions & 10 deletions src/components/Menu/MenuBar/MinMaxCloseButtons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
color="green"
class="title-bar-buttons"
aria-label="最大化"
@click="maximizeWindow()"
@click="toggleMaximizeWindow()"
></QBtn>
</QBadge>
<QBadge
Expand All @@ -57,24 +57,25 @@
></QBtn>

<QBtn
v-if="!isMaximized"
v-if="isMaximized || isFullscreen"
dense
flat
icon="crop_square"
:icon="mdiWindowRestore"
class="title-bar-buttons"
aria-label="最大化"
@click="maximizeWindow()"
></QBtn>
@click="toggleMaximizeWindow()"
>
</QBtn>

<QBtn
v-else
dense
flat
:icon="mdiWindowRestore"
icon="crop_square"
class="title-bar-buttons"
aria-label="最大化"
@click="maximizeWindow()"
>
</QBtn>
@click="toggleMaximizeWindow()"
></QBtn>

<QBtn
dense
Expand All @@ -100,9 +101,10 @@ const closeWindow = async () => {
void store.actions.CHECK_EDITED_AND_NOT_SAVE({ closeOrReload: "close" });
};
const minimizeWindow = () => window.backend.minimizeWindow();
const maximizeWindow = () => window.backend.maximizeWindow();
const toggleMaximizeWindow = () => window.backend.toggleMaximizeWindow();
const isMaximized = computed(() => store.state.isMaximized);
const isFullscreen = computed(() => store.getters.IS_FULLSCREEN);
</script>

<style scoped lang="scss">
Expand Down
Loading

0 comments on commit 6bce5ba

Please sign in to comment.