From 64452016e675c9a090eb848b7d74df285eddf986 Mon Sep 17 00:00:00 2001 From: madosuki Date: Fri, 26 Nov 2021 17:31:49 +0900 Subject: [PATCH] =?UTF-8?q?Electron16=E3=81=8B=E3=81=A4Linux=E3=81=A0?= =?UTF-8?q?=E3=81=A8showOpenDialogSync=E3=80=81showSaveDialogSync=E3=81=8C?= =?UTF-8?q?=E5=8B=95=E4=BD=9C=E3=81=97=E3=81=AA=E3=81=84=E3=81=AE=E3=81=A7?= =?UTF-8?q?=E9=9D=9E=E5=90=8C=E6=9C=9F=E7=89=88=E3=81=AB=E7=BD=AE=E3=81=8D?= =?UTF-8?q?=E6=8F=9B=E3=81=88=20(#512)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add detectNvidia function * follow to menu bar * remove no longer a variable * run fmt * fix typo * remove utils.ts and some changes in background.ts * change message box type and detail, and change behaviour of setOnLaunchModeItemClicked * recreate package-lock.json using node 12.18.2 * re recreate package-lock.json using node 12.18.2 and npm 7.20.5 * recreate package-lock.json using node 12.18.2 and npm 6.14.5 * recreate package-lock.json using node 12.18.2 and npm 7.20.3 * fix conflict * fix * Revert "fix" This reverts commit 99b1defaa3f943f8d45036979ab4250c7efe49ed. * fix --- src/background.ts | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/background.ts b/src/background.ts index 45dbc046b3..a40c9ebd55 100644 --- a/src/background.ts +++ b/src/background.ts @@ -455,36 +455,49 @@ ipcMainHandle("GET_OSS_COMMUNITY_INFOS", () => { return ossCommunityInfos; }); -ipcMainHandle("SHOW_AUDIO_SAVE_DIALOG", (_, { title, defaultPath }) => { - return dialog.showSaveDialogSync(win, { +ipcMainHandle("SHOW_AUDIO_SAVE_DIALOG", async (_, { title, defaultPath }) => { + const result = await dialog.showSaveDialog(win, { title, defaultPath, filters: [{ name: "Wave File", extensions: ["wav"] }], properties: ["createDirectory"], }); + return result.filePath; }); -ipcMainHandle("SHOW_OPEN_DIRECTORY_DIALOG", (_, { title }) => { - return dialog.showOpenDialogSync(win, { +ipcMainHandle("SHOW_OPEN_DIRECTORY_DIALOG", async (_, { title }) => { + const result = await dialog.showOpenDialog(win, { title, properties: ["openDirectory", "createDirectory"], - })?.[0]; + }); + if (result.canceled) { + return undefined; + } + return result.filePaths[0]; }); -ipcMainHandle("SHOW_PROJECT_SAVE_DIALOG", (_, { title }) => { - return dialog.showSaveDialogSync(win, { +ipcMainHandle("SHOW_PROJECT_SAVE_DIALOG", async (_, { title }) => { + const result = await dialog.showSaveDialog(win, { title, filters: [{ name: "VOICEVOX Project file", extensions: ["vvproj"] }], properties: ["showOverwriteConfirmation"], }); + if (result.canceled) { + return undefined; + } + return result.filePath; }); -ipcMainHandle("SHOW_PROJECT_LOAD_DIALOG", (_, { title }) => { - return dialog.showOpenDialogSync(win, { +ipcMainHandle("SHOW_PROJECT_LOAD_DIALOG", async (_, { title }) => { + const result = await dialog.showOpenDialog(win, { title, filters: [{ name: "VOICEVOX Project file", extensions: ["vvproj"] }], properties: ["openFile"], }); + if (result.canceled) { + return undefined; + } + return result.filePaths; }); ipcMainHandle("SHOW_INFO_DIALOG", (_, { title, message, buttons }) => {