diff --git a/Cargo.toml b/Cargo.toml index 086d9df..35574f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ build = "build.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -slint = "1.1" +slint = "1.2.1" ab_versions = {git = "https://github.com/Vadoola/ab_versions_rs.git"} clap = { version = "4.3", features = ["derive"] } rayon = "1.5" @@ -18,7 +18,7 @@ log = "0.4.20" simplelog = "0.12.1" [build-dependencies] -slint-build = "1.1" +slint-build = "1.2.1" [profile.release] #https://github.com/johnthagen/min-sized-rust diff --git a/src/main.rs b/src/main.rs index 39f4b2e..d518e8d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,7 @@ use ab_versions::{get_version, is_protected, strip_protection}; use clap::Parser; -use log::error; +use log::{error, Record}; use rayon::prelude::{IntoParallelRefIterator, ParallelIterator}; use rfd::FileDialog; use simplelog::{CombinedLogger, Config, LevelFilter, SimpleLogger, WriteLogger}; @@ -100,7 +100,6 @@ fn main() -> Result<(), slint::PlatformError> { }); let info_file_model_start = file_model.clone(); - //let info_timer = vec![Timer::default(); file_model.row_count()]; let mut info_timers: Vec = (0..file_model.row_count()).map(|_i|Timer::default()).collect(); ui.on_slide_over(move |idx| { let idx = idx as usize; @@ -113,7 +112,7 @@ fn main() -> Result<(), slint::PlatformError> { fi.note_vis = true; info_file_model_start.set_row_data(idx, fi); } - info_timers[idx].start(TimerMode::SingleShot, std::time::Duration::from_secs(3), move || { + info_timers[idx].start(TimerMode::SingleShot, std::time::Duration::from_secs(10), move || { let info_file_model_stop = info_file_model_stop.clone(); let info_file_model_stop = info_file_model_stop.as_ref(); if let Some(mut fi) = info_file_model_stop.row_data(idx) { @@ -149,7 +148,50 @@ fn get_file_info(files: &HashMap) -> Vec { .par_iter() //need to do this differently....what if the version is older than 5 there the is_protected //would return an error...but I still want to display the version - .filter_map(|(name, file)| match is_protected(&file) { + .filter_map(|(name, file)| match get_version(&file) { + Ok(ver) => { + let note = if ver.is_old() { + if ver.is_restorable() { + "As an old MER some features may not restore correctly." + } else { + "Restoring a file this old is currently unsupported." + } + } else { + "" + }; + + let lckd = if ver.is_restorable() { + match is_protected(&file) { + Ok(prot) => prot, + Err(e) => { + error!( + "Unable to get file protected status from {}. Reason: {e}", + file.display() + ); + true + } + } + } else { + true + }; + + Some(file_info { + locked: lckd, + file_name: name.into(), + file_ver: ver.to_string().into(), + note: note.into(), + note_vis: false, + }) + } + Err(e) => { + error!( + "Unable to get file version from {}, file may not be a valid MER/APA file. Reason: {e}", + file.display() + ); + None + } + }) + /*.filter_map(|(name, file)| match is_protected(&file) { Ok(lckd) => match get_version(&file) { Ok(ver) => Some(file_info { locked: lckd, @@ -180,6 +222,6 @@ fn get_file_info(files: &HashMap) -> Vec { note_vis: false, }) } - }) + })*/ .collect() } diff --git a/ui/appwindow.slint b/ui/appwindow.slint index 64adf75..00a6e1b 100644 --- a/ui/appwindow.slint +++ b/ui/appwindow.slint @@ -24,7 +24,7 @@ component SlideOver inherits Rectangle { Rectangle { height: 2%; width: 100%; - background: yellow; + background: #F7630C; } } } @@ -76,9 +76,9 @@ component FileInfo inherits HorizontalLayout { } info-icon := Image { //this circle question icon is a temporary one while I'm offline, I just had it on my machine - source: @image-url("../assets/icons/circle-question.svg"); - colorize: yellow; - height: 100%; + source: @image-url("../assets/icons/info.svg"); + colorize: #F7630C; + height: 80%; width: self.height; visible: info.note != ""; info-ta := TouchArea {