diff --git a/electron/commands.ts b/electron/commands.ts index cc9dad4..ee334c3 100644 --- a/electron/commands.ts +++ b/electron/commands.ts @@ -1,6 +1,7 @@ const commands = { SELECT_FILE: "Select a File", SELECT_FOLDER: "Select a Folder", + SELECT_CUSTOM_MODEL_FOLDER: "Select a Custom Model Folder", UPSCAYL: "Upscale the Image", UPSCAYL_DONE: "Upscaling Done", UPSCAYL_PROGRESS: "Send Progress from Main to Renderer", diff --git a/electron/index.ts b/electron/index.ts index a5e2f52..85f48c2 100644 --- a/electron/index.ts +++ b/electron/index.ts @@ -89,11 +89,17 @@ app.on("window-all-closed", app.quit); log.log(app.getAppPath()); +let imagePath: string | undefined = undefined; +let folderPath: string | undefined = undefined; +let customModelsFolderPath: string | undefined = undefined; + //------------------------Select File-----------------------------// // ! DONT FORGET TO RESTART THE APP WHEN YOU CHANGE CODE HERE ipcMain.handle(commands.SELECT_FILE, async () => { const { canceled, filePaths } = await dialog.showOpenDialog({ properties: ["openFile", "multiSelections"], + title: "Select Image", + defaultPath: imagePath, }); if (canceled) { @@ -101,6 +107,7 @@ ipcMain.handle(commands.SELECT_FILE, async () => { return "cancelled"; } else { log.log("Selected File Path: ", filePaths[0]); + imagePath = filePaths[0]; // CREATE input AND upscaled FOLDER return filePaths[0]; } @@ -108,15 +115,34 @@ ipcMain.handle(commands.SELECT_FILE, async () => { //------------------------Select Folder-----------------------------// ipcMain.handle(commands.SELECT_FOLDER, async (event, message) => { - const { canceled, filePaths } = await dialog.showOpenDialog({ + const { canceled, filePaths: folderPaths } = await dialog.showOpenDialog({ properties: ["openDirectory"], + defaultPath: folderPath, }); if (canceled) { log.log("operation cancelled"); return "cancelled"; } else { - log.log(filePaths[0]); - return filePaths[0]; + log.log("Selected Folder Path: ", folderPaths[0]); + folderPath = folderPaths[0]; + return folderPaths[0]; + } +}); + +//------------------------Select Custom Models Folder---------------------// +ipcMain.handle(commands.SELECT_CUSTOM_MODEL_FOLDER, async (event, message) => { + const { canceled, filePaths: folderPaths } = await dialog.showOpenDialog({ + properties: ["openDirectory"], + title: "Select Custom Models Folder", + defaultPath: customModelsFolderPath, + }); + if (canceled) { + log.log("operation cancelled"); + return "cancelled"; + } else { + log.log("Custom Folder Path: ", folderPaths[0]); + customModelsFolderPath = folderPaths[0]; + return folderPaths[0]; } }); diff --git a/main/commands.js b/main/commands.js index bc6485b..810b487 100644 --- a/main/commands.js +++ b/main/commands.js @@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const commands = { SELECT_FILE: "Select a File", SELECT_FOLDER: "Select a Folder", + SELECT_CUSTOM_MODEL_FOLDER: "Select a Custom Model Folder", UPSCAYL: "Upscale the Image", UPSCAYL_DONE: "Upscaling Done", UPSCAYL_PROGRESS: "Send Progress from Main to Renderer", diff --git a/main/index.js b/main/index.js index 41a5972..6cf7dc5 100644 --- a/main/index.js +++ b/main/index.js @@ -105,6 +105,20 @@ electron_1.ipcMain.handle(commands_1.default.SELECT_FOLDER, (event, message) => return filePaths[0]; } })); +//------------------------Select Custom Models Folder---------------------// +electron_1.ipcMain.handle(commands_1.default.SELECT_CUSTOM_MODEL_FOLDER, (event, message) => __awaiter(void 0, void 0, void 0, function* () { + const { canceled, filePaths } = yield electron_1.dialog.showOpenDialog({ + properties: ["openDirectory"], + }); + if (canceled) { + electron_log_1.default.log("operation cancelled"); + return "cancelled"; + } + else { + electron_log_1.default.log(filePaths[0]); + return filePaths[0]; + } +})); //------------------------Open Folder-----------------------------// electron_1.ipcMain.on(commands_1.default.OPEN_FOLDER, (event, payload) => __awaiter(void 0, void 0, void 0, function* () { electron_log_1.default.log(payload); diff --git a/renderer/components/SettingsTab.tsx b/renderer/components/SettingsTab.tsx index 56d40a7..d67321e 100644 --- a/renderer/components/SettingsTab.tsx +++ b/renderer/components/SettingsTab.tsx @@ -3,59 +3,29 @@ import Select from "react-select"; import ReactTooltip from "react-tooltip"; import { themeChange } from "theme-change"; import log from "electron-log/renderer"; +import commands from "../../electron/commands"; interface IProps { - progress: string; - selectImageHandler: () => Promise; - selectFolderHandler: () => Promise; - handleModelChange: (e: any) => void; - handleDrop: (e: any) => void; - outputHandler: () => Promise; - upscaylHandler: () => Promise; batchMode: boolean; setBatchMode: React.Dispatch>; imagePath: string; - outputPath: string; - doubleUpscayl: boolean; - setDoubleUpscayl: React.Dispatch>; - model: string; setModel: React.Dispatch>; - isVideo: boolean; - setIsVideo: React.Dispatch>; saveImageAs: string; setSaveImageAs: React.Dispatch>; gpuId: string; setGpuId: React.Dispatch>; - dimensions: { - width: number | null; - height: number | null; - }; logData: string[]; } function SettingsTab({ - progress, - selectImageHandler, - selectFolderHandler, - handleModelChange, - handleDrop, - outputHandler, - upscaylHandler, batchMode, setBatchMode, imagePath, - outputPath, - doubleUpscayl, - setDoubleUpscayl, - model, setModel, - isVideo, - setIsVideo, gpuId, setGpuId, saveImageAs, setSaveImageAs, - dimensions, logData, }: IProps) { const [currentModel, setCurrentModel] = useState<{ @@ -252,6 +222,21 @@ function SettingsTab({ /> + {/* GPU ID INPUT */} +
+

Custom Models Path:

+

/fasfas/asfasf/asf/saf

+ +
+

Logs

- + {logData.length === 0 && (

No logs to show

)} diff --git a/renderer/pages/index.tsx b/renderer/pages/index.tsx index f49b5cb..1954e76 100644 --- a/renderer/pages/index.tsx +++ b/renderer/pages/index.tsx @@ -477,28 +477,14 @@ const Home = () => { {selectedTab === 1 && ( )}