1
0
Fork 0
mirror of synced 2024-05-17 19:03:08 +12:00
This commit is contained in:
Rafał Mikrut 2023-11-05 10:01:37 +01:00
parent 84b7145550
commit 592ec9a040
11 changed files with 139 additions and 82 deletions

118
Cargo.lock generated
View file

@ -669,9 +669,9 @@ dependencies = [
[[package]]
name = "cairo-rs"
version = "0.18.2"
version = "0.18.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c0466dfa8c0ee78deef390c274ad756801e0a6dbb86c5ef0924a298c5761c4d"
checksum = "f33613627f0dea6a731b0605101fad59ba4f193a52c96c4687728d822605a8a1"
dependencies = [
"bitflags 2.4.1",
"cairo-sys-rs",
@ -996,7 +996,7 @@ dependencies = [
[[package]]
name = "const-field-offset"
version = "0.1.3"
source = "git+https://github.com/slint-ui/slint.git#50a6040c38cf93c6cd0e21255e052286b468a59c"
source = "git+https://github.com/slint-ui/slint.git#8becbeb2926335400e4e31ab2d0758698a7ac627"
dependencies = [
"const-field-offset-macro",
"field-offset",
@ -1005,7 +1005,7 @@ dependencies = [
[[package]]
name = "const-field-offset-macro"
version = "0.1.3"
source = "git+https://github.com/slint-ui/slint.git#50a6040c38cf93c6cd0e21255e052286b468a59c"
source = "git+https://github.com/slint-ui/slint.git#8becbeb2926335400e4e31ab2d0758698a7ac627"
dependencies = [
"proc-macro2",
"quote",
@ -1235,9 +1235,9 @@ dependencies = [
[[package]]
name = "cursor-icon"
version = "1.0.0"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "740bb192a8e2d1350119916954f4409ee7f62f149b536911eeb78ba5a20526bf"
checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991"
[[package]]
name = "czkawka_cli"
@ -1333,6 +1333,7 @@ dependencies = [
"czkawka_core",
"handsome_logger",
"home",
"log",
"open",
"rand",
"rfd",
@ -2119,9 +2120,9 @@ dependencies = [
[[package]]
name = "gdk-pixbuf"
version = "0.18.0"
version = "0.18.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbc9c2ed73a81d556b65d08879ba4ee58808a6b1927ce915262185d6d547c6f3"
checksum = "446f32b74d22c33b7b258d4af4ffde53c2bf96ca2e29abdf1a785fe59bd6c82c"
dependencies = [
"gdk-pixbuf-sys",
"gio",
@ -2242,9 +2243,9 @@ dependencies = [
[[package]]
name = "gio"
version = "0.18.2"
version = "0.18.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57052f84e8e5999b258e8adf8f5f2af0ac69033864936b8b6838321db2f759b1"
checksum = "47d809baf02bdf1b5ef4ad3bf60dd9d4977149db4612b7bbb58e56aef168193b"
dependencies = [
"futures-channel",
"futures-core",
@ -2285,9 +2286,9 @@ dependencies = [
[[package]]
name = "glib"
version = "0.18.2"
version = "0.18.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c316afb01ce8067c5eaab1fc4f2cd47dc21ce7b6296358605e2ffab23ccbd19"
checksum = "58cf801b6f7829fa76db37449ab67c9c98a2b1bf21076d9113225621e61a0fa6"
dependencies = [
"bitflags 2.4.1",
"futures-channel",
@ -2308,12 +2309,12 @@ dependencies = [
[[package]]
name = "glib-macros"
version = "0.18.2"
version = "0.18.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8da903822b136d42360518653fcf154455defc437d3e7a81475bf9a95ff1e47"
checksum = "72793962ceece3863c2965d7f10c8786323b17c7adea75a515809fa20ab799a5"
dependencies = [
"heck",
"proc-macro-crate 1.3.1",
"proc-macro-crate 2.0.0",
"proc-macro-error",
"proc-macro2",
"quote",
@ -2651,7 +2652,7 @@ dependencies = [
[[package]]
name = "i-slint-backend-linuxkms"
version = "1.3.0"
source = "git+https://github.com/slint-ui/slint.git#50a6040c38cf93c6cd0e21255e052286b468a59c"
source = "git+https://github.com/slint-ui/slint.git#8becbeb2926335400e4e31ab2d0758698a7ac627"
dependencies = [
"calloop 0.11.0",
"drm",
@ -2672,7 +2673,7 @@ dependencies = [
[[package]]
name = "i-slint-backend-selector"
version = "1.3.0"
source = "git+https://github.com/slint-ui/slint.git#50a6040c38cf93c6cd0e21255e052286b468a59c"
source = "git+https://github.com/slint-ui/slint.git#8becbeb2926335400e4e31ab2d0758698a7ac627"
dependencies = [
"cfg-if",
"i-slint-backend-linuxkms",
@ -2685,7 +2686,7 @@ dependencies = [
[[package]]
name = "i-slint-backend-winit"
version = "1.3.0"
source = "git+https://github.com/slint-ui/slint.git#50a6040c38cf93c6cd0e21255e052286b468a59c"
source = "git+https://github.com/slint-ui/slint.git#8becbeb2926335400e4e31ab2d0758698a7ac627"
dependencies = [
"accesskit",
"bytemuck",
@ -2721,7 +2722,7 @@ dependencies = [
[[package]]
name = "i-slint-common"
version = "1.3.0"
source = "git+https://github.com/slint-ui/slint.git#50a6040c38cf93c6cd0e21255e052286b468a59c"
source = "git+https://github.com/slint-ui/slint.git#8becbeb2926335400e4e31ab2d0758698a7ac627"
dependencies = [
"cfg-if",
"derive_more",
@ -2732,7 +2733,7 @@ dependencies = [
[[package]]
name = "i-slint-compiler"
version = "1.3.0"
source = "git+https://github.com/slint-ui/slint.git#50a6040c38cf93c6cd0e21255e052286b468a59c"
source = "git+https://github.com/slint-ui/slint.git#8becbeb2926335400e4e31ab2d0758698a7ac627"
dependencies = [
"by_address",
"codemap",
@ -2761,7 +2762,7 @@ dependencies = [
[[package]]
name = "i-slint-core"
version = "1.3.0"
source = "git+https://github.com/slint-ui/slint.git#50a6040c38cf93c6cd0e21255e052286b468a59c"
source = "git+https://github.com/slint-ui/slint.git#8becbeb2926335400e4e31ab2d0758698a7ac627"
dependencies = [
"auto_enums",
"bytemuck",
@ -2804,7 +2805,7 @@ dependencies = [
[[package]]
name = "i-slint-core-macros"
version = "1.3.0"
source = "git+https://github.com/slint-ui/slint.git#50a6040c38cf93c6cd0e21255e052286b468a59c"
source = "git+https://github.com/slint-ui/slint.git#8becbeb2926335400e4e31ab2d0758698a7ac627"
dependencies = [
"quote",
"syn 2.0.38",
@ -2813,7 +2814,7 @@ dependencies = [
[[package]]
name = "i-slint-renderer-femtovg"
version = "1.3.0"
source = "git+https://github.com/slint-ui/slint.git#50a6040c38cf93c6cd0e21255e052286b468a59c"
source = "git+https://github.com/slint-ui/slint.git#8becbeb2926335400e4e31ab2d0758698a7ac627"
dependencies = [
"cfg-if",
"const-field-offset",
@ -2845,7 +2846,7 @@ dependencies = [
[[package]]
name = "i-slint-renderer-skia"
version = "1.3.0"
source = "git+https://github.com/slint-ui/slint.git#50a6040c38cf93c6cd0e21255e052286b468a59c"
source = "git+https://github.com/slint-ui/slint.git#8becbeb2926335400e4e31ab2d0758698a7ac627"
dependencies = [
"ash",
"bytemuck",
@ -3382,6 +3383,28 @@ version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058"
[[package]]
name = "libredox"
version = "0.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8"
dependencies = [
"bitflags 2.4.1",
"libc",
"redox_syscall 0.4.1",
]
[[package]]
name = "libredox"
version = "0.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3af92c55d7d839293953fcd0fda5ecfe93297cfde6ffbdec13b41d99c0ba6607"
dependencies = [
"bitflags 2.4.1",
"libc",
"redox_syscall 0.4.1",
]
[[package]]
name = "libseat"
version = "0.2.1"
@ -3944,11 +3967,11 @@ dependencies = [
[[package]]
name = "orbclient"
version = "0.3.46"
version = "0.3.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8378ac0dfbd4e7895f2d2c1f1345cab3836910baf3a300b000d04250f0c8428f"
checksum = "52f0d54bde9774d3a51dcf281a5def240c71996bc6ca05d2c847ec8b2b216166"
dependencies = [
"redox_syscall 0.3.5",
"libredox 0.0.2",
]
[[package]]
@ -3978,9 +4001,9 @@ dependencies = [
[[package]]
name = "pango"
version = "0.18.0"
version = "0.18.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06a9e54b831d033206160096b825f2070cf5fda7e35167b1c01e9e774f9202d1"
checksum = "7ca27ec1eb0457ab26f3036ea52229edbdb74dee1edd29063f5b9b010e7ebee4"
dependencies = [
"gio",
"glib",
@ -4436,15 +4459,6 @@ dependencies = [
"rustfft 6.1.0",
]
[[package]]
name = "redox_syscall"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
dependencies = [
"bitflags 1.3.2",
]
[[package]]
name = "redox_syscall"
version = "0.3.5"
@ -4465,12 +4479,12 @@ dependencies = [
[[package]]
name = "redox_users"
version = "0.4.3"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b"
checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4"
dependencies = [
"getrandom",
"redox_syscall 0.2.16",
"libredox 0.0.1",
"thiserror",
]
@ -5038,7 +5052,7 @@ dependencies = [
[[package]]
name = "slint"
version = "1.3.0"
source = "git+https://github.com/slint-ui/slint.git#50a6040c38cf93c6cd0e21255e052286b468a59c"
source = "git+https://github.com/slint-ui/slint.git#8becbeb2926335400e4e31ab2d0758698a7ac627"
dependencies = [
"const-field-offset",
"i-slint-backend-selector",
@ -5054,7 +5068,7 @@ dependencies = [
[[package]]
name = "slint-build"
version = "1.3.0"
source = "git+https://github.com/slint-ui/slint.git#50a6040c38cf93c6cd0e21255e052286b468a59c"
source = "git+https://github.com/slint-ui/slint.git#8becbeb2926335400e4e31ab2d0758698a7ac627"
dependencies = [
"i-slint-compiler",
"spin_on",
@ -5065,7 +5079,7 @@ dependencies = [
[[package]]
name = "slint-macros"
version = "1.3.0"
source = "git+https://github.com/slint-ui/slint.git#50a6040c38cf93c6cd0e21255e052286b468a59c"
source = "git+https://github.com/slint-ui/slint.git#8becbeb2926335400e4e31ab2d0758698a7ac627"
dependencies = [
"i-slint-compiler",
"proc-macro2",
@ -6199,7 +6213,7 @@ dependencies = [
[[package]]
name = "vtable"
version = "0.1.11"
source = "git+https://github.com/slint-ui/slint.git#50a6040c38cf93c6cd0e21255e052286b468a59c"
source = "git+https://github.com/slint-ui/slint.git#8becbeb2926335400e4e31ab2d0758698a7ac627"
dependencies = [
"const-field-offset",
"portable-atomic",
@ -6210,7 +6224,7 @@ dependencies = [
[[package]]
name = "vtable-macro"
version = "0.1.10"
source = "git+https://github.com/slint-ui/slint.git#50a6040c38cf93c6cd0e21255e052286b468a59c"
source = "git+https://github.com/slint-ui/slint.git#8becbeb2926335400e4e31ab2d0758698a7ac627"
dependencies = [
"proc-macro2",
"quote",
@ -6735,9 +6749,9 @@ dependencies = [
[[package]]
name = "winnow"
version = "0.5.18"
version = "0.5.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "176b6138793677221d420fd2f0aeeced263f197688b36484660da767bca2fa32"
checksum = "829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b"
dependencies = [
"memchr",
]
@ -6956,18 +6970,18 @@ dependencies = [
[[package]]
name = "zerocopy"
version = "0.7.21"
version = "0.7.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "686b7e407015242119c33dab17b8f61ba6843534de936d94368856528eae4dcc"
checksum = "8cd369a67c0edfef15010f980c3cbe45d7f651deac2cd67ce097cd801de16557"
dependencies = [
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
version = "0.7.21"
version = "0.7.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "020f3dfe25dfc38dfea49ce62d5d45ecdd7f0d8a724fa63eb36b6eba4ec76806"
checksum = "c2f140bda219a26ccc0cdb03dba58af72590c53b22642577d88a927bc5c87d6b"
dependencies = [
"proc-macro2",
"quote",

View file

@ -29,13 +29,15 @@ 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"
log = "0.4.20"
[build-dependencies]
#slint-build = "1.2.2"
slint-build = { git = "https://github.com/slint-ui/slint.git" }
[features]
default = ["winit_femtovg", "winit_software"]
# TODO remove from deault features skia, because is harder to cross-compile it
default = ["winit_femtovg", "winit_software", "winit_skia_opengl"]
skia_opengl = ["slint/renderer-skia-opengl"]
skia_vulkan = ["slint/renderer-skia-vulkan"]
software = ["slint/renderer-software"]

View file

@ -10,6 +10,11 @@ Slint version of app should not have any special runtime requirements - it shoul
Alternatively, it can be run with software rendering.
## Compilation
Ubuntu
```
sudo apt install libfontconfig-dev libfreetype-dev
```
Default compilation is done by `cargo build --release` and should work on most systems.
You need the latest available version of Rust to compile it, because NAME_TODO aims to support the latest slint verions,

View file

@ -4,6 +4,7 @@ use slint::{ComponentHandle, Model, ModelRc, VecModel};
use crate::MainListModel;
use crate::{CurrentTab, MainWindow};
use log::info;
pub fn connect_delete_button(app: &MainWindow) {
let a = app.as_weak();
@ -34,7 +35,7 @@ fn handle_delete_empty_folders(app: &MainWindow) {
// TODO delete in parallel items, consider to add progress bar
fn remove_selected_items(items: Vec<MainListModel>) {
dbg!(format!("Items to remove {}", items.len()));
info!("Items to remove {}", items.len());
drop(items);
// items.into_iter().for_each(|_item| {});
}

View file

@ -1,8 +1,46 @@
use crate::{MainWindow, Settings};
use rfd::FileDialog;
use slint::{ComponentHandle, Model, ModelRc, VecModel};
pub fn connect_add_directories(app: &MainWindow) {
use crate::{MainWindow, Settings};
pub fn connect_add_remove_directories(app: &MainWindow) {
connect_add_directories(app);
connect_remove_directories(app);
}
fn connect_remove_directories(app: &MainWindow) {
let a = app.as_weak();
app.global::<Settings>().on_remove_item_directories(move |included_directories, current_index| {
// Nothing selected
if current_index == -1 {
return;
}
let app = a.upgrade().unwrap();
let settings = app.global::<Settings>();
if included_directories {
let included_model = settings.get_included_directories();
let model_count = included_model.iter().count();
if model_count > current_index as usize {
let mut included_model = included_model.iter().collect::<Vec<_>>();
included_model.remove(current_index as usize);
settings.set_included_directories(ModelRc::new(VecModel::from(included_model)));
}
} else {
let excluded_model = settings.get_excluded_directories();
let model_count = excluded_model.iter().count();
if model_count > current_index as usize {
let mut excluded_model = excluded_model.iter().collect::<Vec<_>>();
excluded_model.remove(current_index as usize);
settings.set_excluded_directories(ModelRc::new(VecModel::from(excluded_model)));
}
}
});
}
fn connect_add_directories(app: &MainWindow) {
let a = app.as_weak();
app.on_folder_choose_requested(move |included_directories| {
let app = a.upgrade().unwrap();

View file

@ -1,7 +1,8 @@
use crate::MainListModel;
use crate::{split_path, CurrentTab, MainWindow, ProgressToSend};
use crate::{CurrentTab, MainWindow, ProgressToSend};
use chrono::NaiveDateTime;
use crossbeam_channel::{Receiver, Sender};
use czkawka_core::common::split_path;
use czkawka_core::common_dir_traversal::ProgressData;
use czkawka_core::common_tool::CommonData;
use czkawka_core::empty_folder::EmptyFolder;

View file

@ -22,14 +22,13 @@ mod connect_stop;
mod settings;
use crossbeam_channel::{unbounded, Receiver, Sender};
use std::path::Path;
use std::rc::Rc;
use crate::connect_delete::connect_delete_button;
use crate::connect_open::connect_open_items;
use crate::connect_scan::connect_scan_button;
use crate::connect_directories_changes::connect_add_directories;
use crate::connect_directories_changes::connect_add_remove_directories;
use crate::connect_progress_receiver::connect_progress_gathering;
use crate::connect_stop::connect_stop_button;
use crate::settings::reset_settings;
@ -53,7 +52,7 @@ fn main() {
connect_stop_button(&app, stop_sender);
connect_open_items(&app);
connect_progress_gathering(&app, progress_receiver);
connect_add_directories(&app);
connect_add_remove_directories(&app);
reset_settings(&app);
@ -106,11 +105,3 @@ pub fn to_remove_debug(app: &MainWindow) {
app.set_empty_files_model(non_header_row_data.into());
app.set_similar_images_model(header_row_data.into());
}
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()),
}
}

View file

@ -4,7 +4,7 @@ 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};
use slint::{ComponentHandle, SharedString};
#[cfg(target_family = "unix")]
const DEFAULT_EXCLUDED_DIRECTORIES: &[&str] = &["/proc", "/dev", "/sys", "/run", "/snap"];
@ -21,23 +21,20 @@ pub fn reset_settings(app: &MainWindow) {
let mut included_directories = vec![];
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 {
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());
}
}
// This could be set to default
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);
// Excluded directories
let mut excluded_directories = DEFAULT_EXCLUDED_DIRECTORIES.iter().map(|x| x.to_string()).collect::<Vec<_>>();
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);

View file

@ -18,6 +18,9 @@ component DirectoriesPanel {
}
Button {
text: "Remove";
clicked => {
Settings.remove_item_directories(true, included-list.current-item);
}
}
Rectangle {
vertical-stretch: 1.0;
@ -29,7 +32,7 @@ component DirectoriesPanel {
text: "Included Directories";
}
}
StandardListView {
included_list := StandardListView {
model: Settings.included-directories;
}
}
@ -43,6 +46,9 @@ component DirectoriesPanel {
}
Button {
text: "Remove";
clicked => {
Settings.remove_item_directories(false, excluded-list.current-item);
}
}
Rectangle {
vertical-stretch: 1.0;
@ -54,7 +60,7 @@ component DirectoriesPanel {
text: "Excluded Directories";
}
}
StandardListView {
excluded_list := StandardListView {
model: Settings.excluded-directories;
}
}

View file

@ -22,7 +22,7 @@ export component MainWindow inherits Window {
callback scan_ended();
min-width: 300px;
preferred-width: 2000px;
preferred-width: 800px;
min-height: 300px;
preferred-height: 600px;

View file

@ -8,4 +8,6 @@ export global Settings {
in-out property <[StandardListViewItem]> included_directories: [{text: "ABCD"}, {text: "BCDA"}];
in-out property <[StandardListViewItem]> excluded_directories: [{text: "ABCD"}, {text: "BCDA"}, {text: "CDFFF"}];
callback remove_item_directories(bool, int);
}