Change tabs depending on TCP input.

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-04-30 10:46:08 +02:00
parent cd80468f54
commit 51a2c28c55
2 changed files with 26 additions and 2 deletions

View File

@@ -48,10 +48,19 @@ pub enum TabActive {
Shortcuts,
}
impl ToString for TabActive {
fn to_string(&self) -> String {
match self {
TabActive::Single => "Single".to_string(),
TabActive::Sweep => "Sweep".to_string(),
TabActive::Shortcuts => "Shortcuts".to_string(),
}
}
}
pub struct App {
tree: DockState<String>,
tab_viewer: CustomTabs,
// tab_active: TabActive,
log_filename: Arc<Mutex<String>>,
log_marker_modal: bool,
log_marker: String,
@@ -865,6 +874,17 @@ impl eframe::App for App {
.show_inside(ui, &mut self.tab_viewer);
});
// Check if tab is different from the active tab in app state, if so, switch to that tab
if let Some((_, name)) = self.tree.find_active_focused() {
if self.app_state_rx.borrow().tab_active.to_string() != *name {
let active_tab = self.app_state_rx.borrow().tab_active.to_string();
self.tree.set_active_tab(self.tree.find_tab(&active_tab).unwrap());
}
} else {
let active_tab = self.app_state_rx.borrow().tab_active.to_string();
self.tree.set_active_tab(self.tree.find_tab(&active_tab).unwrap());
}
// CMD- or control-W to close window
if ctx.input(|i| i.modifiers.cmd_ctrl_matches(Modifiers::COMMAND))
&& ctx.input(|i| i.key_pressed(Key::W))