diff --git a/electron/index.ts b/electron/index.ts index 47dece9..bbf525f 100644 --- a/electron/index.ts +++ b/electron/index.ts @@ -78,6 +78,7 @@ app.on("ready", async () => { webSecurity: false, preload: join(__dirname, "preload.js"), }, + titleBarStyle: getPlatform() === "mac" ? "hiddenInset" : "default", }); const url = isDev ? "http://localhost:8000" @@ -159,9 +160,9 @@ app.on("ready", async () => { // GET IMAGE QUALITY (NUMBER) TO LOCAL STORAGE mainWindow.webContents .executeJavaScript('localStorage.getItem("quality");', true) - .then((overwriteToggle: string | null) => { - if (overwriteToggle !== null) { - quality = parseInt(overwriteToggle); + .then((lastSavedQuality: string | null) => { + if (lastSavedQuality !== null) { + quality = parseInt(lastSavedQuality); } }); mainWindow.webContents.send(commands.OS, getPlatform()); @@ -408,8 +409,18 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => { "." + 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 - if (fs.existsSync(outFile) && !overwrite) { + if (fs.existsSync(outFile) && overwrite === false) { // If already upscayled, just output that file logit("✅ Already upscayled at: ", outFile); mainWindow.webContents.send(commands.UPSCAYL_DONE, outFile); diff --git a/electron/preload.ts b/electron/preload.ts index 8cad08d..9ebdddc 100644 --- a/electron/preload.ts +++ b/electron/preload.ts @@ -1,4 +1,5 @@ import { ipcRenderer, contextBridge } from "electron"; +import getPlatform from "./getPlatform"; // 'ipcRenderer' will be available in index.js with the method 'window.electron' contextBridge.exposeInMainWorld("electron", { @@ -9,4 +10,5 @@ contextBridge.exposeInMainWorld("electron", { }), invoke: (command: string, payload: any) => ipcRenderer.invoke(command, payload), + platform: getPlatform(), }); diff --git a/renderer/components/Header.tsx b/renderer/components/Header.tsx index 9d82234..1c8bb54 100644 --- a/renderer/components/Header.tsx +++ b/renderer/components/Header.tsx @@ -5,7 +5,7 @@ export default function Header({ version }: { version: string }) {
Upscayl Logo diff --git a/renderer/components/settings-tab/ImageFormatSelect.tsx b/renderer/components/settings-tab/ImageFormatSelect.tsx index 0c84ebb..f756705 100644 --- a/renderer/components/settings-tab/ImageFormatSelect.tsx +++ b/renderer/components/settings-tab/ImageFormatSelect.tsx @@ -42,14 +42,14 @@ export function ImageFormatSelect({ onClick={() => setExportType("jpg")}> JPG - {/* WEBP */} + {/* WEBP + */}
diff --git a/renderer/components/settings-tab/QualityInput.tsx b/renderer/components/settings-tab/QualityInput.tsx index 1cd17c2..0129be9 100644 --- a/renderer/components/settings-tab/QualityInput.tsx +++ b/renderer/components/settings-tab/QualityInput.tsx @@ -11,9 +11,12 @@ export function QualityInput({ }: QualityInputProps) { return (
-

- Image Compression ({quality}%) -

+
+

Image Compression ({quality}%)

+

+ EXPERIMENTAL +

+
{ if (!localStorage.getItem("overwrite")) { localStorage.setItem("overwrite", JSON.stringify(overwrite)); } else { - setOverwrite(localStorage.getItem("overwrite") === 'true'); + const currentlySavedOverwrite = localStorage.getItem("overwrite"); + if (currentlySavedOverwrite) { + setOverwrite(JSON.parse(currentlySavedOverwrite)); + } } }, []); + return (

OVERWRITE PREVIOUS UPSCALE

@@ -21,11 +25,13 @@ const ToggleOverwrite = ({ overwrite, setOverwrite }: ToggleOverwriteProps) => { className="toggle" checked={overwrite} onClick={() => { - setOverwrite((oldValue) => { - if (oldValue === true) { + setOverwrite((oldValue: boolean) => { + if (oldValue) { localStorage.removeItem("overwrite"); + return false; + } else { + return true; } - return !oldValue; }); localStorage.setItem("overwrite", JSON.stringify(!overwrite)); }} diff --git a/renderer/components/upscayl-tab/config/LeftPaneImageSteps.tsx b/renderer/components/upscayl-tab/config/LeftPaneImageSteps.tsx index c9c7b1b..084cedc 100644 --- a/renderer/components/upscayl-tab/config/LeftPaneImageSteps.tsx +++ b/renderer/components/upscayl-tab/config/LeftPaneImageSteps.tsx @@ -130,7 +130,8 @@ function LeftPaneImageSteps({ }; return ( -
+
{/* BATCH OPTION */}
setBatchMode((oldValue) => !oldValue)}>

Batch Upscayl diff --git a/renderer/pages/index.tsx b/renderer/pages/index.tsx index e595b94..ec7822f 100644 --- a/renderer/pages/index.tsx +++ b/renderer/pages/index.tsx @@ -436,9 +436,22 @@ const Home = () => { const allowedFileTypes = ["png", "jpg", "jpeg", "webp"]; + if (typeof window === "undefined") { + return ( + Upscayl icon + ); + } + return (

-
+
+ {window.electron.platform === "mac" && ( +
+ )} {/* HEADER */}
@@ -493,6 +506,10 @@ const Home = () => { onDragEnter={(e) => handleDragEnter(e)} onDragLeave={(e) => handleDragLeave(e)} onPaste={(e) => handlePaste(e)}> + {window.electron.platform === "mac" && ( +
+ )} + {progress.length > 0 && upscaledImagePath.length === 0 && upscaledBatchFolderPath.length === 0 ? ( diff --git a/renderer/renderer.d.ts b/renderer/renderer.d.ts index 0f9f235..ab0bb02 100644 --- a/renderer/renderer.d.ts +++ b/renderer/renderer.d.ts @@ -4,6 +4,7 @@ export interface IElectronAPI { on: (command, func?) => IpcRenderer; send: (command, func?) => IpcRenderer; invoke: (command, func?) => any; + platform: "mac" | "win" | "linux"; } declare global { diff --git a/renderer/styles/globals.css b/renderer/styles/globals.css index da2bc6e..bca20a6 100644 --- a/renderer/styles/globals.css +++ b/renderer/styles/globals.css @@ -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; } +.mac-titlebar { + -webkit-app-region: drag; +} + @keyframes animate-step-in { 0% { opacity: 0;