Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
add wallpaper
neo7735f92e91de174
diff --git a/apps/desktop/src/routes/editor/ConfigSidebar.tsx b/apps/desktop/src/routes/editor/ConfigSidebar.tsxindex 30b467d8e..feac399b2 100644--- a/apps/desktop/src/routes/editor/ConfigSidebar.tsx+++ b/apps/desktop/src/routes/editor/ConfigSidebar.tsx@@ -9,9 +9,9 @@ import { Dynamic } from "solid-js/web";import { createWritableMemo } from "@solid-primitives/memo";import { createEventListenerMap } from "@solid-primitives/event-listener";import { produce } from "solid-js/store";-import { writeFile, BaseDirectory } from '@tauri-apps/plugin-fs';-import { appDataDir } from '@tauri-apps/api/path';-import { convertFileSrc } from '@tauri-apps/api/core';+import { writeFile, BaseDirectory } from "@tauri-apps/plugin-fs";+import { appDataDir } from "@tauri-apps/api/path";+import { convertFileSrc } from "@tauri-apps/api/core";import type {BackgroundSource,@@ -34,14 +34,14 @@ import {} from "./projectConfig";const BACKGROUND_SOURCES = {- // wallpaper: "Wallpaper",+ wallpaper: "Wallpaper",image: "Image",color: "Color",gradient: "Gradient",} satisfies Record<BackgroundSource["type"], string>;const BACKGROUND_SOURCES_LIST = [- // "wallpaper",+ "wallpaper","image","color","gradient",@@ -53,6 +53,28 @@ const CURSOR_ANIMATION_STYLES: Record<CursorAnimationStyle, string> = {fast: "Fast & Responsive",} as const;+const UNSPLASH_ACCESS_KEY = "YOUR_UNSPLASH_ACCESS_KEY"; // You'll need to get this from Unsplash+const WALLPAPERS_PER_PAGE = 14;++const WALLPAPERS = [+ {+ id: "wall1",+ url: "https://images.unsplash.com/photo-1542332213-9b5a5a3fad35?w=1920",+ },+ {+ id: "wall2",+ url: "https://images.unsplash.com/photo-1542810104-c5f07c7357ff?w=1920",+ },+ {+ id: "wall3",+ url: "https://images.unsplash.com/photo-1445368794737-0cf251429ca0?w=1920",+ },+ {+ id: "wall4",+ url: "https://images.unsplash.com/photo-1737365506116-ef7eba797492?w=1920",+ },+];+export function ConfigSidebar() {const {selectedTab,@@ -67,10 +89,10 @@ export function ConfigSidebar() {const backgrounds: {[K in BackgroundSource["type"]]: Extract<BackgroundSource, { type: K }>;} = {- // wallpaper: {- // type: "wallpaper",- // id: 0,- // },+ wallpaper: {+ type: "wallpaper",+ path: null,+ },image: {type: "image",path: null,@@ -156,6 +178,12 @@ export function ConfigSidebar() {});return;}+ case "wallpaper": {+ setProject("background", "source", {+ ...backgrounds.wallpaper,+ });+ return;+ }}}}>@@ -205,33 +233,54 @@ export function ConfigSidebar() {</KTabs.Indicator></KTabs.List><KTabs.Content value="wallpaper">- {/* <KRadioGroup+ <KRadioGroupvalue={- project.background.source.type === "wallpaper"- ? project.background.source.id.toString()+ project.background.source.type === "image"+ ? project.background.source.path ?? undefined: undefined}- onChange={(v) => {- backgrounds.wallpaper = {- type: "wallpaper",- id: Number(v),- };- setProject("background", "source", backgrounds.wallpaper);+ onChange={async (photoUrl) => {+ try {+ const response = await fetch(photoUrl);+ const blob = await response.blob();+ const fileName = `wallpaper-${Date.now()}.jpg`;+ const arrayBuffer = await blob.arrayBuffer();+ const uint8Array = new Uint8Array(arrayBuffer);++ const fullPath = `${await appDataDir()}/${fileName}`;++ await writeFile(fileName, uint8Array, {+ baseDir: BaseDirectory.AppData,+ });++ setProject("background", "source", {+ type: "image",+ path: fullPath,+ });+ } catch (err) {+ console.error("Failed to save wallpaper:", err);+ }}}- class="grid grid-cols-7 grid-rows-2 gap-2 h-[6.8rem]"+ class="grid grid-cols-2 gap-2 h-auto">- <For each={[...Array(14).keys()]}>- {(_, i) => (+ <For each={WALLPAPERS}>+ {(photo) => (<KRadioGroup.Item- value={i().toString()}- class="col-span-1 row-span-1"+ value={photo.url}+ class="col-span-1 aspect-video relative group"><KRadioGroup.ItemInput class="peer" />- <KRadioGroup.ItemControl class="cursor-pointer bg-gray-100 rounded-lg w-full h-full border border-gray-200 ui-checked:border-blue-300 peer-focus-visible:border-2 peer-focus-visible:border-blue-300" />+ <KRadioGroup.ItemControl class="cursor-pointer w-full h-full overflow-hidden rounded-lg border border-gray-200 ui-checked:border-blue-300 peer-focus-visible:border-2 peer-focus-visible:border-blue-300">+ <img+ src={photo.url}+ alt="Wallpaper option"+ class="w-full h-full object-cover"+ />+ </KRadioGroup.ItemControl></KRadioGroup.Item>)}</For>- </KRadioGroup> */}+ </KRadioGroup></KTabs.Content><KTabs.Content value="image"><Show@@ -260,7 +309,12 @@ export function ConfigSidebar() {<div class="absolute top-2 right-2"><buttontype="button"- onClick={() => setProject("background", "source", { type: "color", value: [255, 255, 255] })}+ onClick={() =>+ setProject("background", "source", {+ type: "color",+ value: [255, 255, 255],+ })+ }class="bg-black/50 text-white p-2 rounded-full hover:bg-black/70 transition-colors"><IconCapCircleX class="w-4 h-4" />@@ -277,24 +331,24 @@ export function ConfigSidebar() {onChange={async (e) => {const file = e.currentTarget.files?.[0];if (!file) return;-+try {const fileName = `bg-${Date.now()}-${file.name}`;const arrayBuffer = await file.arrayBuffer();const uint8Array = new Uint8Array(arrayBuffer);-+const fullPath = `${await appDataDir()}/${fileName}`;-+await writeFile(fileName, uint8Array, {- baseDir: BaseDirectory.AppData+ baseDir: BaseDirectory.AppData,});-+setProject("background", "source", {type: "image",path: fullPath,});} catch (err) {- console.error('Failed to save image:', err);+ console.error("Failed to save image:", err);}}}/>diff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.tsindex 7317068b4..565ea9d9d 100644--- a/apps/desktop/src/utils/tauri.ts+++ b/apps/desktop/src/utils/tauri.ts@@ -227,7 +227,7 @@ export type AudioMeta = { path: string }export type AuthStore = { token: string; user_id: string | null; expires: number; plan: Plan | null }export type AuthenticationInvalid = nullexport type BackgroundConfiguration = { source: BackgroundSource; blur: number; padding: number; rounding: number; inset: number; crop: Crop | null }-export type BackgroundSource = { type: "image"; path: string | null } | { type: "color"; value: [number, number, number] } | { type: "gradient"; from: [number, number, number]; to: [number, number, number]; angle?: number }+export type BackgroundSource = { type: "wallpaper"; path: string | null } | { type: "image"; path: string | null } | { type: "color"; value: [number, number, number] } | { type: "gradient"; from: [number, number, number]; to: [number, number, number]; angle?: number }export type Bounds = { x: number; y: number; width: number; height: number }export type Camera = { hide: boolean; mirror: boolean; position: CameraPosition; size: number; zoom_size: number | null; rounding: number; shadow: number }export type CameraMeta = { path: string; fps?: number }diff --git a/crates/project/src/configuration.rs b/crates/project/src/configuration.rsindex acd404278..6b9ac6974 100644--- a/crates/project/src/configuration.rs+++ b/crates/project/src/configuration.rs@@ -22,9 +22,9 @@ pub type Color = [u16; 3];#[derive(Type, Serialize, Deserialize, Clone, Debug)]#[serde(rename_all = "camelCase", tag = "type")]pub enum BackgroundSource {- // Wallpaper {- // id: u16,- // },+ Wallpaper {+ path: Option<String>,+ },Image {path: Option<String>,},diff --git a/crates/rendering/src/lib.rs b/crates/rendering/src/lib.rsindex 8ea8f9add..5ca83398f 100644--- a/crates/rendering/src/lib.rs+++ b/crates/rendering/src/lib.rs@@ -88,6 +88,9 @@ impl From<BackgroundSource> for Background {BackgroundSource::Image { path } => Background::Image {path: path.clone().unwrap(),},+ BackgroundSource::Wallpaper { path } => Background::Image {+ path: path.clone().unwrap(),+ },}}}