Skip to content

Commit

Permalink
フルクリーンモードを追加(VOICEVOX#2251)
Browse files Browse the repository at this point in the history
  • Loading branch information
terapotan committed Sep 27, 2024
1 parent f0df6a6 commit 0118d00
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/backend/browser/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ export const api: Sandbox = {
maximizeWindow() {
throw new Error(`Not supported on Browser version: maximizeWindow`);
},
toggleFullScreenMode() {
throw new Error(`Not supported on Browser version: toggleFullScreenMode`);
},
/* eslint-disable no-console */ // ログの吐き出し先は console ぐらいしかないので、ここでは特例で許可している
logError(...params: unknown[]) {
console.error(...params);
Expand Down
8 changes: 7 additions & 1 deletion src/backend/electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,13 @@ registerIpcMainHandle<IpcMainHandle>({
win.maximize();
}
},

TOGGLE_FULLSCREENMODE: () => {
if (win.isFullScreen()) {
win.setFullScreen(false);
} else {
win.setFullScreen(true);
}
},
OPEN_LOG_DIRECTORY: () => {
void shell.openPath(app.getPath("logs"));
},
Expand Down
4 changes: 4 additions & 0 deletions src/backend/electron/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ const api: Sandbox = {
void ipcRendererInvokeProxy.MAXIMIZE_WINDOW();
},

toggleFullScreenMode: () => {
void ipcRendererInvokeProxy.TOGGLE_FULLSCREENMODE();
},

logError: (...params) => {
console.error(...params);
// 経緯 https://github.com/VOICEVOX/voicevox/pull/1620#discussion_r1371804569
Expand Down
19 changes: 18 additions & 1 deletion src/components/Menu/MenuBar/MenuBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ const openHelpDialog = () => {
});
};
const toggleFullScreenMode = async () => {
window.backend.toggleFullScreenMode();
};
const createNewProject = async () => {
if (!uiLocked.value) {
await store.dispatch("CREATE_NEW_PROJECT", {});
Expand Down Expand Up @@ -396,7 +400,16 @@ const menudata = computed<MenuItemData[]>(() => [
closeAllDialog();
},
disableWhenUiLocked: false,
subMenu: [...props.viewSubMenuData],
subMenu: [
...props.viewSubMenuData,
{ type: "separator" },
{
type: "button",
label: "全画面表示/ウィンドウ表示切り替え",
onClick: toggleFullScreenMode,
disableWhenUiLocked: false,
},
],
},
{
type: "root",
Expand Down Expand Up @@ -527,6 +540,10 @@ function registerHotkeyForAllEditors(action: Omit<HotkeyAction, "editor">) {
});
}
registerHotkeyForAllEditors({
callback: toggleFullScreenMode,
name: "全画面表示/ウィンドウ表示切り替え",
});
registerHotkeyForAllEditors({
callback: createNewProject,
name: "新規プロジェクト",
Expand Down
5 changes: 5 additions & 0 deletions src/type/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ export type IpcIHData = {
return: void;
};

TOGGLE_FULLSCREENMODE: {
args: [];
return: void;
};

OPEN_LOG_DIRECTORY: {
args: [];
return: void;
Expand Down
6 changes: 6 additions & 0 deletions src/type/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ export const defaultHotkeySettings: HotkeySettingType[] = [
action: "新規プロジェクト",
combination: HotkeyCombination(!isMac ? "Ctrl N" : "Meta N"),
},
{
action: "全画面表示/ウィンドウ表示切り替え",
combination: HotkeyCombination(!isMac ? "F11" : "Ctrl Meta F"),
},
{
action: "プロジェクトを名前を付けて保存",
combination: HotkeyCombination(!isMac ? "Ctrl Shift S" : "Shift Meta S"),
Expand Down Expand Up @@ -273,6 +277,7 @@ export interface Sandbox {
closeWindow(): void;
minimizeWindow(): void;
maximizeWindow(): void;
toggleFullScreenMode(): void;
logError(...params: unknown[]): void;
logWarn(...params: unknown[]): void;
logInfo(...params: unknown[]): void;
Expand Down Expand Up @@ -466,6 +471,7 @@ export const hotkeyActionNameSchema = z.enum([
"元に戻す",
"やり直す",
"新規プロジェクト",
"全画面表示/ウィンドウ表示切り替え",
"プロジェクトを名前を付けて保存",
"プロジェクトを上書き保存",
"プロジェクトを読み込む",
Expand Down

0 comments on commit 0118d00

Please sign in to comment.