mirror of
https://github.com/upscayl/upscayl.git
synced 2025-01-19 01:24:09 +01:00
added STOP button
This commit is contained in:
parent
c1878ba42d
commit
48517e9896
@ -21,6 +21,7 @@ const commands = {
|
|||||||
GET_MODELS_LIST: "Send models list from main to renderer",
|
GET_MODELS_LIST: "Send models list from main to renderer",
|
||||||
CUSTOM_MODEL_FILES_LIST: "Send custom model files list to renderer",
|
CUSTOM_MODEL_FILES_LIST: "Send custom model files list to renderer",
|
||||||
LOG: "Log",
|
LOG: "Log",
|
||||||
|
STOP: "Stop the current operation",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default commands;
|
export default commands;
|
||||||
|
@ -14,7 +14,6 @@ import { format } from "url";
|
|||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
|
|
||||||
import { execPath, modelsPath } from "./binaries";
|
import { execPath, modelsPath } from "./binaries";
|
||||||
|
|
||||||
// Packages
|
// Packages
|
||||||
import {
|
import {
|
||||||
BrowserWindow,
|
BrowserWindow,
|
||||||
@ -29,6 +28,9 @@ import { spawnUpscayl } from "./upscayl";
|
|||||||
import prepareNext from "electron-next";
|
import prepareNext from "electron-next";
|
||||||
import isDev from "electron-is-dev";
|
import isDev from "electron-is-dev";
|
||||||
import commands from "./commands";
|
import commands from "./commands";
|
||||||
|
import { ChildProcessWithoutNullStreams } from "child_process";
|
||||||
|
|
||||||
|
let ChildProcess : { process: ChildProcessWithoutNullStreams; kill: () => boolean; }[] = []
|
||||||
|
|
||||||
log.initialize({ preload: true });
|
log.initialize({ preload: true });
|
||||||
|
|
||||||
@ -314,6 +316,12 @@ ipcMain.on(commands.OPEN_FOLDER, async (event, payload) => {
|
|||||||
shell.openPath(payload);
|
shell.openPath(payload);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcMain.on(commands.STOP, async (event, payload) => {
|
||||||
|
ChildProcess.forEach((child) => {
|
||||||
|
child.kill();
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
//------------------------Double Upscayl-----------------------------//
|
//------------------------Double Upscayl-----------------------------//
|
||||||
ipcMain.on(commands.DOUBLE_UPSCAYL, async (event, payload) => {
|
ipcMain.on(commands.DOUBLE_UPSCAYL, async (event, payload) => {
|
||||||
const model = payload.model as string;
|
const model = payload.model as string;
|
||||||
@ -359,6 +367,8 @@ ipcMain.on(commands.DOUBLE_UPSCAYL, async (event, payload) => {
|
|||||||
let isAlpha = false;
|
let isAlpha = false;
|
||||||
let failed2 = false;
|
let failed2 = false;
|
||||||
|
|
||||||
|
ChildProcess.push(upscayl)
|
||||||
|
|
||||||
const onData = (data) => {
|
const onData = (data) => {
|
||||||
// CONVERT DATA TO STRING
|
// CONVERT DATA TO STRING
|
||||||
data = data.toString();
|
data = data.toString();
|
||||||
@ -427,6 +437,8 @@ ipcMain.on(commands.DOUBLE_UPSCAYL, async (event, payload) => {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ChildProcess.push(upscayl2)
|
||||||
|
|
||||||
upscayl2.process.stderr.on("data", onData2);
|
upscayl2.process.stderr.on("data", onData2);
|
||||||
upscayl2.process.on("error", onError2);
|
upscayl2.process.on("error", onError2);
|
||||||
upscayl2.process.on("close", onClose2);
|
upscayl2.process.on("close", onClose2);
|
||||||
@ -493,6 +505,8 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
|
|||||||
let isAlpha = false;
|
let isAlpha = false;
|
||||||
let failed = false;
|
let failed = false;
|
||||||
|
|
||||||
|
ChildProcess.push(upscayl)
|
||||||
|
|
||||||
const onData = (data: string) => {
|
const onData = (data: string) => {
|
||||||
logit("image upscayl: ", data.toString());
|
logit("image upscayl: ", data.toString());
|
||||||
data = data.toString();
|
data = data.toString();
|
||||||
@ -564,6 +578,8 @@ ipcMain.on(commands.FOLDER_UPSCAYL, async (event, payload) => {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ChildProcess.push(upscayl)
|
||||||
|
|
||||||
let failed = false;
|
let failed = false;
|
||||||
const onData = (data: any) => {
|
const onData = (data: any) => {
|
||||||
logit("🚀 => upscayl.stderr.on => stderr.toString()", data.toString());
|
logit("🚀 => upscayl.stderr.on => stderr.toString()", data.toString());
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import Spinner from "./icons/Spinner";
|
import Spinner from "./icons/Spinner";
|
||||||
|
|
||||||
function ProgressBar({ progress, doubleUpscaylCounter }) {
|
function ProgressBar({ progress, doubleUpscaylCounter, stopHandler }) {
|
||||||
return (
|
return (
|
||||||
<div className="absolute flex h-full w-full flex-col items-center justify-center bg-base-300/50 backdrop-blur-lg">
|
<div className="absolute flex h-full w-full flex-col items-center justify-center bg-base-300/50 backdrop-blur-lg">
|
||||||
<div className="flex flex-col items-center gap-2">
|
<div className="flex flex-col items-center gap-2">
|
||||||
@ -14,6 +14,7 @@ function ProgressBar({ progress, doubleUpscaylCounter }) {
|
|||||||
<p className="rounded-full bg-base-300 px-2 py-1 text-sm font-medium">
|
<p className="rounded-full bg-base-300 px-2 py-1 text-sm font-medium">
|
||||||
Doing the Upscayl magic...
|
Doing the Upscayl magic...
|
||||||
</p>
|
</p>
|
||||||
|
<button onClick={stopHandler}>STOP</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -141,6 +141,7 @@ const Home = () => {
|
|||||||
window.electron.on(commands.UPSCAYL_DONE, (_, data: string) => {
|
window.electron.on(commands.UPSCAYL_DONE, (_, data: string) => {
|
||||||
setProgress("");
|
setProgress("");
|
||||||
setUpscaledImagePath(data);
|
setUpscaledImagePath(data);
|
||||||
|
console.log("upscaledImagePath: ", upscaledImagePath)
|
||||||
addToLog(data);
|
addToLog(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -472,6 +473,11 @@ const Home = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const stopHandler = () => {
|
||||||
|
window.electron.send(commands.STOP);
|
||||||
|
resetImagePaths();
|
||||||
|
}
|
||||||
|
|
||||||
const allowedFileTypes = ["png", "jpg", "jpeg", "webp"];
|
const allowedFileTypes = ["png", "jpg", "jpeg", "webp"];
|
||||||
const allowedVideoFileTypes = ["webm", "mp4", "mkv"];
|
const allowedVideoFileTypes = ["webm", "mp4", "mkv"];
|
||||||
|
|
||||||
@ -573,6 +579,7 @@ const Home = () => {
|
|||||||
<ProgressBar
|
<ProgressBar
|
||||||
progress={progress}
|
progress={progress}
|
||||||
doubleUpscaylCounter={doubleUpscaylCounter}
|
doubleUpscaylCounter={doubleUpscaylCounter}
|
||||||
|
stopHandler={stopHandler}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user