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

refactor: WindowManagerを追加 #2455

Merged
merged 13 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from 6 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 changes: 15 additions & 5 deletions src/backend/electron/engineAndVvppController.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import path from "path";
import fs from "fs";
import log from "electron-log/main";
import { BrowserWindow, dialog } from "electron";
import { dialog, MessageBoxSyncOptions } from "electron";

import { getConfigManager } from "./electronConfig";
import { getEngineInfoManager } from "./manager/engineInfoManager";
import { getEngineProcessManager } from "./manager/engineProcessManager";
import { getRuntimeInfoManager } from "./manager/RuntimeInfoManager";
import { getVvppManager } from "./manager/vvppManager";
import { getWindowManager } from "./manager/windowManager";
import {
EngineId,
EngineInfo,
Expand Down Expand Up @@ -67,28 +68,37 @@ export class EngineAndVvppController {
vvppPath,
reloadNeeded,
reloadCallback,
win,
}: {
vvppPath: string;
reloadNeeded: boolean;
reloadCallback?: () => void; // 再読み込みが必要な場合のコールバック
win: BrowserWindow; // dialog表示に必要。 FIXME: dialog表示関数をDI可能にし、winを削除する
}) {
const result = dialog.showMessageBoxSync(win, {
// FIXME: dialog表示関数をDI可能にする。
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
const win = getWindowManager().win;
const option: MessageBoxSyncOptions = {
type: "warning",
title: "エンジン追加の確認",
message: `この操作はコンピュータに損害を与える可能性があります。エンジンの配布元が信頼できない場合は追加しないでください。`,
buttons: ["追加", "キャンセル"],
noLink: true,
cancelId: 1,
});
};
let result: number;
if (win != undefined) {
result = dialog.showMessageBoxSync(win, option);
} else {
result = dialog.showMessageBoxSync(option);
}
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
if (result == 1) {
return;
}

await this.installVvppEngine(vvppPath);

if (reloadNeeded) {
if (win == undefined) {
throw new Error("win == undefined");
}
void dialog
.showMessageBox(win, {
type: "info",
Expand Down
Loading
Loading