Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Add prettyName to screenshot editor

Richie McIlroy74816b697c72
diff --git a/apps/desktop/src-tauri/src/screenshot_editor.rs b/apps/desktop/src-tauri/src/screenshot_editor.rs
index 591b17a34..ad23e0ebd 100644
--- a/apps/desktop/src-tauri/src/screenshot_editor.rs
+++ b/apps/desktop/src-tauri/src/screenshot_editor.rs
@@ -30,6 +30,7 @@ pub struct ScreenshotEditorInstance {
pub ws_shutdown_token: CancellationToken,
pub config_tx: watch::Sender<ProjectConfiguration>,
pub path: PathBuf,
+ pub pretty_name: String,
}
impl ScreenshotEditorInstance {
@@ -264,6 +265,7 @@ impl ScreenshotEditorInstances {
ws_shutdown_token,
config_tx,
path: path.clone(),
+ pretty_name: recording_meta.pretty_name.clone(),
});
// Spawn render loop
@@ -375,6 +377,7 @@ pub struct SerializedScreenshotEditorInstance {
pub frames_socket_url: String,
pub path: PathBuf,
pub config: Option<ProjectConfiguration>,
+ pub pretty_name: String,
}
#[tauri::command]
@@ -404,6 +407,7 @@ pub async fn create_screenshot_editor_instance(
frames_socket_url: format!("ws://localhost:{}", instance.ws_port),
path: instance.path.clone(),
config: Some(config),
+ pretty_name: instance.pretty_name.clone(),
})
}
diff --git a/apps/desktop/src/routes/screenshot-editor/context.tsx b/apps/desktop/src/routes/screenshot-editor/context.tsx
index 67220a16b..876321889 100644
--- a/apps/desktop/src/routes/screenshot-editor/context.tsx
+++ b/apps/desktop/src/routes/screenshot-editor/context.tsx
@@ -118,6 +118,10 @@ function createScreenshotEditorContext() {
null,
);
+ const [activePopover, setActivePopover] = createSignal<
+ "background" | "padding" | "rounding" | "shadow" | "border" | null
+ >(null);
+
const [dialog, setDialog] = createSignal<DialogState>({
open: false,
});
@@ -309,6 +313,9 @@ function createScreenshotEditorContext() {
get path() {
return editorInstance()?.path ?? "";
},
+ get prettyName() {
+ return editorInstance()?.prettyName ?? "Screenshot";
+ },
project,
setProject,
annotations,
@@ -321,6 +328,8 @@ function createScreenshotEditorContext() {
setLayersPanelOpen,
focusAnnotationId,
setFocusAnnotationId,
+ activePopover,
+ setActivePopover,
projectHistory,
dialog,
setDialog,
diff --git a/apps/desktop/src/routes/screenshot-editor/useScreenshotExport.ts b/apps/desktop/src/routes/screenshot-editor/useScreenshotExport.ts
index 0e52522f4..9abc271d2 100644
--- a/apps/desktop/src/routes/screenshot-editor/useScreenshotExport.ts
+++ b/apps/desktop/src/routes/screenshot-editor/useScreenshotExport.ts
@@ -8,8 +8,15 @@ import { getArrowHeadPoints } from "./arrow";
import { type Annotation, useScreenshotEditorContext } from "./context";
export function useScreenshotExport() {
- const { path, latestFrame, annotations, dialog, setDialog, project } =
- useScreenshotEditorContext();
+ const {
+ path,
+ prettyName,
+ latestFrame,
+ annotations,
+ dialog,
+ setDialog,
+ project,
+ } = useScreenshotEditorContext();
const [isExporting, setIsExporting] = createSignal(false);
const drawAnnotations = (
@@ -284,7 +291,7 @@ export function useScreenshotExport() {
if (destination === "file") {
const savePath = await save({
filters: [{ name: "PNG Image", extensions: ["png"] }],
- defaultPath: "screenshot.png",
+ defaultPath: `${prettyName}.png`,
});
if (savePath) {
await writeFile(savePath, uint8Array);
diff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.ts
index b7b805ec9..94d9c7756 100644
--- a/apps/desktop/src/utils/tauri.ts
+++ b/apps/desktop/src/utils/tauri.ts
@@ -472,7 +472,7 @@ export type SceneSegment = { start: number; end: number; mode?: SceneMode }
export type ScreenCaptureTarget = { variant: "window"; id: WindowId } | { variant: "display"; id: DisplayId } | { variant: "area"; screen: DisplayId; bounds: LogicalBounds }
export type SegmentRecordings = { display: Video; camera: Video | null; mic: Audio | null; system_audio: Audio | null }
export type SerializedEditorInstance = { framesSocketUrl: string; recordingDuration: number; savedProjectConfig: ProjectConfiguration; recordings: ProjectRecordingsMeta; path: string }
-export type SerializedScreenshotEditorInstance = { framesSocketUrl: string; path: string; config: ProjectConfiguration | null }
+export type SerializedScreenshotEditorInstance = { framesSocketUrl: string; path: string; config: ProjectConfiguration | null; prettyName: string }
export type SetCaptureAreaPending = boolean
export type ShadowConfiguration = { size: number; opacity: number; blur: number }
export type SharingMeta = { id: string; link: string }