G
This commit is contained in:
parent
da54431880
commit
84b7145550
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1332,6 +1332,7 @@ dependencies = [
|
|||
"crossbeam-channel",
|
||||
"czkawka_core",
|
||||
"handsome_logger",
|
||||
"home",
|
||||
"open",
|
||||
"rand",
|
||||
"rfd",
|
||||
|
|
|
@ -28,6 +28,7 @@ open = "5.0.0"
|
|||
crossbeam-channel = "0.5.8"
|
||||
handsome_logger = "0.8.0"
|
||||
rfd = { version = "0.12.0", default-features = false, features = ["xdg-portal"] }
|
||||
home = "0.5.5"
|
||||
|
||||
[build-dependencies]
|
||||
#slint-build = "1.2.2"
|
||||
|
|
|
@ -1 +1,13 @@
|
|||
use slint::{ModelRc, SharedString, StandardListViewItem, VecModel};
|
||||
|
||||
pub fn create_string_standard_list_view(items: &[String]) -> ModelRc<StandardListViewItem> {
|
||||
let new_folders_standard_list_view = items
|
||||
.iter()
|
||||
.map(|x| {
|
||||
let mut element = StandardListViewItem::default();
|
||||
element.text = SharedString::from(x.to_string());
|
||||
element
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
ModelRc::new(VecModel::from(new_folders_standard_list_view))
|
||||
}
|
||||
|
|
|
@ -1,26 +1,44 @@
|
|||
use crate::MainWindow;
|
||||
use std::env;
|
||||
|
||||
use crate::common::create_string_standard_list_view;
|
||||
use crate::Settings;
|
||||
use home::home_dir;
|
||||
use slint::{ComponentHandle, ModelRc, SharedString, StandardListViewItem, VecModel};
|
||||
|
||||
#[cfg(target_family = "unix")]
|
||||
const DEFAULT_EXCLUDED_DIRECTORIES: &[&str] = &["/proc", "/dev", "/sys", "/run", "/snap"];
|
||||
#[cfg(not(target_family = "unix"))]
|
||||
const DEFAULT_EXCLUDED_DIRECTORIES: &[&str] = &["C:\\Windows"];
|
||||
|
||||
pub fn reset_settings(app: &MainWindow) {
|
||||
let settings = app.global::<Settings>();
|
||||
|
||||
// app.width(1000);
|
||||
app.invoke_set_console_text(SharedString::from(""));
|
||||
|
||||
// Get current folder where executed binary is
|
||||
let current_folder = env::current_dir();
|
||||
// Included directories
|
||||
let mut included_directories = vec![];
|
||||
if let Ok(current_dir) = current_folder {
|
||||
if let Ok(current_dir) = env::current_dir() {
|
||||
included_directories.push(current_dir.to_string_lossy().to_string());
|
||||
} else {
|
||||
if let Some(home_dir) = home_dir() {
|
||||
included_directories.push(home_dir.to_string_lossy().to_string());
|
||||
} else {
|
||||
if cfg!(target_family = "unix") {
|
||||
included_directories.push("/".to_string());
|
||||
} else {
|
||||
included_directories.push("C:\\".to_string());
|
||||
}
|
||||
}
|
||||
};
|
||||
included_directories.sort();
|
||||
let included_items = create_string_standard_list_view(&included_directories);
|
||||
settings.set_included_directories(included_items);
|
||||
|
||||
let included_items = VecModel::default();
|
||||
for i in included_directories {
|
||||
let mut element = StandardListViewItem::default();
|
||||
element.text = SharedString::from(i);
|
||||
included_items.push(element);
|
||||
}
|
||||
settings.set_included_directories(ModelRc::new(included_items));
|
||||
// Excluded directories
|
||||
let mut excluded_directories = DEFAULT_EXCLUDED_DIRECTORIES.iter().map(|x| x.to_string()).collect::<Vec<_>>();
|
||||
excluded_directories.sort();
|
||||
let excluded_items = create_string_standard_list_view(&excluded_directories);
|
||||
settings.set_excluded_directories(excluded_items);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue