Skip to content

Commit b793a0d

Browse files
committed
Fix URL button layout and add URL history
1 parent 8e3c37a commit b793a0d

3 files changed

Lines changed: 36 additions & 1 deletion

File tree

src/engine.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,6 +1833,21 @@ impl<'a> VulkanEngine<'a> {
18331833
}
18341834
});
18351835
});
1836+
1837+
if !state.url_history.is_empty() {
1838+
ui.separator();
1839+
ui.label(egui::RichText::new("Recent Streams:").strong());
1840+
egui::ScrollArea::vertical().max_height(150.0).show(ui, |ui| {
1841+
for (url, title) in &state.url_history {
1842+
if ui.add_sized(
1843+
[ui.available_width(), 30.0],
1844+
egui::Button::new(format!("{} ({})", title, url))
1845+
).clicked() {
1846+
engine_action = EngineAction::LoadUrl(url.clone());
1847+
}
1848+
}
1849+
});
1850+
}
18361851
});
18371852
}
18381853

src/main.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,8 +808,16 @@ async fn run_gui(app_state: Arc<Mutex<AppState>>, mut active_stream: Option<audi
808808
state.url_input_text.clear();
809809
state.playlist = vec![url.clone()];
810810
state.playlist_index = 0;
811-
state.load_request = Some(url);
811+
state.load_request = Some(url.clone());
812812
state.file_loaded = true;
813+
if !state.url_history.iter().any(|(u, _)| u == &url) {
814+
state.url_history.push((url.clone(), "Network Stream".to_string()));
815+
let mut out = String::new();
816+
for (u, t) in &state.url_history {
817+
out.push_str(&format!("{}|{}\n", u, t));
818+
}
819+
let _ = std::fs::write("url_history.txt", out);
820+
}
813821
}
814822
EngineAction::None => {}
815823
}

src/state.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ pub struct AppState {
170170
pub open_file_request: bool,
171171
pub is_url_dialog_open: bool,
172172
pub url_input_text: String,
173+
pub url_history: Vec<(String, String)>,
173174
pub egui_gamepad_events: Vec<egui::Event>,
174175
pub force_stereo_downmix: bool,
175176
pub append_to_playlist: bool,
@@ -212,6 +213,15 @@ impl AppState {
212213
vis_enabled[9] = false; // Ferrofluid Particle Sim
213214
vis_enabled[10] = false; // Neon Corridor
214215
}
216+
217+
let mut url_history = Vec::new();
218+
if let Ok(data) = std::fs::read_to_string("url_history.txt") {
219+
for line in data.lines() {
220+
if let Some((url, title)) = line.split_once('|') {
221+
url_history.push((url.to_string(), title.to_string()));
222+
}
223+
}
224+
}
215225

216226
AppState {
217227
passthrough_enabled: true,
@@ -273,6 +283,7 @@ impl AppState {
273283
open_file_request: false,
274284
is_url_dialog_open: false,
275285
url_input_text: String::new(),
286+
url_history,
276287
egui_gamepad_events: Vec::new(),
277288
force_stereo_downmix: is_steam_deck,
278289
append_to_playlist: false,
@@ -358,6 +369,7 @@ impl AppState {
358369
open_file_request: false,
359370
is_url_dialog_open: self.is_url_dialog_open,
360371
url_input_text: self.url_input_text.clone(),
372+
url_history: self.url_history.clone(),
361373
egui_gamepad_events: Vec::new(),
362374
force_stereo_downmix: self.force_stereo_downmix,
363375
append_to_playlist: self.append_to_playlist,

0 commit comments

Comments
 (0)