mirror of
https://github.com/upscayl/upscayl.git
synced 2024-11-28 01:10:52 +01:00
Initial Fix
This commit is contained in:
parent
df9ff7de27
commit
1755b26c4a
@ -4,6 +4,7 @@ import {
|
|||||||
childProcesses,
|
childProcesses,
|
||||||
customModelsFolderPath,
|
customModelsFolderPath,
|
||||||
customWidth,
|
customWidth,
|
||||||
|
folderPath,
|
||||||
noImageProcessing,
|
noImageProcessing,
|
||||||
outputFolderPath,
|
outputFolderPath,
|
||||||
saveOutputFolder,
|
saveOutputFolder,
|
||||||
|
@ -7,7 +7,10 @@ export const customModelsPathAtom = atomWithStorage<string | null>(
|
|||||||
);
|
);
|
||||||
export const scaleAtom = atomWithStorage<"2" | "3" | "4">("scale", "4");
|
export const scaleAtom = atomWithStorage<"2" | "3" | "4">("scale", "4");
|
||||||
export const batchModeAtom = atom<boolean>(false);
|
export const batchModeAtom = atom<boolean>(false);
|
||||||
export const outputPathAtom = atom<string | null>("");
|
export const outputPathAtom = atomWithStorage<string | null>(
|
||||||
|
"lastOutputFolderPath",
|
||||||
|
null,
|
||||||
|
);
|
||||||
export const progressAtom = atom<string>("");
|
export const progressAtom = atom<string>("");
|
||||||
|
|
||||||
export const rememberOutputFolderAtom = atomWithStorage<boolean>(
|
export const rememberOutputFolderAtom = atomWithStorage<boolean>(
|
||||||
|
@ -1,20 +1,22 @@
|
|||||||
import React from "react";
|
import {
|
||||||
|
outputPathAtom,
|
||||||
|
rememberOutputFolderAtom,
|
||||||
|
} from "@/atoms/userSettingsAtom";
|
||||||
|
import { useAtom } from "jotai";
|
||||||
|
|
||||||
type SaveOutputFolderToggleProps = {
|
export function SaveOutputFolderToggle() {
|
||||||
rememberOutputFolder: boolean;
|
const [outputPath, setOutputPath] = useAtom(outputPathAtom);
|
||||||
setRememberOutputFolder: (arg: any) => void;
|
const [rememberOutputFolder, setRememberOutputFolder] = useAtom(
|
||||||
};
|
rememberOutputFolderAtom,
|
||||||
|
);
|
||||||
export function SaveOutputFolderToggle({
|
|
||||||
rememberOutputFolder,
|
|
||||||
setRememberOutputFolder,
|
|
||||||
}: SaveOutputFolderToggleProps) {
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
<p className="text-sm font-medium">SAVE OUTPUT FOLDER</p>
|
<p className="text-sm font-medium">SAVE OUTPUT FOLDER</p>
|
||||||
<p className="text-xs text-base-content/80">
|
<p className="text-xs text-base-content/80">
|
||||||
If enabled, the output folder will be remembered between sessions.
|
If enabled, the output folder will be remembered between sessions.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p>{outputPath}</p>
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
className="toggle"
|
className="toggle"
|
||||||
@ -22,13 +24,13 @@ export function SaveOutputFolderToggle({
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
setRememberOutputFolder((oldValue) => {
|
setRememberOutputFolder((oldValue) => {
|
||||||
if (oldValue === true) {
|
if (oldValue === true) {
|
||||||
localStorage.removeItem("lastOutputFolderPath");
|
setOutputPath("");
|
||||||
}
|
}
|
||||||
return !oldValue;
|
return !oldValue;
|
||||||
});
|
});
|
||||||
localStorage.setItem(
|
localStorage.setItem(
|
||||||
"rememberOutputFolder",
|
"rememberOutputFolder",
|
||||||
JSON.stringify(!rememberOutputFolder)
|
JSON.stringify(!rememberOutputFolder),
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
@ -65,7 +65,6 @@ function SettingsTab({
|
|||||||
label: null,
|
label: null,
|
||||||
value: null,
|
value: null,
|
||||||
});
|
});
|
||||||
const [rememberOutputFolder, setRememberOutputFolder] = useState(false);
|
|
||||||
const [isCopied, setIsCopied] = useState(false);
|
const [isCopied, setIsCopied] = useState(false);
|
||||||
|
|
||||||
const [customModelsPath, setCustomModelsPath] = useAtom(customModelsPathAtom);
|
const [customModelsPath, setCustomModelsPath] = useAtom(customModelsPathAtom);
|
||||||
@ -126,22 +125,6 @@ function SettingsTab({
|
|||||||
setGpuId(currentlySavedGpuId);
|
setGpuId(currentlySavedGpuId);
|
||||||
logit("⚙️ Getting gpuId from localStorage: ", currentlySavedGpuId);
|
logit("⚙️ Getting gpuId from localStorage: ", currentlySavedGpuId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!localStorage.getItem("rememberOutputFolder")) {
|
|
||||||
logit("⚙️ Setting rememberOutputFolder to false");
|
|
||||||
localStorage.setItem("rememberOutputFolder", "false");
|
|
||||||
} else {
|
|
||||||
const currentlySavedRememberOutputFolder = localStorage.getItem(
|
|
||||||
"rememberOutputFolder",
|
|
||||||
);
|
|
||||||
logit(
|
|
||||||
"⚙️ Getting rememberOutputFolder from localStorage: ",
|
|
||||||
currentlySavedRememberOutputFolder,
|
|
||||||
);
|
|
||||||
setRememberOutputFolder(
|
|
||||||
currentlySavedRememberOutputFolder === "true" ? true : false,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// HANDLERS
|
// HANDLERS
|
||||||
@ -229,10 +212,7 @@ function SettingsTab({
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<SaveOutputFolderToggle
|
<SaveOutputFolderToggle />
|
||||||
rememberOutputFolder={rememberOutputFolder}
|
|
||||||
setRememberOutputFolder={setRememberOutputFolder}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<OverwriteToggle />
|
<OverwriteToggle />
|
||||||
<TurnOffNotificationsToggle />
|
<TurnOffNotificationsToggle />
|
||||||
|
@ -9,16 +9,17 @@ import {
|
|||||||
noImageProcessingAtom,
|
noImageProcessingAtom,
|
||||||
outputPathAtom,
|
outputPathAtom,
|
||||||
progressAtom,
|
progressAtom,
|
||||||
|
rememberOutputFolderAtom,
|
||||||
scaleAtom,
|
scaleAtom,
|
||||||
} from "../../../atoms/userSettingsAtom";
|
} from "../../../atoms/userSettingsAtom";
|
||||||
import { featureFlags } from "@common/feature-flags";
|
import { featureFlags } from "@common/feature-flags";
|
||||||
import getModelScale from "@common/check-model-scale";
|
import getModelScale from "@common/check-model-scale";
|
||||||
|
import COMMAND from "@common/commands";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
selectImageHandler: () => Promise<void>;
|
selectImageHandler: () => Promise<void>;
|
||||||
selectFolderHandler: () => Promise<void>;
|
selectFolderHandler: () => Promise<void>;
|
||||||
handleModelChange: (e: any) => void;
|
handleModelChange: (e: any) => void;
|
||||||
outputHandler: () => Promise<void>;
|
|
||||||
upscaylHandler: () => Promise<void>;
|
upscaylHandler: () => Promise<void>;
|
||||||
batchMode: boolean;
|
batchMode: boolean;
|
||||||
setBatchMode: React.Dispatch<React.SetStateAction<boolean>>;
|
setBatchMode: React.Dispatch<React.SetStateAction<boolean>>;
|
||||||
@ -39,7 +40,6 @@ function LeftPaneImageSteps({
|
|||||||
selectImageHandler,
|
selectImageHandler,
|
||||||
selectFolderHandler,
|
selectFolderHandler,
|
||||||
handleModelChange,
|
handleModelChange,
|
||||||
outputHandler,
|
|
||||||
upscaylHandler,
|
upscaylHandler,
|
||||||
batchMode,
|
batchMode,
|
||||||
setBatchMode,
|
setBatchMode,
|
||||||
@ -65,12 +65,23 @@ function LeftPaneImageSteps({
|
|||||||
const noImageProcessing = useAtomValue(noImageProcessingAtom);
|
const noImageProcessing = useAtomValue(noImageProcessingAtom);
|
||||||
const [outputPath, setOutputPath] = useAtom(outputPathAtom);
|
const [outputPath, setOutputPath] = useAtom(outputPathAtom);
|
||||||
const [progress, setProgress] = useAtom(progressAtom);
|
const [progress, setProgress] = useAtom(progressAtom);
|
||||||
|
const rememberOutputFolder = useAtomValue(rememberOutputFolderAtom);
|
||||||
|
|
||||||
const [targetWidth, setTargetWidth] = useState<number>(null);
|
const [targetWidth, setTargetWidth] = useState<number>(null);
|
||||||
const [targetHeight, setTargetHeight] = useState<number>(null);
|
const [targetHeight, setTargetHeight] = useState<number>(null);
|
||||||
|
|
||||||
const { logit } = useLog();
|
const { logit } = useLog();
|
||||||
|
|
||||||
|
const outputHandler = async () => {
|
||||||
|
var path = await window.electron.invoke(COMMAND.SELECT_FOLDER);
|
||||||
|
if (path !== null) {
|
||||||
|
logit("🗂 Setting Output Path: ", path);
|
||||||
|
setOutputPath(path);
|
||||||
|
} else {
|
||||||
|
setOutputPath(null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
themeChange(false);
|
themeChange(false);
|
||||||
|
|
||||||
@ -166,7 +177,9 @@ function LeftPaneImageSteps({
|
|||||||
className="toggle"
|
className="toggle"
|
||||||
defaultChecked={batchMode}
|
defaultChecked={batchMode}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setOutputPath("");
|
if (!rememberOutputFolder) {
|
||||||
|
setOutputPath("");
|
||||||
|
}
|
||||||
setProgress("");
|
setProgress("");
|
||||||
setBatchMode((oldValue) => !oldValue);
|
setBatchMode((oldValue) => !oldValue);
|
||||||
}}
|
}}
|
||||||
|
@ -1,107 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
import Select from "react-select";
|
|
||||||
|
|
||||||
interface IProps {
|
|
||||||
progress: string;
|
|
||||||
selectVideoHandler: () => Promise<void>;
|
|
||||||
handleModelChange: (e: any) => void;
|
|
||||||
handleDrop: (e: any) => void;
|
|
||||||
outputHandler: () => Promise<void>;
|
|
||||||
upscaylHandler: () => Promise<void>;
|
|
||||||
videoPath: string;
|
|
||||||
outputPath: string;
|
|
||||||
model: string;
|
|
||||||
isVideo: boolean;
|
|
||||||
setIsVideo: (arg: boolean) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
function LeftPaneVideoSteps({
|
|
||||||
progress,
|
|
||||||
selectVideoHandler,
|
|
||||||
handleModelChange,
|
|
||||||
handleDrop,
|
|
||||||
outputHandler,
|
|
||||||
upscaylHandler,
|
|
||||||
videoPath,
|
|
||||||
outputPath,
|
|
||||||
model,
|
|
||||||
isVideo,
|
|
||||||
setIsVideo,
|
|
||||||
}: IProps) {
|
|
||||||
const customStyles = {
|
|
||||||
option: (provided, state) => ({
|
|
||||||
...provided,
|
|
||||||
borderBottom: "1px dotted pink",
|
|
||||||
color: state.isSelected ? "red" : "blue",
|
|
||||||
padding: 20,
|
|
||||||
}),
|
|
||||||
control: () => ({
|
|
||||||
// none of react-select's styles are passed to <Control />
|
|
||||||
width: 200,
|
|
||||||
}),
|
|
||||||
singleValue: (provided, state) => {
|
|
||||||
const opacity = state.isDisabled ? 0.5 : 1;
|
|
||||||
const transition = "opacity 300ms";
|
|
||||||
|
|
||||||
return { ...provided, opacity, transition };
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const modelOptions = [
|
|
||||||
{ label: "2x Digital Art", value: "realesr-animevideov3-x2" },
|
|
||||||
{ label: "3x Digital Art", value: "realesr-animevideov3-x3" },
|
|
||||||
{ label: "4x Digital Art", value: "realesr-animevideov3-x4" },
|
|
||||||
];
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="animate-step-in animate flex h-screen flex-col gap-7 overflow-y-auto p-5 overflow-x-hidden">
|
|
||||||
{/* STEP 1 */}
|
|
||||||
<div data-tip={videoPath}>
|
|
||||||
<p className="step-heading">Step 1</p>
|
|
||||||
<button className="btn-primary btn" onClick={selectVideoHandler}>
|
|
||||||
Select Video
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* STEP 2 */}
|
|
||||||
<div className="animate-step-in">
|
|
||||||
<p className="step-heading">Step 2</p>
|
|
||||||
<p className="mb-2 text-sm">Select Scaling</p>
|
|
||||||
|
|
||||||
<Select
|
|
||||||
options={modelOptions}
|
|
||||||
components={{
|
|
||||||
IndicatorSeparator: () => null,
|
|
||||||
DropdownIndicator: () => null,
|
|
||||||
}}
|
|
||||||
onChange={handleModelChange}
|
|
||||||
className="react-select-container"
|
|
||||||
classNamePrefix="react-select"
|
|
||||||
defaultValue={modelOptions[0]}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* STEP 3 */}
|
|
||||||
<div className="animate-step-in" data-tip={outputPath}>
|
|
||||||
<p className="step-heading">Step 3</p>
|
|
||||||
<p className="mb-2 text-sm">Defaults to Video's path</p>
|
|
||||||
<button className="btn-primary btn" onClick={outputHandler}>
|
|
||||||
Set Output Folder
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* STEP 4 */}
|
|
||||||
<div className="animate-step-in">
|
|
||||||
<p className="step-heading">Step 4</p>
|
|
||||||
<button
|
|
||||||
className="btn-accent btn"
|
|
||||||
onClick={upscaylHandler}
|
|
||||||
disabled={progress.length > 0}>
|
|
||||||
{progress.length > 0 ? "Upscayling⏳" : "Upscayl"}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default LeftPaneVideoSteps;
|
|
@ -24,6 +24,7 @@ import {
|
|||||||
progressAtom,
|
progressAtom,
|
||||||
scaleAtom,
|
scaleAtom,
|
||||||
viewTypeAtom,
|
viewTypeAtom,
|
||||||
|
rememberOutputFolderAtom,
|
||||||
} from "../atoms/userSettingsAtom";
|
} from "../atoms/userSettingsAtom";
|
||||||
import useLog from "../components/hooks/useLog";
|
import useLog from "../components/hooks/useLog";
|
||||||
import { UpscaylCloudModal } from "../components/UpscaylCloudModal";
|
import { UpscaylCloudModal } from "../components/UpscaylCloudModal";
|
||||||
@ -81,6 +82,7 @@ const Home = () => {
|
|||||||
const [showNewsModal, setShowNewsModal] = useAtom(showNewsModalAtom);
|
const [showNewsModal, setShowNewsModal] = useAtom(showNewsModalAtom);
|
||||||
const viewType = useAtomValue(viewTypeAtom);
|
const viewType = useAtomValue(viewTypeAtom);
|
||||||
const lensSize = useAtomValue(lensSizeAtom);
|
const lensSize = useAtomValue(lensSizeAtom);
|
||||||
|
const rememberOutputFolder = useAtomValue(rememberOutputFolderAtom);
|
||||||
|
|
||||||
const { logit } = useLog();
|
const { logit } = useLog();
|
||||||
|
|
||||||
@ -275,19 +277,6 @@ const Home = () => {
|
|||||||
}
|
}
|
||||||
}, [news]);
|
}, [news]);
|
||||||
|
|
||||||
// CONFIGURE SAVED OUTPUT PATH
|
|
||||||
useEffect(() => {
|
|
||||||
const rememberOutputFolder = localStorage.getItem("rememberOutputFolder");
|
|
||||||
const lastOutputFolderPath = localStorage.getItem("lastOutputFolderPath");
|
|
||||||
if (rememberOutputFolder === "true") {
|
|
||||||
logit("🧠 Recalling Output Folder: ", lastOutputFolderPath);
|
|
||||||
setOutputPath(lastOutputFolderPath);
|
|
||||||
} else {
|
|
||||||
setOutputPath("");
|
|
||||||
localStorage.removeItem("lastOutputFolderPath");
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
// LOADING STATE
|
// LOADING STATE
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
@ -340,7 +329,9 @@ const Home = () => {
|
|||||||
var dirname = path.match(/(.*)[\/\\]/)[1] || "";
|
var dirname = path.match(/(.*)[\/\\]/)[1] || "";
|
||||||
logit("📁 Selected Image Directory: ", dirname);
|
logit("📁 Selected Image Directory: ", dirname);
|
||||||
if (!featureFlags.APP_STORE_BUILD) {
|
if (!featureFlags.APP_STORE_BUILD) {
|
||||||
setOutputPath(dirname);
|
if (!rememberOutputFolder) {
|
||||||
|
setOutputPath(dirname);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
validateImagePath(path);
|
validateImagePath(path);
|
||||||
};
|
};
|
||||||
@ -351,11 +342,15 @@ const Home = () => {
|
|||||||
if (path !== null) {
|
if (path !== null) {
|
||||||
logit("🖼 Selected Folder Path: ", path);
|
logit("🖼 Selected Folder Path: ", path);
|
||||||
setBatchFolderPath(path);
|
setBatchFolderPath(path);
|
||||||
setOutputPath(path);
|
if (!rememberOutputFolder) {
|
||||||
|
setOutputPath(path);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
logit("🚫 Folder selection cancelled");
|
logit("🚫 Folder selection cancelled");
|
||||||
setBatchFolderPath("");
|
setBatchFolderPath("");
|
||||||
setOutputPath("");
|
if (!rememberOutputFolder) {
|
||||||
|
setOutputPath("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -412,7 +407,11 @@ const Home = () => {
|
|||||||
setImagePath(filePath);
|
setImagePath(filePath);
|
||||||
var dirname = filePath.match(/(.*)[\/\\]/)[1] || "";
|
var dirname = filePath.match(/(.*)[\/\\]/)[1] || "";
|
||||||
logit("🗂 Setting output path: ", dirname);
|
logit("🗂 Setting output path: ", dirname);
|
||||||
if (!featureFlags.APP_STORE_BUILD) setOutputPath(dirname);
|
if (!featureFlags.APP_STORE_BUILD) {
|
||||||
|
if (!rememberOutputFolder) {
|
||||||
|
setOutputPath(dirname);
|
||||||
|
}
|
||||||
|
}
|
||||||
validateImagePath(filePath);
|
validateImagePath(filePath);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -433,22 +432,9 @@ const Home = () => {
|
|||||||
setImagePath(filePath);
|
setImagePath(filePath);
|
||||||
var dirname = filePath.match(/(.*)[\/\\]/)[1] || "";
|
var dirname = filePath.match(/(.*)[\/\\]/)[1] || "";
|
||||||
logit("🗂 Setting output path: ", dirname);
|
logit("🗂 Setting output path: ", dirname);
|
||||||
setOutputPath(dirname);
|
if (!rememberOutputFolder) {
|
||||||
}
|
setOutputPath(dirname);
|
||||||
};
|
|
||||||
|
|
||||||
const outputHandler = async () => {
|
|
||||||
var path = await window.electron.invoke(COMMAND.SELECT_FOLDER);
|
|
||||||
if (path !== null) {
|
|
||||||
logit("🗂 Setting Output Path: ", path);
|
|
||||||
setOutputPath(path);
|
|
||||||
const rememberOutputFolder = localStorage.getItem("rememberOutputFolder");
|
|
||||||
if (rememberOutputFolder) {
|
|
||||||
logit("🧠 Remembering Output Folder: ", path);
|
|
||||||
localStorage.setItem("lastOutputFolderPath", path);
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
setOutputPath("");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -564,7 +550,6 @@ const Home = () => {
|
|||||||
selectImageHandler={selectImageHandler}
|
selectImageHandler={selectImageHandler}
|
||||||
selectFolderHandler={selectFolderHandler}
|
selectFolderHandler={selectFolderHandler}
|
||||||
handleModelChange={handleModelChange}
|
handleModelChange={handleModelChange}
|
||||||
outputHandler={outputHandler}
|
|
||||||
upscaylHandler={upscaylHandler}
|
upscaylHandler={upscaylHandler}
|
||||||
batchMode={batchMode}
|
batchMode={batchMode}
|
||||||
setBatchMode={setBatchMode}
|
setBatchMode={setBatchMode}
|
||||||
@ -674,7 +659,7 @@ const Home = () => {
|
|||||||
)}
|
)}
|
||||||
{/* BATCH UPSCALE DONE INFO */}
|
{/* BATCH UPSCALE DONE INFO */}
|
||||||
{batchMode && upscaledBatchFolderPath.length > 0 && (
|
{batchMode && upscaledBatchFolderPath.length > 0 && (
|
||||||
<>
|
<div className="z-50 flex flex-col items-center">
|
||||||
<p className="select-none py-4 font-bold text-base-content">
|
<p className="select-none py-4 font-bold text-base-content">
|
||||||
All done!
|
All done!
|
||||||
</p>
|
</p>
|
||||||
@ -684,7 +669,7 @@ const Home = () => {
|
|||||||
>
|
>
|
||||||
Open Upscayled Folder
|
Open Upscayled Folder
|
||||||
</button>
|
</button>
|
||||||
</>
|
</div>
|
||||||
)}
|
)}
|
||||||
<ImageOptions
|
<ImageOptions
|
||||||
zoomAmount={zoomAmount}
|
zoomAmount={zoomAmount}
|
||||||
|
Loading…
Reference in New Issue
Block a user