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"; import React, { useEffect, useState } from "react"; import { themeChange } from "theme-change"; import { useAtom, useAtomValue } from "jotai"; import { customModelsPathAtom, scaleAtom } from "@/atoms/user-settings-atom"; import { modelsListAtom } from "@/atoms/models-list-atom"; 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"; import { cn } from "@/lib/utils"; import { InputCustomResolution } from "./input-custom-resolution"; import { InputTileSize } from "./input-tile-size"; import LanguageSwitcher from "./language-switcher"; import { translationAtom } from "@/atoms/translations-atom"; interface IProps { batchMode: boolean; setModel: React.Dispatch>; saveImageAs: string; setSaveImageAs: React.Dispatch>; compression: number; setCompression: React.Dispatch>; gpuId: string; setGpuId: React.Dispatch>; logData: string[]; show: boolean; setShow: React.Dispatch>; setDontShowCloudModal: React.Dispatch>; } function SettingsTab({ batchMode, setModel, compression, setCompression, gpuId, setGpuId, saveImageAs, setSaveImageAs, logData, show, setShow, setDontShowCloudModal, }: IProps) { const [isCopied, setIsCopied] = useState(false); const [customModelsPath, setCustomModelsPath] = useAtom(customModelsPathAtom); const modelOptions = useAtomValue(modelsListAtom); const [scale, setScale] = useAtom(scaleAtom); const [enableScrollbar, setEnableScrollbar] = useState(true); const [timeoutId, setTimeoutId] = useState(null); const t = useAtomValue(translationAtom); const logit = useLogger(); useEffect(() => { themeChange(false); if (!localStorage.getItem("saveImageAs")) { logit("⚙️ Setting saveImageAs to png"); localStorage.setItem("saveImageAs", "png"); } else { const currentlySavedImageFormat = localStorage.getItem("saveImageAs"); logit( "⚙️ Getting saveImageAs from localStorage: ", currentlySavedImageFormat, ); setSaveImageAs(currentlySavedImageFormat); } if (!localStorage.getItem("model")) { setModel(modelOptions[0].value); localStorage.setItem("model", JSON.stringify(modelOptions[0])); logit("🔀 Setting model to", modelOptions[0].value); } else { let currentlySavedModel = JSON.parse( localStorage.getItem("model"), ) as (typeof modelOptions)[0]; if ( modelOptions.find( (model) => model.value === currentlySavedModel.value, ) === undefined ) { localStorage.setItem("model", JSON.stringify(modelOptions[0])); logit("🔀 Setting model to", modelOptions[0].value); currentlySavedModel = modelOptions[0]; } setModel(currentlySavedModel.value); logit( "⚙️ Getting model from localStorage: ", JSON.stringify(currentlySavedModel), ); } if (!localStorage.getItem("gpuId")) { localStorage.setItem("gpuId", ""); logit("⚙️ Setting gpuId to empty string"); } else { const currentlySavedGpuId = localStorage.getItem("gpuId"); setGpuId(currentlySavedGpuId); logit("⚙️ Getting gpuId from localStorage: ", currentlySavedGpuId); } }, []); // HANDLERS const setExportType = (format: string) => { setSaveImageAs(format); localStorage.setItem("saveImageAs", format); }; const handleCompressionChange = (e) => { setCompression(e.target.value); }; 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); }; const upscaylVersion = navigator?.userAgent?.match( /Upscayl\/([\d\.]+\d+)/, )[1]; function disableScrolling() { if (timeoutId !== null) { clearTimeout(timeoutId); } setTimeoutId( setTimeout(function () { setEnableScrollbar(false); }, 1000), ); } function enableScrolling() { if (timeoutId !== null) { clearTimeout(timeoutId); } setEnableScrollbar(true); } return (
{ if (enableScrollbar) disableScrolling(); }} onWheel={() => { enableScrolling(); }} >

{t("SETTINGS.SUPPORT.TITLE")}

{t("SETTINGS.SUPPORT.DOCS_BUTTON_TITLE")} {FEATURE_FLAGS.APP_STORE_BUILD && ( {t("SETTINGS.SUPPORT.EMAIL_BUTTON_TITLE")} )} {!FEATURE_FLAGS.APP_STORE_BUILD && }
{/* THEME SELECTOR */} {/* IMAGE FORMAT BUTTONS */} {/* IMAGE SCALE */} {/* GPU ID INPUT */} {/* CUSTOM MODEL */} {/* RESET SETTINGS */} {FEATURE_FLAGS.SHOW_UPSCAYL_CLOUD_INFO && ( <> )}
); } export default SettingsTab;