mirror of
https://github.com/upscayl/upscayl.git
synced 2024-11-27 17:00:52 +01:00
Merge remote-tracking branch 'origin/main' into suvojit/overwrite-fix
This commit is contained in:
commit
3a1721222e
@ -78,6 +78,7 @@ app.on("ready", async () => {
|
|||||||
webSecurity: false,
|
webSecurity: false,
|
||||||
preload: join(__dirname, "preload.js"),
|
preload: join(__dirname, "preload.js"),
|
||||||
},
|
},
|
||||||
|
titleBarStyle: getPlatform() === "mac" ? "hiddenInset" : "default",
|
||||||
});
|
});
|
||||||
const url = isDev
|
const url = isDev
|
||||||
? "http://localhost:8000"
|
? "http://localhost:8000"
|
||||||
@ -159,9 +160,9 @@ app.on("ready", async () => {
|
|||||||
// GET IMAGE QUALITY (NUMBER) TO LOCAL STORAGE
|
// GET IMAGE QUALITY (NUMBER) TO LOCAL STORAGE
|
||||||
mainWindow.webContents
|
mainWindow.webContents
|
||||||
.executeJavaScript('localStorage.getItem("quality");', true)
|
.executeJavaScript('localStorage.getItem("quality");', true)
|
||||||
.then((overwriteToggle: string | null) => {
|
.then((lastSavedQuality: string | null) => {
|
||||||
if (overwriteToggle !== null) {
|
if (lastSavedQuality !== null) {
|
||||||
quality = parseInt(overwriteToggle);
|
quality = parseInt(lastSavedQuality);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mainWindow.webContents.send(commands.OS, getPlatform());
|
mainWindow.webContents.send(commands.OS, getPlatform());
|
||||||
@ -408,8 +409,18 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
|
|||||||
"." +
|
"." +
|
||||||
saveImageAs;
|
saveImageAs;
|
||||||
|
|
||||||
|
// GET OVERWRITE SETTINGS FROM LOCAL STORAGE
|
||||||
|
mainWindow.webContents
|
||||||
|
.executeJavaScript('localStorage.getItem("overwrite");', true)
|
||||||
|
.then((lastSavedOverwrite: boolean | null) => {
|
||||||
|
if (lastSavedOverwrite !== null) {
|
||||||
|
console.log("Overwrite: ", lastSavedOverwrite);
|
||||||
|
overwrite = lastSavedOverwrite;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// UPSCALE
|
// UPSCALE
|
||||||
if (fs.existsSync(outFile) && !overwrite) {
|
if (fs.existsSync(outFile) && overwrite === false) {
|
||||||
// If already upscayled, just output that file
|
// If already upscayled, just output that file
|
||||||
logit("✅ Already upscayled at: ", outFile);
|
logit("✅ Already upscayled at: ", outFile);
|
||||||
mainWindow.webContents.send(commands.UPSCAYL_DONE, outFile);
|
mainWindow.webContents.send(commands.UPSCAYL_DONE, outFile);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { ipcRenderer, contextBridge } from "electron";
|
import { ipcRenderer, contextBridge } from "electron";
|
||||||
|
import getPlatform from "./getPlatform";
|
||||||
|
|
||||||
// 'ipcRenderer' will be available in index.js with the method 'window.electron'
|
// 'ipcRenderer' will be available in index.js with the method 'window.electron'
|
||||||
contextBridge.exposeInMainWorld("electron", {
|
contextBridge.exposeInMainWorld("electron", {
|
||||||
@ -9,4 +10,5 @@ contextBridge.exposeInMainWorld("electron", {
|
|||||||
}),
|
}),
|
||||||
invoke: (command: string, payload: any) =>
|
invoke: (command: string, payload: any) =>
|
||||||
ipcRenderer.invoke(command, payload),
|
ipcRenderer.invoke(command, payload),
|
||||||
|
platform: getPlatform(),
|
||||||
});
|
});
|
||||||
|
@ -5,7 +5,7 @@ export default function Header({ version }: { version: string }) {
|
|||||||
<a
|
<a
|
||||||
href="https://github.com/upscayl/upscayl"
|
href="https://github.com/upscayl/upscayl"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
className="outline-none focus-visible:ring-2"
|
className={`outline-none focus-visible:ring-2`}
|
||||||
data-tip="Star us on GitHub 😁">
|
data-tip="Star us on GitHub 😁">
|
||||||
<div className="flex items-center gap-3 px-5 py-5">
|
<div className="flex items-center gap-3 px-5 py-5">
|
||||||
<img src="icon.png" className="inline-block w-14" alt="Upscayl Logo" />
|
<img src="icon.png" className="inline-block w-14" alt="Upscayl Logo" />
|
||||||
|
@ -42,14 +42,14 @@ export function ImageFormatSelect({
|
|||||||
onClick={() => setExportType("jpg")}>
|
onClick={() => setExportType("jpg")}>
|
||||||
JPG
|
JPG
|
||||||
</button>
|
</button>
|
||||||
{/* WEBP */}
|
{/* WEBP
|
||||||
<button
|
<button
|
||||||
className={`btn-primary btn ${
|
className={`btn-primary btn ${
|
||||||
saveImageAs === "webp" && "btn-accent"
|
saveImageAs === "webp" && "btn-accent"
|
||||||
}`}
|
}`}
|
||||||
onClick={() => setExportType("webp")}>
|
onClick={() => setExportType("webp")}>
|
||||||
WEBP
|
WEBP
|
||||||
</button>
|
</button> */}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -11,9 +11,12 @@ export function QualityInput({
|
|||||||
}: QualityInputProps) {
|
}: QualityInputProps) {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
<p className="text-sm font-medium uppercase">
|
<div className="flex gap-1 text-sm font-medium uppercase">
|
||||||
Image Compression ({quality}%)
|
<p className="shrink-0">Image Compression ({quality}%)</p>
|
||||||
</p>
|
<p className="badge-primary badge text-[10px] font-medium">
|
||||||
|
EXPERIMENTAL
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
<input
|
<input
|
||||||
type="range"
|
type="range"
|
||||||
placeholder="Type here"
|
placeholder="Type here"
|
||||||
|
@ -10,9 +10,13 @@ const ToggleOverwrite = ({ overwrite, setOverwrite }: ToggleOverwriteProps) => {
|
|||||||
if (!localStorage.getItem("overwrite")) {
|
if (!localStorage.getItem("overwrite")) {
|
||||||
localStorage.setItem("overwrite", JSON.stringify(overwrite));
|
localStorage.setItem("overwrite", JSON.stringify(overwrite));
|
||||||
} else {
|
} else {
|
||||||
setOverwrite(localStorage.getItem("overwrite") === 'true');
|
const currentlySavedOverwrite = localStorage.getItem("overwrite");
|
||||||
|
if (currentlySavedOverwrite) {
|
||||||
|
setOverwrite(JSON.parse(currentlySavedOverwrite));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
<p className="text-sm font-medium">OVERWRITE PREVIOUS UPSCALE</p>
|
<p className="text-sm font-medium">OVERWRITE PREVIOUS UPSCALE</p>
|
||||||
@ -21,11 +25,13 @@ const ToggleOverwrite = ({ overwrite, setOverwrite }: ToggleOverwriteProps) => {
|
|||||||
className="toggle"
|
className="toggle"
|
||||||
checked={overwrite}
|
checked={overwrite}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setOverwrite((oldValue) => {
|
setOverwrite((oldValue: boolean) => {
|
||||||
if (oldValue === true) {
|
if (oldValue) {
|
||||||
localStorage.removeItem("overwrite");
|
localStorage.removeItem("overwrite");
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return !oldValue;
|
|
||||||
});
|
});
|
||||||
localStorage.setItem("overwrite", JSON.stringify(!overwrite));
|
localStorage.setItem("overwrite", JSON.stringify(!overwrite));
|
||||||
}}
|
}}
|
||||||
|
@ -130,7 +130,8 @@ function LeftPaneImageSteps({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="animate-step-in animate flex h-screen flex-col gap-7 overflow-y-auto p-5 overflow-x-hidden">
|
<div
|
||||||
|
className={`animate-step-in animate flex h-screen flex-col gap-7 overflow-y-auto p-5 overflow-x-hidden`}>
|
||||||
{/* BATCH OPTION */}
|
{/* BATCH OPTION */}
|
||||||
<div className="flex flex-row items-center gap-2">
|
<div className="flex flex-row items-center gap-2">
|
||||||
<input
|
<input
|
||||||
@ -139,7 +140,7 @@ function LeftPaneImageSteps({
|
|||||||
defaultChecked={batchMode}
|
defaultChecked={batchMode}
|
||||||
onClick={() => setBatchMode((oldValue) => !oldValue)}></input>
|
onClick={() => setBatchMode((oldValue) => !oldValue)}></input>
|
||||||
<p
|
<p
|
||||||
className="mr-1 inline-block cursor-help text-sm"
|
className="mr-1 inline-block cursor-help text-sm"
|
||||||
data-tooltip-id="tooltip"
|
data-tooltip-id="tooltip"
|
||||||
data-tooltip-content="This will let you Upscayl all files in a folder at once">
|
data-tooltip-content="This will let you Upscayl all files in a folder at once">
|
||||||
Batch Upscayl
|
Batch Upscayl
|
||||||
|
@ -436,9 +436,22 @@ const Home = () => {
|
|||||||
|
|
||||||
const allowedFileTypes = ["png", "jpg", "jpeg", "webp"];
|
const allowedFileTypes = ["png", "jpg", "jpeg", "webp"];
|
||||||
|
|
||||||
|
if (typeof window === "undefined") {
|
||||||
|
return (
|
||||||
|
<img
|
||||||
|
src="/icon.png"
|
||||||
|
alt="Upscayl icon"
|
||||||
|
className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-36 animate-pulse"
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-screen w-screen flex-row overflow-hidden bg-base-300">
|
<div className="flex h-screen w-screen flex-row overflow-hidden bg-base-300">
|
||||||
<div className="flex h-screen w-128 flex-col rounded-r-3xl bg-base-100">
|
<div className={`flex h-screen w-128 flex-col bg-base-100`}>
|
||||||
|
{window.electron.platform === "mac" && (
|
||||||
|
<div className="pt-8 mac-titlebar"></div>
|
||||||
|
)}
|
||||||
{/* HEADER */}
|
{/* HEADER */}
|
||||||
<Header version={version} />
|
<Header version={version} />
|
||||||
|
|
||||||
@ -493,6 +506,10 @@ const Home = () => {
|
|||||||
onDragEnter={(e) => handleDragEnter(e)}
|
onDragEnter={(e) => handleDragEnter(e)}
|
||||||
onDragLeave={(e) => handleDragLeave(e)}
|
onDragLeave={(e) => handleDragLeave(e)}
|
||||||
onPaste={(e) => handlePaste(e)}>
|
onPaste={(e) => handlePaste(e)}>
|
||||||
|
{window.electron.platform === "mac" && (
|
||||||
|
<div className="absolute top-0 w-full h-8 mac-titlebar"></div>
|
||||||
|
)}
|
||||||
|
|
||||||
{progress.length > 0 &&
|
{progress.length > 0 &&
|
||||||
upscaledImagePath.length === 0 &&
|
upscaledImagePath.length === 0 &&
|
||||||
upscaledBatchFolderPath.length === 0 ? (
|
upscaledBatchFolderPath.length === 0 ? (
|
||||||
|
1
renderer/renderer.d.ts
vendored
1
renderer/renderer.d.ts
vendored
@ -4,6 +4,7 @@ export interface IElectronAPI {
|
|||||||
on: (command, func?) => IpcRenderer;
|
on: (command, func?) => IpcRenderer;
|
||||||
send: (command, func?) => IpcRenderer;
|
send: (command, func?) => IpcRenderer;
|
||||||
invoke: (command, func?) => any;
|
invoke: (command, func?) => any;
|
||||||
|
platform: "mac" | "win" | "linux";
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
@ -161,6 +161,10 @@
|
|||||||
@apply rounded-btn h-10 ring-1 ring-slate-500 cursor-pointer !border-0 !border-none !border-transparent bg-primary shadow-none;
|
@apply rounded-btn h-10 ring-1 ring-slate-500 cursor-pointer !border-0 !border-none !border-transparent bg-primary shadow-none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mac-titlebar {
|
||||||
|
-webkit-app-region: drag;
|
||||||
|
}
|
||||||
|
|
||||||
@keyframes animate-step-in {
|
@keyframes animate-step-in {
|
||||||
0% {
|
0% {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user