2024-10-04 14:45:54 +05:30
|
|
|
import { SelectTheme } from "./select-theme";
|
|
|
|
import { SaveOutputFolderToggle } from "./save-output-folder-toggle";
|
|
|
|
import { InputGpuId } from "./input-gpu-id";
|
|
|
|
import { CustomModelsFolderSelect } from "./select-custom-models-folder";
|
|
|
|
import { LogArea } from "./log-area";
|
|
|
|
import { SelectImageScale } from "./select-image-scale";
|
|
|
|
import { SelectImageFormat } from "./select-image-format";
|
|
|
|
import { DonateButton } from "./donate-button";
|
2023-07-22 16:37:53 +05:30
|
|
|
import React, { useEffect, useState } from "react";
|
|
|
|
import { themeChange } from "theme-change";
|
|
|
|
import { useAtom, useAtomValue } from "jotai";
|
2024-10-04 14:45:54 +05:30
|
|
|
import { customModelsPathAtom, scaleAtom } from "@/atoms/user-settings-atom";
|
2024-10-06 12:45:44 +05:30
|
|
|
import { customModelIdsAtom } from "@/atoms/models-list-atom";
|
2024-10-04 14:45:54 +05:30
|
|
|
import useLogger from "@/components/hooks/use-logger";
|
|
|
|
import { InputCompression } from "./input-compression";
|
|
|
|
import OverwriteToggle from "./overwrite-toggle";
|
|
|
|
import { UpscaylCloudModal } from "@/components/upscayl-cloud-modal";
|
|
|
|
import { ResetSettingsButton } from "./reset-settings-button";
|
|
|
|
import { FEATURE_FLAGS } from "@common/feature-flags";
|
|
|
|
import TurnOffNotificationsToggle from "./turn-off-notifications-toggle";
|
2024-04-19 00:15:12 +05:30
|
|
|
import { cn } from "@/lib/utils";
|
2024-10-04 14:45:54 +05:30
|
|
|
import { InputCustomResolution } from "./input-custom-resolution";
|
|
|
|
import { InputTileSize } from "./input-tile-size";
|
2024-08-31 19:09:05 +05:30
|
|
|
import LanguageSwitcher from "./language-switcher";
|
2024-09-01 17:31:45 +05:30
|
|
|
import { translationAtom } from "@/atoms/translations-atom";
|
2024-10-06 12:45:44 +05:30
|
|
|
import { ImageFormat } from "@/lib/valid-formats";
|
2023-07-22 16:37:53 +05:30
|
|
|
|
|
|
|
interface IProps {
|
|
|
|
batchMode: boolean;
|
2024-10-06 12:45:44 +05:30
|
|
|
saveImageAs: ImageFormat;
|
|
|
|
setSaveImageAs: React.Dispatch<React.SetStateAction<ImageFormat>>;
|
2023-09-13 19:37:45 +05:30
|
|
|
compression: number;
|
|
|
|
setCompression: React.Dispatch<React.SetStateAction<number>>;
|
2023-07-22 16:37:53 +05:30
|
|
|
gpuId: string;
|
|
|
|
setGpuId: React.Dispatch<React.SetStateAction<string>>;
|
|
|
|
logData: string[];
|
2023-09-03 14:46:48 +05:30
|
|
|
show: boolean;
|
|
|
|
setShow: React.Dispatch<React.SetStateAction<boolean>>;
|
|
|
|
setDontShowCloudModal: React.Dispatch<React.SetStateAction<boolean>>;
|
2023-07-22 16:37:53 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
function SettingsTab({
|
|
|
|
batchMode,
|
2023-09-13 19:37:45 +05:30
|
|
|
compression,
|
|
|
|
setCompression,
|
2023-07-22 16:37:53 +05:30
|
|
|
gpuId,
|
|
|
|
setGpuId,
|
|
|
|
saveImageAs,
|
|
|
|
setSaveImageAs,
|
|
|
|
logData,
|
2023-09-03 14:46:48 +05:30
|
|
|
show,
|
|
|
|
setShow,
|
|
|
|
setDontShowCloudModal,
|
2023-07-22 16:37:53 +05:30
|
|
|
}: IProps) {
|
|
|
|
const [isCopied, setIsCopied] = useState(false);
|
|
|
|
|
|
|
|
const [customModelsPath, setCustomModelsPath] = useAtom(customModelsPathAtom);
|
|
|
|
const [scale, setScale] = useAtom(scaleAtom);
|
2024-04-19 00:15:12 +05:30
|
|
|
const [enableScrollbar, setEnableScrollbar] = useState(true);
|
|
|
|
const [timeoutId, setTimeoutId] = useState(null);
|
2024-09-01 17:31:45 +05:30
|
|
|
const t = useAtomValue(translationAtom);
|
2023-07-22 16:37:53 +05:30
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
themeChange(false);
|
2023-09-09 15:43:16 +05:30
|
|
|
}, []);
|
|
|
|
|
2023-07-22 16:37:53 +05:30
|
|
|
// HANDLERS
|
2024-10-06 12:45:44 +05:30
|
|
|
const setExportType = (format: ImageFormat) => {
|
2023-07-22 16:37:53 +05:30
|
|
|
setSaveImageAs(format);
|
|
|
|
localStorage.setItem("saveImageAs", format);
|
|
|
|
};
|
|
|
|
|
2023-09-16 16:04:35 +05:30
|
|
|
const handleCompressionChange = (e) => {
|
2023-09-13 19:37:45 +05:30
|
|
|
setCompression(e.target.value);
|
2023-07-23 14:37:18 +05:30
|
|
|
};
|
|
|
|
|
2023-07-22 16:37:53 +05:30
|
|
|
const handleGpuIdChange = (e) => {
|
|
|
|
setGpuId(e.target.value);
|
|
|
|
localStorage.setItem("gpuId", e.target.value);
|
|
|
|
};
|
|
|
|
|
|
|
|
const copyOnClickHandler = () => {
|
|
|
|
navigator.clipboard.writeText(logData.join("\n"));
|
|
|
|
setIsCopied(true);
|
|
|
|
setTimeout(() => {
|
|
|
|
setIsCopied(false);
|
|
|
|
}, 2000);
|
|
|
|
};
|
|
|
|
|
2024-01-31 16:50:46 +05:30
|
|
|
const upscaylVersion = navigator?.userAgent?.match(
|
2024-02-08 20:27:35 +05:30
|
|
|
/Upscayl\/([\d\.]+\d+)/,
|
2024-01-31 16:50:46 +05:30
|
|
|
)[1];
|
|
|
|
|
2024-04-19 00:15:12 +05:30
|
|
|
function disableScrolling() {
|
|
|
|
if (timeoutId !== null) {
|
|
|
|
clearTimeout(timeoutId);
|
|
|
|
}
|
|
|
|
|
|
|
|
setTimeoutId(
|
|
|
|
setTimeout(function () {
|
|
|
|
setEnableScrollbar(false);
|
|
|
|
}, 1000),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function enableScrolling() {
|
|
|
|
if (timeoutId !== null) {
|
|
|
|
clearTimeout(timeoutId);
|
|
|
|
}
|
|
|
|
|
|
|
|
setEnableScrollbar(true);
|
|
|
|
}
|
|
|
|
|
2023-07-22 16:37:53 +05:30
|
|
|
return (
|
2024-04-19 00:15:12 +05:30
|
|
|
<div
|
|
|
|
className={cn(
|
|
|
|
"animate-step-in animate z-50 flex h-screen flex-col gap-7 overflow-y-auto overflow-x-hidden p-5",
|
|
|
|
enableScrollbar ? "" : "hide-scrollbar",
|
|
|
|
)}
|
|
|
|
onScroll={() => {
|
|
|
|
if (enableScrollbar) disableScrolling();
|
|
|
|
}}
|
|
|
|
onWheel={() => {
|
|
|
|
enableScrolling();
|
|
|
|
}}
|
|
|
|
>
|
2024-01-31 16:50:46 +05:30
|
|
|
<div className="flex flex-col gap-2 text-sm font-medium uppercase">
|
2024-09-03 13:04:58 +05:30
|
|
|
<p>{t("SETTINGS.SUPPORT.TITLE")}</p>
|
2023-07-23 12:02:22 +05:30
|
|
|
<a
|
2024-02-08 20:27:35 +05:30
|
|
|
className="btn btn-primary"
|
2024-04-25 01:58:03 +05:30
|
|
|
href="https://docs.upscayl.org/"
|
2024-02-08 20:27:35 +05:30
|
|
|
target="_blank"
|
|
|
|
>
|
2024-09-03 13:04:58 +05:30
|
|
|
{t("SETTINGS.SUPPORT.DOCS_BUTTON_TITLE")}
|
2023-07-23 12:02:22 +05:30
|
|
|
</a>
|
2024-10-04 14:45:54 +05:30
|
|
|
{FEATURE_FLAGS.APP_STORE_BUILD && (
|
2024-01-15 23:22:16 +05:30
|
|
|
<a
|
2024-02-08 20:27:35 +05:30
|
|
|
className="btn btn-primary"
|
2024-01-31 16:50:46 +05:30
|
|
|
href={`mailto:upscayl@gmail.com?subject=Upscayl%20Issue%3A%20%3CIssue%20name%20here%3E&body=Device%20Name%3A%20%3CYOUR%20DEVICE%20MODEL%3E%0AOperating%20System%3A%20%3CYOUR%20OPERATING%20SYSTEM%20VERSION%3E%0AUpscayl%20Version%3A%20${upscaylVersion}%0A%0AHi%2C%20I'm%20having%20an%20issue%20with%20Upscayl.%20%3CDESCRIBE%20ISSUE%20HERE%3E`}
|
2024-02-08 20:27:35 +05:30
|
|
|
target="_blank"
|
|
|
|
>
|
2024-09-03 13:04:58 +05:30
|
|
|
{t("SETTINGS.SUPPORT.EMAIL_BUTTON_TITLE")}
|
2024-01-15 23:22:16 +05:30
|
|
|
</a>
|
|
|
|
)}
|
2024-10-04 14:45:54 +05:30
|
|
|
{!FEATURE_FLAGS.APP_STORE_BUILD && <DonateButton />}
|
2023-07-23 12:02:22 +05:30
|
|
|
</div>
|
2023-07-22 16:37:53 +05:30
|
|
|
|
2023-07-23 14:37:18 +05:30
|
|
|
<LogArea
|
|
|
|
copyOnClickHandler={copyOnClickHandler}
|
|
|
|
isCopied={isCopied}
|
|
|
|
logData={logData}
|
|
|
|
/>
|
|
|
|
|
2023-07-22 16:37:53 +05:30
|
|
|
{/* THEME SELECTOR */}
|
2024-10-04 14:45:54 +05:30
|
|
|
<SelectTheme />
|
2023-07-22 16:37:53 +05:30
|
|
|
|
2024-08-31 19:09:05 +05:30
|
|
|
<LanguageSwitcher />
|
|
|
|
|
2023-07-23 14:37:18 +05:30
|
|
|
{/* IMAGE FORMAT BUTTONS */}
|
2024-10-04 14:45:54 +05:30
|
|
|
<SelectImageFormat
|
2023-07-23 14:37:18 +05:30
|
|
|
batchMode={batchMode}
|
|
|
|
saveImageAs={saveImageAs}
|
|
|
|
setExportType={setExportType}
|
|
|
|
/>
|
|
|
|
|
2024-04-09 23:51:54 +05:30
|
|
|
{/* IMAGE SCALE */}
|
2024-10-04 14:45:54 +05:30
|
|
|
<SelectImageScale scale={scale} setScale={setScale} />
|
2024-02-08 20:27:35 +05:30
|
|
|
|
2024-10-04 14:45:54 +05:30
|
|
|
<InputCustomResolution />
|
2024-04-20 21:14:42 +05:30
|
|
|
|
2024-10-04 14:45:54 +05:30
|
|
|
<InputCompression
|
2024-04-09 23:51:54 +05:30
|
|
|
compression={compression}
|
|
|
|
handleCompressionChange={handleCompressionChange}
|
|
|
|
/>
|
2023-09-19 00:00:43 +05:30
|
|
|
|
2024-02-14 12:02:52 +05:30
|
|
|
<SaveOutputFolderToggle />
|
2023-07-22 16:37:53 +05:30
|
|
|
|
2024-01-15 14:37:22 +05:30
|
|
|
<OverwriteToggle />
|
2024-01-16 13:03:43 +05:30
|
|
|
<TurnOffNotificationsToggle />
|
2023-08-10 15:47:35 +05:30
|
|
|
|
2023-07-22 16:37:53 +05:30
|
|
|
{/* GPU ID INPUT */}
|
2024-10-04 14:45:54 +05:30
|
|
|
<InputGpuId gpuId={gpuId} handleGpuIdChange={handleGpuIdChange} />
|
2023-07-22 16:37:53 +05:30
|
|
|
|
2024-10-04 14:45:54 +05:30
|
|
|
<InputTileSize />
|
2024-04-25 01:10:48 +05:30
|
|
|
|
2023-07-22 16:37:53 +05:30
|
|
|
{/* CUSTOM MODEL */}
|
|
|
|
<CustomModelsFolderSelect
|
|
|
|
customModelsPath={customModelsPath}
|
|
|
|
setCustomModelsPath={setCustomModelsPath}
|
|
|
|
/>
|
2023-09-03 14:46:48 +05:30
|
|
|
|
|
|
|
{/* RESET SETTINGS */}
|
2024-10-04 14:45:54 +05:30
|
|
|
<ResetSettingsButton />
|
2023-09-03 14:46:48 +05:30
|
|
|
|
2024-10-04 14:45:54 +05:30
|
|
|
{FEATURE_FLAGS.SHOW_UPSCAYL_CLOUD_INFO && (
|
2023-11-02 20:33:21 +05:30
|
|
|
<>
|
|
|
|
<button
|
2024-04-20 21:14:42 +05:30
|
|
|
className="mx-5 mb-5 animate-pulse rounded-btn bg-success p-1 text-sm text-slate-50 shadow-lg shadow-success/40"
|
2023-11-02 20:33:21 +05:30
|
|
|
onClick={() => {
|
|
|
|
setShow(true);
|
2024-02-08 20:27:35 +05:30
|
|
|
}}
|
|
|
|
>
|
2024-09-03 13:04:58 +05:30
|
|
|
{t("INTRO")}
|
2023-11-02 20:33:21 +05:30
|
|
|
</button>
|
2023-09-03 14:46:48 +05:30
|
|
|
|
2023-11-02 20:33:21 +05:30
|
|
|
<UpscaylCloudModal
|
|
|
|
show={show}
|
|
|
|
setShow={setShow}
|
|
|
|
setDontShowCloudModal={setDontShowCloudModal}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
)}
|
2023-07-22 16:37:53 +05:30
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SettingsTab;
|