diff --git a/README.md b/README.md index 1a032d7..7d3fd68 100644 --- a/README.md +++ b/README.md @@ -83,8 +83,9 @@ pixelpass --gui ``` Host: pick quality / max-viewers / options, click **Start hosting**, and the -share code appears with a copy button alongside a live viewer count. View: -paste a code, pick mpv or VLC, click **Connect** and the player launches. +share code appears with a copy button. Connected viewers are listed with a +**Kick** button each, and a desktop notification fires as they join or leave. +View: paste a code, pick mpv or VLC, click **Connect** and the player launches. The window is a thin driver — it runs the same headless `pixelpass` as a child process and reads its event stream, so the GUI is purely additive and diff --git a/src/common/config.rs b/src/common/config.rs index 6dfec06..c3bd55c 100644 --- a/src/common/config.rs +++ b/src/common/config.rs @@ -37,18 +37,15 @@ pub struct BandwidthEntry { #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "lowercase")] +#[derive(Default)] pub enum BandwidthStatus { + #[default] Unmeasured, Measured, Skipped, Failed, } -impl Default for BandwidthStatus { - fn default() -> Self { - Self::Unmeasured - } -} fn default_status() -> BandwidthStatus { BandwidthStatus::Unmeasured diff --git a/src/gui/mod.rs b/src/gui/mod.rs index 00d748e..4d24177 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -165,6 +165,7 @@ impl PlayerSel { /// Host-screen state: the config form fields plus, once started, the running /// child and the latest values parsed from its event stream. +#[derive(Default)] struct HostState { // form quality: QualitySel, @@ -190,27 +191,6 @@ struct HostState { viewers: Vec, } -impl Default for HostState { - fn default() -> Self { - Self { - quality: QualitySel::default(), - max_viewers: 0, - no_hwencode: false, - window: false, - proc: None, - ticket: None, - info: None, - active: 0, - max: 0, - capturing: false, - copied: false, - last_refusal: None, - error: None, - viewers: Vec::new(), - } - } -} - /// The host config summary echoed back by the child's `host_info` event. struct HostInfo { display: String, diff --git a/src/interactive.rs b/src/interactive.rs index 2b69489..574ed55 100644 --- a/src/interactive.rs +++ b/src/interactive.rs @@ -13,7 +13,7 @@ pub async fn run(cli: Cli) -> Result<()> { let theme = ColorfulTheme::default(); let choice = Select::with_theme(&theme) .with_prompt("What do you want to do?") - .items(&[ + .items([ "Host (share my screen)", "View (watch someone else's screen)", ]) @@ -112,7 +112,7 @@ fn pick_quality(theme: &ColorfulTheme) -> Result { let choice = Select::with_theme(theme) .with_prompt("What quality should the viewer(s) get?") - .items(&items) + .items(items) .default(0) .interact()?; @@ -138,7 +138,7 @@ pub async fn run_reconfigure() -> Result<()> { async fn preflight_if_needed(theme: &ColorfulTheme) { let mut cfg = config::load().unwrap_or_default(); match cfg.bandwidth.status { - config::BandwidthStatus::Measured | config::BandwidthStatus::Skipped => return, + config::BandwidthStatus::Measured | config::BandwidthStatus::Skipped => (), config::BandwidthStatus::Unmeasured => { eprintln!(); eprintln!("First-time setup"); @@ -154,7 +154,7 @@ async fn preflight_if_needed(theme: &ColorfulTheme) { let Ok(choice) = Select::with_theme(theme) .with_prompt("What would you like to do?") - .items(&[ + .items([ "Run the bandwidth test (recommended)", "Skip — use the conservative default", ]) @@ -180,7 +180,7 @@ async fn preflight_if_needed(theme: &ColorfulTheme) { eprintln!(); let Ok(choice) = Select::with_theme(theme) .with_prompt("Last bandwidth test failed. Try again?") - .items(&[ + .items([ "Yes — retry now", "No — use the conservative default", ]) @@ -341,7 +341,7 @@ pub fn prompt_player() -> Result { let theme = ColorfulTheme::default(); let choice = Select::with_theme(&theme) .with_prompt("Connected. Pick a player to launch") - .items(&["mpv", "VLC"]) + .items(["mpv", "VLC"]) .default(0) .interact()?; Ok(if choice == 0 { Player::Mpv } else { Player::Vlc })