1
0
Fork 0
mirror of synced 2024-06-27 02:21:05 +12:00
czkawka/czkawka_slint_gui/src/main.rs

44 lines
1.2 KiB
Rust
Raw Normal View History

2023-10-21 19:36:56 +13:00
mod connect_delete;
mod connect_scan;
use std::borrow::BorrowMut;
use std::path::Path;
2023-10-19 20:32:37 +13:00
use std::rc::Rc;
2023-10-21 19:36:56 +13:00
use crate::connect_delete::connect_delete_button;
use crate::connect_scan::connect_scan_button;
use czkawka_core::common_tool::CommonData;
use czkawka_core::empty_folder::EmptyFolder;
2023-10-20 08:39:48 +13:00
use slint::{Model, ModelRc, SharedString, VecModel};
2023-10-21 19:36:56 +13:00
slint::include_modules!();
2023-10-18 08:31:08 +13:00
fn main() {
2023-10-21 19:36:56 +13:00
let app = MainWindow::new().unwrap(); //.run().unwrap();
let row_data: Rc<VecModel<(bool, bool, bool, ModelRc<SharedString>)>> = Rc::new(VecModel::default());
2023-10-18 04:40:05 +13:00
2023-10-20 08:39:48 +13:00
for r in 0..1000 {
2023-10-19 20:32:37 +13:00
let items = VecModel::default();
for c in 0..3 {
items.push(slint::format!("Item {r}.{c}").into());
}
2023-10-22 02:13:27 +13:00
row_data.push((r % 2 == 0, false, true, ModelRc::new(items)));
2023-10-19 20:32:37 +13:00
}
2023-10-22 02:13:27 +13:00
app.set_empty_folder_model(row_data.into());
2023-10-19 20:32:37 +13:00
2023-10-21 19:36:56 +13:00
connect_delete_button(&app);
connect_scan_button(&app);
2023-10-20 08:39:48 +13:00
2023-10-19 20:32:37 +13:00
app.run().unwrap();
2023-10-21 19:36:56 +13:00
}
pub fn split_path(path: &Path) -> (String, String) {
match (path.parent(), path.file_name()) {
(Some(dir), Some(file)) => (dir.display().to_string(), file.to_string_lossy().into_owned()),
(Some(dir), None) => (dir.display().to_string(), String::new()),
(None, _) => (String::new(), String::new()),
}
}