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

50 lines
1.3 KiB
Rust
Raw Normal View History

2023-10-21 19:36:56 +13:00
mod connect_delete;
2023-10-22 23:18:41 +13:00
mod connect_open;
2023-10-21 19:36:56 +13:00
mod connect_scan;
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;
2023-10-22 23:18:41 +13:00
use crate::connect_open::connect_open_items;
2023-10-21 19:36:56 +13:00
use crate::connect_scan::connect_scan_button;
2023-10-22 10:33:29 +13:00
use slint::{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();
2023-10-22 10:33:29 +13:00
to_remove_debug(&app);
connect_delete_button(&app);
connect_scan_button(&app);
2023-10-22 23:18:41 +13:00
connect_open_items(&app);
2023-10-22 10:33:29 +13:00
app.run().unwrap();
}
// TODO remove this after trying
pub fn to_remove_debug(app: &MainWindow) {
2023-10-21 19:36:56 +13:00
let row_data: Rc<VecModel<(bool, bool, bool, ModelRc<SharedString>)>> = Rc::new(VecModel::default());
2023-10-18 04:40:05 +13:00
2023-10-22 10:33:29 +13:00
for r in 0..100000 {
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 10:33:29 +13:00
row_data.push((r % 2 == 0, r % 3 == 0, false, 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-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()),
}
}