mirror of
https://github.com/arabianq/pipewire-soundpad.git
synced 2026-04-28 06:21:23 +00:00
new feature: pause playback when GUI window is closed
This commit is contained in:
@@ -48,10 +48,15 @@ impl SoundpadGui {
|
|||||||
&mut self.config.save_scale_factor,
|
&mut self.config.save_scale_factor,
|
||||||
"Always remember UI 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()
|
if save_volume_response.changed()
|
||||||
|| save_input_response.changed()
|
|| save_input_response.changed()
|
||||||
|| save_scale_response.changed()
|
|| save_scale_response.changed()
|
||||||
|
|| pause_on_exit_response.changed()
|
||||||
{
|
{
|
||||||
self.config.save_to_file().ok();
|
self.config.save_to_file().ok();
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-1
@@ -149,7 +149,13 @@ pub async fn run() -> Result<(), Box<dyn Error>> {
|
|||||||
Ok(Box::new(SoundpadGui::new(&cc.egui_ctx)))
|
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()),
|
Err(e) => Err(e.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ pub struct GuiConfig {
|
|||||||
pub save_volume: bool,
|
pub save_volume: bool,
|
||||||
pub save_input: bool,
|
pub save_input: bool,
|
||||||
pub save_scale_factor: bool,
|
pub save_scale_factor: bool,
|
||||||
|
pub pause_on_exit: bool,
|
||||||
|
|
||||||
pub dirs: HashSet<PathBuf>,
|
pub dirs: HashSet<PathBuf>,
|
||||||
}
|
}
|
||||||
@@ -48,6 +49,7 @@ impl Default for GuiConfig {
|
|||||||
save_volume: false,
|
save_volume: false,
|
||||||
save_input: false,
|
save_input: false,
|
||||||
save_scale_factor: false,
|
save_scale_factor: false,
|
||||||
|
pause_on_exit: false,
|
||||||
|
|
||||||
dirs: HashSet::default(),
|
dirs: HashSet::default(),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user