settings page, reveal in explorer
This commit is contained in:
@@ -229,6 +229,16 @@ pub struct ExportResult {
|
|||||||
pub size_bytes: u64,
|
pub size_bytes: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
fn reveal_in_explorer(path: String) -> Result<(), String> {
|
||||||
|
use std::process::Command;
|
||||||
|
Command::new("explorer.exe")
|
||||||
|
.arg(format!("/select,{path}"))
|
||||||
|
.spawn()
|
||||||
|
.map_err(|e| format!("opening explorer: {e}"))?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn export(state: State<'_, AppState>, request: ExportRequest) -> Result<ExportResult, String> {
|
fn export(state: State<'_, AppState>, request: ExportRequest) -> Result<ExportResult, String> {
|
||||||
let cfg = state.config.lock().expect("config mutex").clone();
|
let cfg = state.config.lock().expect("config mutex").clone();
|
||||||
@@ -310,6 +320,7 @@ pub fn run() {
|
|||||||
start_capture,
|
start_capture,
|
||||||
stop_capture,
|
stop_capture,
|
||||||
export,
|
export,
|
||||||
|
reveal_in_explorer,
|
||||||
])
|
])
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running ByteSize")
|
.expect("error while running ByteSize")
|
||||||
|
|||||||
+5
-2
@@ -5,8 +5,9 @@
|
|||||||
import Bootstrap from "./lib/Bootstrap.svelte"
|
import Bootstrap from "./lib/Bootstrap.svelte"
|
||||||
import FirstRun from "./lib/FirstRun.svelte"
|
import FirstRun from "./lib/FirstRun.svelte"
|
||||||
import Main from "./lib/Main.svelte"
|
import Main from "./lib/Main.svelte"
|
||||||
|
import Settings from "./lib/Settings.svelte"
|
||||||
|
|
||||||
type View = "loading" | "bootstrap" | "first-run" | "main"
|
type View = "loading" | "bootstrap" | "first-run" | "main" | "settings"
|
||||||
|
|
||||||
let view: View = $state("loading")
|
let view: View = $state("loading")
|
||||||
|
|
||||||
@@ -34,6 +35,8 @@
|
|||||||
<Bootstrap onReady={refresh} />
|
<Bootstrap onReady={refresh} />
|
||||||
{:else if view === "first-run"}
|
{:else if view === "first-run"}
|
||||||
<FirstRun onDone={refresh} />
|
<FirstRun onDone={refresh} />
|
||||||
|
{:else if view === "settings"}
|
||||||
|
<Settings onClose={() => view = "main"} />
|
||||||
{:else}
|
{:else}
|
||||||
<Main />
|
<Main onSettings={() => view = "settings"} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
+28
-1
@@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
type Phase = "idle" | "recording" | "editing" | "exporting" | "done"
|
type Phase = "idle" | "recording" | "editing" | "exporting" | "done"
|
||||||
|
|
||||||
|
let { onSettings }: { onSettings: () => void } = $props()
|
||||||
|
|
||||||
let phase: Phase = $state("idle")
|
let phase: Phase = $state("idle")
|
||||||
let config: Config | null = $state(null)
|
let config: Config | null = $state(null)
|
||||||
let clip: RecordedClip | null = $state(null)
|
let clip: RecordedClip | null = $state(null)
|
||||||
@@ -109,6 +111,7 @@
|
|||||||
|
|
||||||
<main>
|
<main>
|
||||||
<header>
|
<header>
|
||||||
|
<div class="title">
|
||||||
<h1>ByteSize</h1>
|
<h1>ByteSize</h1>
|
||||||
<p class="sub">
|
<p class="sub">
|
||||||
{#if phase === "recording"}recording...
|
{#if phase === "recording"}recording...
|
||||||
@@ -117,6 +120,8 @@
|
|||||||
{:else if phase === "done"}exported
|
{:else if phase === "done"}exported
|
||||||
{:else}ready{/if}
|
{:else}ready{/if}
|
||||||
</p>
|
</p>
|
||||||
|
</div>
|
||||||
|
<button class="settings-btn" onclick={onSettings} title="settings">⚙</button>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
{#if phase === "idle"}
|
{#if phase === "idle"}
|
||||||
@@ -209,6 +214,9 @@
|
|||||||
<p>final size: {formatBytes(exportResult.size_bytes)}</p>
|
<p>final size: {formatBytes(exportResult.size_bytes)}</p>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<button class="primary" onclick={startOver}>record another</button>
|
<button class="primary" onclick={startOver}>record another</button>
|
||||||
|
<button onclick={() => exportResult && api.revealInExplorer(exportResult.output_path)}>
|
||||||
|
show in explorer
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -224,6 +232,12 @@
|
|||||||
max-width: 720px;
|
max-width: 720px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: flex-start;
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
}
|
||||||
header h1 {
|
header h1 {
|
||||||
margin: 0 0 0.25rem;
|
margin: 0 0 0.25rem;
|
||||||
font-size: 1.5rem;
|
font-size: 1.5rem;
|
||||||
@@ -232,7 +246,20 @@
|
|||||||
.sub {
|
.sub {
|
||||||
color: #888;
|
color: #888;
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
margin: 0 0 1.5rem;
|
margin: 0;
|
||||||
|
}
|
||||||
|
.settings-btn {
|
||||||
|
font-size: 1.25rem;
|
||||||
|
padding: 0.25rem 0.5rem;
|
||||||
|
background: transparent;
|
||||||
|
border: 1px solid #2a2a2a;
|
||||||
|
color: #888;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.settings-btn:hover {
|
||||||
|
color: #fff;
|
||||||
|
border-color: #888;
|
||||||
}
|
}
|
||||||
section {
|
section {
|
||||||
margin: 1.25rem 0;
|
margin: 1.25rem 0;
|
||||||
|
|||||||
@@ -0,0 +1,230 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { onMount } from "svelte"
|
||||||
|
import { api, type Config } from "./api"
|
||||||
|
|
||||||
|
let { onClose }: { onClose: () => void } = $props()
|
||||||
|
|
||||||
|
let cfg: Config | null = $state(null)
|
||||||
|
let saving: boolean = $state(false)
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
cfg = await api.getConfig()
|
||||||
|
})
|
||||||
|
|
||||||
|
async function save() {
|
||||||
|
if (!cfg) return
|
||||||
|
saving = true
|
||||||
|
try {
|
||||||
|
await api.saveConfig(cfg)
|
||||||
|
onClose()
|
||||||
|
} finally {
|
||||||
|
saving = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<main>
|
||||||
|
<header>
|
||||||
|
<h1>settings</h1>
|
||||||
|
<button class="back" onclick={onClose}>← back</button>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
{#if cfg}
|
||||||
|
<section>
|
||||||
|
<h2>capture</h2>
|
||||||
|
<label>
|
||||||
|
<span>default fps</span>
|
||||||
|
<select bind:value={cfg.capture.default_fps}>
|
||||||
|
<option value={15}>15</option>
|
||||||
|
<option value={24}>24</option>
|
||||||
|
<option value={30}>30</option>
|
||||||
|
<option value={60}>60</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label class="check">
|
||||||
|
<input type="checkbox" bind:checked={cfg.capture.capture_cursor} />
|
||||||
|
<span>capture cursor by default</span>
|
||||||
|
</label>
|
||||||
|
<label class="check">
|
||||||
|
<input type="checkbox" bind:checked={cfg.capture.capture_audio} />
|
||||||
|
<span>capture system audio by default</span>
|
||||||
|
</label>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<h2>export defaults</h2>
|
||||||
|
<label>
|
||||||
|
<span>default format</span>
|
||||||
|
<select bind:value={cfg.export.default_format}>
|
||||||
|
<option value="gif">GIF</option>
|
||||||
|
<option value="webm">WebM</option>
|
||||||
|
<option value="mp4">MP4</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
<span>GIF dithering</span>
|
||||||
|
<select bind:value={cfg.export.gif_dither}>
|
||||||
|
<option value="floyd_steinberg">Floyd-Steinberg</option>
|
||||||
|
<option value="bayer">Bayer</option>
|
||||||
|
<option value="none">none</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
<span>WebM codec</span>
|
||||||
|
<select bind:value={cfg.export.webm_codec}>
|
||||||
|
<option value="vp9">VP9 (default)</option>
|
||||||
|
<option value="av1">AV1 (smaller, slower)</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
<span>MP4 codec</span>
|
||||||
|
<select bind:value={cfg.export.mp4_codec}>
|
||||||
|
<option value="h264">H.264 (default)</option>
|
||||||
|
<option value="h265">H.265 (smaller, less universal)</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<h2>hotkeys</h2>
|
||||||
|
<label>
|
||||||
|
<span>start</span>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="F9"
|
||||||
|
value={cfg.hotkeys.start ?? ""}
|
||||||
|
oninput={(e) => cfg && (cfg.hotkeys.start = (e.currentTarget as HTMLInputElement).value || null)}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
<span>stop</span>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="F9"
|
||||||
|
value={cfg.hotkeys.stop ?? ""}
|
||||||
|
oninput={(e) => cfg && (cfg.hotkeys.stop = (e.currentTarget as HTMLInputElement).value || null)}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
<span>pause</span>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="F10"
|
||||||
|
value={cfg.hotkeys.pause ?? ""}
|
||||||
|
oninput={(e) => cfg && (cfg.hotkeys.pause = (e.currentTarget as HTMLInputElement).value || null)}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<h2>updates</h2>
|
||||||
|
<label class="check">
|
||||||
|
<input type="checkbox" bind:checked={cfg.updates.check_on_launch} />
|
||||||
|
<span>check for updates on launch</span>
|
||||||
|
</label>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<button class="primary" disabled={saving} onclick={save}>
|
||||||
|
{saving ? "saving..." : "save"}
|
||||||
|
</button>
|
||||||
|
<button onclick={onClose}>cancel</button>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
main {
|
||||||
|
padding: 2rem;
|
||||||
|
max-width: 720px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
}
|
||||||
|
header h1 {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
letter-spacing: -0.01em;
|
||||||
|
}
|
||||||
|
section {
|
||||||
|
margin: 1.5rem 0;
|
||||||
|
padding-top: 1rem;
|
||||||
|
border-top: 1px solid #2a2a2a;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
margin: 0 0 0.75rem;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
color: #888;
|
||||||
|
font-weight: normal;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
}
|
||||||
|
label {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 180px 1fr;
|
||||||
|
gap: 1rem;
|
||||||
|
align-items: center;
|
||||||
|
margin: 0.75rem 0;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
label span {
|
||||||
|
color: #aaa;
|
||||||
|
}
|
||||||
|
label.check {
|
||||||
|
grid-template-columns: 20px 1fr;
|
||||||
|
}
|
||||||
|
select, input[type="text"] {
|
||||||
|
font: inherit;
|
||||||
|
padding: 0.4rem 0.6rem;
|
||||||
|
border: 1px solid #444;
|
||||||
|
background: #222;
|
||||||
|
color: inherit;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
input[type="text"]:focus, select:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: #4a8;
|
||||||
|
}
|
||||||
|
.row {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.5rem;
|
||||||
|
margin-top: 2rem;
|
||||||
|
}
|
||||||
|
button {
|
||||||
|
font: inherit;
|
||||||
|
padding: 0.5rem 1rem;
|
||||||
|
border: 1px solid #444;
|
||||||
|
background: transparent;
|
||||||
|
color: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
button:hover:not(:disabled) {
|
||||||
|
border-color: #888;
|
||||||
|
}
|
||||||
|
button.primary {
|
||||||
|
background: #4a8;
|
||||||
|
border-color: #4a8;
|
||||||
|
color: #111;
|
||||||
|
}
|
||||||
|
button.primary:disabled {
|
||||||
|
background: #333;
|
||||||
|
border-color: #333;
|
||||||
|
color: #666;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
button.back {
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
padding: 0.25rem 0.5rem;
|
||||||
|
color: #aaa;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
button.back:hover {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -78,6 +78,7 @@ export const api = {
|
|||||||
startCapture: () => invoke<void>("start_capture"),
|
startCapture: () => invoke<void>("start_capture"),
|
||||||
stopCapture: () => invoke<RecordedClip>("stop_capture"),
|
stopCapture: () => invoke<RecordedClip>("stop_capture"),
|
||||||
export: (request: ExportRequest) => invoke<ExportResult>("export", { request }),
|
export: (request: ExportRequest) => invoke<ExportResult>("export", { request }),
|
||||||
|
revealInExplorer: (path: string) => invoke<void>("reveal_in_explorer", { path }),
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatBytes(n: number): string {
|
export function formatBytes(n: number): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user