Downloading prototype works
This commit is contained in:
@@ -1,40 +1,80 @@
|
||||
use std::str::FromStr;
|
||||
|
||||
use super::Window;
|
||||
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SettingsW {
|
||||
accent_color: egui::Color32,
|
||||
primary_bg_color: egui::Color32,
|
||||
secondary_bg_color: egui::Color32,
|
||||
text_color: egui::Color32,
|
||||
dim_text_color: egui::Color32,
|
||||
ytdlp_p: String,
|
||||
spotdl_p: String,
|
||||
ffmpeg_p: String,
|
||||
song_fmt: String,
|
||||
}
|
||||
|
||||
impl Default for SettingsW {
|
||||
fn default() -> Self {
|
||||
let def = xmpd_settings::theme::Theme::default();
|
||||
Self {
|
||||
accent_color: def.accent_color,
|
||||
primary_bg_color: def.primary_bg_color,
|
||||
secondary_bg_color: def.secondary_bg_color,
|
||||
text_color: def.text_color,
|
||||
dim_text_color: def.dim_text_color
|
||||
let tooling = xmpd_settings::Settings::get().unwrap().tooling.clone();
|
||||
Self {
|
||||
ytdlp_p: tooling.ytdlp_path.to_string(),
|
||||
spotdl_p: tooling.spotdl_path.to_string(),
|
||||
ffmpeg_p: tooling.ffmpeg_path.to_string(),
|
||||
song_fmt: tooling.song_format
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
impl Window for SettingsW {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
fn draw(&mut self, ui: &mut egui::Ui, _: &mut crate::GuiState) -> crate::Result<()> {
|
||||
let theme = &mut xmpd_settings::Settings::get()?.theme;
|
||||
ui.group(|ui| {
|
||||
ui.vertical(|ui| {
|
||||
ui.heading("Theme");
|
||||
Self::add_theme_button(&mut theme.accent_color, ui, "Accent");
|
||||
Self::add_theme_button(&mut theme.primary_bg_color, ui, "Primary BG");
|
||||
Self::add_theme_button(&mut theme.secondary_bg_color, ui, "Secondary BG");
|
||||
Self::add_theme_button(&mut theme.text_color, ui, "Text");
|
||||
Self::add_theme_button(&mut theme.dim_text_color, ui, "Dim Text");
|
||||
ui.horizontal(|ui| {
|
||||
{
|
||||
let theme = &mut handle_error_ui!(xmpd_settings::Settings::get()).theme;
|
||||
ui.group(|ui| {
|
||||
ui.vertical(|ui| {
|
||||
ui.heading("Theme");
|
||||
Self::add_theme_button(&mut theme.accent_color, ui, "Accent");
|
||||
Self::add_theme_button(&mut theme.primary_bg_color, ui, "Primary BG");
|
||||
Self::add_theme_button(&mut theme.secondary_bg_color, ui, "Secondary BG");
|
||||
Self::add_theme_button(&mut theme.text_color, ui, "Text");
|
||||
Self::add_theme_button(&mut theme.dim_text_color, ui, "Dim Text");
|
||||
if ui.button("Reset").clicked() {
|
||||
*theme = xmpd_settings::theme::Theme::default();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
{
|
||||
ui.group(|ui| {
|
||||
ui.vertical(|ui| {
|
||||
ui.heading("Tooling paths");
|
||||
Self::add_tooling_input(&mut self.ytdlp_p, ui, "stdlp");
|
||||
Self::add_tooling_input(&mut self.spotdl_p, ui, "spotdl");
|
||||
Self::add_tooling_input(&mut self.ffmpeg_p, ui, "ffmpeg");
|
||||
Self::add_tooling_input(&mut self.song_fmt, ui, "Format");
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
ui.with_layout(egui::Layout::bottom_up(egui::Align::RIGHT), |ui| {
|
||||
if ui.button("Save").clicked() {
|
||||
let mut settings = handle_error_ui!(xmpd_settings::Settings::get());
|
||||
if let Ok(p) = camino::Utf8PathBuf::from_str(&self.ytdlp_p) {
|
||||
settings.tooling.ytdlp_path = p;
|
||||
}
|
||||
if let Ok(p) = camino::Utf8PathBuf::from_str(&self.spotdl_p) {
|
||||
settings.tooling.spotdl_path = p;
|
||||
}
|
||||
if let Ok(p) = camino::Utf8PathBuf::from_str(&self.ffmpeg_p) {
|
||||
settings.tooling.ffmpeg_path = p;
|
||||
}
|
||||
settings.tooling.song_format.clone_from(&self.song_fmt);
|
||||
handle_error_ui!(settings.save(None));
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
Ok(())
|
||||
@@ -48,4 +88,10 @@ impl SettingsW {
|
||||
ui.color_edit_button_srgba(rf);
|
||||
});
|
||||
}
|
||||
fn add_tooling_input(inp: &mut String, ui: &mut egui::Ui, name: &str) {
|
||||
ui.horizontal(|ui|{
|
||||
ui.label(format!("{name}: "));
|
||||
ui.text_edit_singleline(inp);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user