Edit photos by describing the change, on your own GPU. A free, open-source alternative to Nano Banana and ChatGPT image editing: photos stay on your computer, no daily limit. One installer for Windows, Mac and Linux sets up the best open model (Qwen-Image 2.1). MCP server for AI agents.
TypeScript ai-photo-editorcomfyui-alternativegenerative-fillimage-editingimage-generationinpaintinglinuxlocal-aimacosmcpmcp-servernano-banana-alternativeofflinephoto-editorprivacyqwen-imageqwen-image-2-1stable-diffusion-cppvulkanwindows
feat(ui): Appearance setting: System, Light or Dark
Gabriele Lozupone3461182237db
diff --git a/.gitignore b/.gitignoreindex a1f9f04..fb07e4e 100644--- a/.gitignore+++ b/.gitignore@@ -21,6 +21,8 @@ __pycache__//docs/upscale-plan.md/docs/visibility-plan.md/docs/visibility-progress.md+/docs/vision.md+/docs/test-results//docs/media/demo.gif/docs/launch-posts.md/docs/launch-day-prs.mddiff --git a/index.html b/index.htmlindex e5d4759..82a9359 100644--- a/index.html+++ b/index.html@@ -7,9 +7,10 @@<!-- Painted before any JavaScript runs, so the window never shows an empty white page(the dev server can take seconds to compile; the web view itself needs a moment).React replaces #root's content when the app mounts. Colors match styles.css. -->+ <script src="/theme.js"></script><style>html, body { margin: 0; height: 100%; background: #ffffff; color: #0d0d0d; }- @media (prefers-color-scheme: dark) { html, body { background: #161616; color: #ececec; } }+ html[data-theme="dark"], html[data-theme="dark"] body { background: #161616; color: #ececec; }.boot-splash { height: 100vh; display: grid; place-items: center; }.boot-splash svg { width: 56px; height: 56px; opacity: 0.9; animation: boot-breathe 1.6s ease-in-out infinite; }@keyframes boot-breathe { 50% { opacity: 0.35; } }diff --git a/public/theme.js b/public/theme.jsnew file mode 100644index 0000000..dc8521e--- /dev/null+++ b/public/theme.js@@ -0,0 +1,17 @@+// Sets data-theme="light" | "dark" on <html> before the first paint, so styles.css and the+// splash in index.html never flash the wrong colors. The choice in Settings → General is kept in+// localStorage (src/lib/theme.ts); without one it follows the OS and updates when that changes.+// (A classic script file, not inline, because the CSP only allows scripts from the app itself.)+(function () {+ var dark = window.matchMedia("(prefers-color-scheme: dark)");+ function apply() {+ var t = null;+ try {+ t = localStorage.getItem("qls.theme.v1");+ } catch (e) {}+ document.documentElement.dataset.theme = t === "light" || t === "dark" ? t : dark.matches ? "dark" : "light";+ }+ apply();+ dark.addEventListener("change", apply);+ window.addEventListener("qls-theme", apply);+})();diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.jsonindex 9ebbeb9..f96078c 100644--- a/src-tauri/capabilities/default.json+++ b/src-tauri/capabilities/default.json@@ -10,6 +10,7 @@"core:window:allow-show","core:window:allow-set-fullscreen","core:window:allow-is-fullscreen",+ "core:window:allow-set-theme","dialog:allow-open","dialog:allow-save","dialog:allow-message",diff --git a/src/components/Settings.tsx b/src/components/Settings.tsxindex 22fa9ec..3962958 100644--- a/src/components/Settings.tsx+++ b/src/components/Settings.tsx@@ -5,6 +5,7 @@ import { api } from "../lib/api";import { native } from "../lib/native";import { getState, refreshStatus, setState, startTour, toastError, toastInfo } from "../lib/store";import { formatBytes } from "../lib/logic";+import { setThemeChoice, themeChoice, type ThemeChoice } from "../lib/theme";import { UpscalerControls } from "./Upscalers";import { WHATS_NEW_VERSION } from "./WhatsNew";import type { AppConfig, Check, ModelProfile, SetupReport, TextEncoderPlacement } from "../lib/types";@@ -92,6 +93,7 @@ export function Settings() {const [upscaler, setUpscaler] = useState<Check | null>(null);const [legacy, setLegacy] = useState<{ files: string[]; bytes: number } | null>(null);const [dirty, setDirty] = useState(false);+ const [theme, setTheme] = useState(themeChoice);useEffect(() => {api.config().then(setCfg, toastError);@@ -197,6 +199,19 @@ export function Settings() {{tab === "general" && (<><PathField label="Save images to" value={cfg.outputDir} folder onChange={(v) => set({ outputDir: v })} />+ <div className="field">+ <span>Appearance</span>+ <Seg<ThemeChoice>+ value={theme}+ options={[+ { value: "system", label: "System" },+ { value: "light", label: "Light" },+ { value: "dark", label: "Dark" },+ ]}+ onChange={(v) => (setThemeChoice(v), setTheme(v))}+ />+ <span className="muted">System follows your computer's light or dark mode. Applies at once.</span>+ </div><div className="field-row"><span>Keep inference server running after closing the app</span><Switch on={cfg.keepServerRunning} onChange={(v) => set({ keepServerRunning: v })} />diff --git a/src/lib/native.ts b/src/lib/native.tsindex 8871de1..d0c7dca 100644--- a/src/lib/native.ts+++ b/src/lib/native.ts@@ -35,6 +35,7 @@ export const native = {confirm: (message: string, title: string) => ask(message, { title, kind: "warning" }),isFullscreen: () => getCurrentWindow().isFullscreen(),setFullscreen: (on: boolean) => getCurrentWindow().setFullscreen(on),+ setTheme: async (theme: "light" | "dark" | null) => getCurrentWindow().setTheme(theme),saveAs: (defaultName: string) =>save({defaultPath: defaultName,diff --git a/src/lib/theme.ts b/src/lib/theme.tsnew file mode 100644index 0000000..489da6f--- /dev/null+++ b/src/lib/theme.ts@@ -0,0 +1,33 @@+// Light / dark appearance. public/theme.js resolves the choice into data-theme on <html> before+// the first paint; this module stores the choice and keeps the native title bar in step.+import { native } from "./native";++export type ThemeChoice = "system" | "light" | "dark";++const KEY = "qls.theme.v1";++export function themeChoice(): ThemeChoice {+ try {+ const t = localStorage.getItem(KEY);+ if (t === "light" || t === "dark") return t;+ } catch {+ /* storage unavailable */+ }+ return "system";+}++/** Native window theme (title bar); null follows the OS. Outside Tauri there is no window. */+export function syncWindowTheme(t: ThemeChoice = themeChoice()) {+ native.setTheme(t === "system" ? null : t).catch(() => {});+}++export function setThemeChoice(t: ThemeChoice) {+ try {+ if (t === "system") localStorage.removeItem(KEY);+ else localStorage.setItem(KEY, t);+ } catch {+ /* storage unavailable: applies until restart */+ }+ window.dispatchEvent(new Event("qls-theme"));+ syncWindowTheme(t);+}diff --git a/src/main.tsx b/src/main.tsxindex 693ac2e..5a40e1e 100644--- a/src/main.tsx+++ b/src/main.tsx@@ -2,6 +2,9 @@ import { StrictMode } from "react";import { createRoot } from "react-dom/client";import App from "./App";import "./styles.css";+import { syncWindowTheme } from "./lib/theme";++syncWindowTheme();createRoot(document.getElementById("root")!).render(<StrictMode>diff --git a/src/styles.css b/src/styles.cssindex edac8af..9dded5b 100644--- a/src/styles.css+++ b/src/styles.css@@ -20,24 +20,23 @@color-scheme: light;}-@media (prefers-color-scheme: dark) {- :root {- --bg: #161616;- --surface: #222222;- --surface-2: #2c2c2c;- --surface-3: #383838;- --border: #2c2c2c;- --text: #ececec;- --text-2: #a3a3a3;- --text-3: #6f6f6f;- --invert-bg: #ececec;- --invert-text: #111111;- --scrim: rgba(22, 22, 22, 0.85);- --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px rgba(0, 0, 0, 0.45);- --checker: #1f1f1f;- --sidebar: #1d1d1d;- color-scheme: dark;- }+/* data-theme is set before the first paint by public/theme.js (OS setting or Settings → General). */+:root[data-theme="dark"] {+ --bg: #161616;+ --surface: #222222;+ --surface-2: #2c2c2c;+ --surface-3: #383838;+ --border: #2c2c2c;+ --text: #ececec;+ --text-2: #a3a3a3;+ --text-3: #6f6f6f;+ --invert-bg: #ececec;+ --invert-text: #111111;+ --scrim: rgba(22, 22, 22, 0.85);+ --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px rgba(0, 0, 0, 0.45);+ --checker: #1f1f1f;+ --sidebar: #1d1d1d;+ color-scheme: dark;}* { box-sizing: border-box; }@@ -552,7 +551,7 @@ pre.diag { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font/* prompt tips (lightbulb in the composer) */:root { --good: #1a7f37; --good-bg: rgba(26, 127, 55, 0.1); --bad: #c62828; --bad-bg: rgba(198, 40, 40, 0.09); --okay: #9a6700; --okay-bg: rgba(191, 135, 0, 0.12); }-@media (prefers-color-scheme: dark) { :root { --good: #7ee2a0; --good-bg: rgba(74, 222, 128, 0.12); --bad: #ff8f8f; --bad-bg: rgba(255, 99, 99, 0.12); --okay: #f5d77a; --okay-bg: rgba(245, 197, 24, 0.12); } }+:root[data-theme="dark"] { --good: #7ee2a0; --good-bg: rgba(74, 222, 128, 0.12); --bad: #ff8f8f; --bad-bg: rgba(255, 99, 99, 0.12); --okay: #f5d77a; --okay-bg: rgba(245, 197, 24, 0.12); }button.link { color: inherit; text-decoration: underline; text-underline-offset: 2px; font-size: inherit; padding: 0; }button.link:hover { color: var(--text); }.tips { width: min(860px, 94vw); max-height: 90vh; display: flex; flex-direction: column; gap: 12px; background: var(--bg); border-radius: 22px; box-shadow: var(--shadow); padding: 22px 24px 18px; animation: welcome-in 0.25s ease-out; }