free-launch 0.2.9

A simple fuzzy launcher written in Rust.
Documentation
use crate::free_launch::free_launch::{Actions, FreeLaunch};

impl FreeLaunch {
    #[must_use]
    pub(crate) fn show_debug_screen(&mut self, ui: &mut egui::Ui) -> Vec<Actions> {
        egui::ScrollArea::vertical().show(ui, |ui| {
            ui.vertical_centered(|ui| {
                ui.heading("Free Launch - Debug Mode");
                ui.add_space(20.0);

                ui.label(format!(
                    "Total LaunchEntries: {}",
                    // TODO find a way to get rid of this clone call
                    self.index_metadata
                        .clone()
                        .map(|m| m.total_items)
                        .unwrap_or(0)
                ));
                ui.add_space(10.0);

                ui.separator();
                ui.add_space(10.0);

                // Show details for each LaunchEntry
                for selectable_entry in &self.last_search_results {
                    let entry = selectable_entry.lock();

                    ui.group(|ui| {
                        ui.vertical(|ui| {
                            ui.heading(format!(
                                "LaunchEntry: {} ({})",
                                entry.name(),
                                entry.id().unwrap_or("NONE".to_string())
                            ));
                            ui.label(format!("Selected: {}", entry.selected));
                            ui.label(format!("Sort Key: {}", entry.sort_key()));

                            ui.add_space(5.0);

                            // Show Invocations
                            ui.label(format!("Invocations ({}): ", entry.invocations.len()));
                            if entry.invocations.is_empty() {
                                ui.label("  None");
                            } else {
                                for (i, invocation) in entry.invocations.iter().enumerate() {
                                    ui.label(format!(
                                        "  [{}] Timestamp: {}, Action: {}, Query: '{}'",
                                        i,
                                        invocation.timestamp,
                                        invocation.action,
                                        invocation.search_query
                                    ));
                                }
                            }

                            ui.add_space(5.0);

                            // Show DesktopItems
                            ui.label(format!("DesktopItems ({}): ", entry.items.len()));
                            if entry.items.is_empty() {
                                ui.label("  None");
                            } else {
                                for (i, item) in entry.items.iter().enumerate() {
                                    item.debug_ui(ui, i);
                                }
                            }
                        });
                    });
                    ui.add_space(10.0);
                }

                ui.add_space(20.0);
                ui.separator();
                ui.add_space(10.0);
                ui.label("Press Ctrl+i again to return to the main screen.");
            });
        });

        Default::default()
    }
}