new feature: pause playback when GUI window is closed

This commit is contained in:
2025-12-16 20:54:30 +03:00
parent ae5da6d9bd
commit 87b791ee3a
3 changed files with 14 additions and 1 deletions
+5
View File
@@ -48,10 +48,15 @@ impl SoundpadGui {
&mut self.config.save_scale_factor,
"Always remember UI scale factor",
);
let pause_on_exit_response = ui.checkbox(
&mut self.config.pause_on_exit,
"Pause audio playback when the window is closed",
);
if save_volume_response.changed()
|| save_input_response.changed()
|| save_scale_response.changed()
|| pause_on_exit_response.changed()
{
self.config.save_to_file().ok();
}
+7 -1
View File
@@ -149,7 +149,13 @@ pub async fn run() -> Result<(), Box<dyn Error>> {
Ok(Box::new(SoundpadGui::new(&cc.egui_ctx)))
}),
) {
Ok(_) => Ok(()),
Ok(_) => {
let config = get_gui_config();
if config.pause_on_exit {
make_request_sync(Request::pause()).ok();
}
Ok(())
}
Err(e) => Err(e.into()),
}
}