use crate::helpers::traits::LogIfErr;
use eframe::egui::{Response, Ui, Widget};
use std::path::PathBuf;
#[derive(Debug, Clone)]
pub struct PathLabel(PathBuf);
impl PathLabel {
#[must_use]
pub fn new(mut path: PathBuf) -> Self {
if path.file_name() == Some(std::ffi::OsStr::new("About.xml")) {
path.pop(); path.pop(); }
Self(path)
}
}
impl Widget for &PathLabel {
fn ui(self, ui: &mut Ui) -> Response {
let path = self.0.as_os_str().to_str().unwrap_or_default();
let lab = ui.button(path);
if lab.clicked() && !path.is_empty() {
open::that(self.0.clone()).log_if_err();
}
lab
}
}