Skip to content

Commit

Permalink
AB
Browse files Browse the repository at this point in the history
  • Loading branch information
qarmin committed Feb 18, 2024
1 parent fb85df9 commit 989c423
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 83 deletions.
133 changes: 67 additions & 66 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Version 7.0.0 - ?
## Version 7.0.0 - 19.02.2024r
### BREAKING CHANGES
- Reducing size of cache files, made old cache files incompatible with new version
- `-C` in CLI now saves as compact json
Expand Down Expand Up @@ -34,7 +34,7 @@
- Decrease a little size of cache by few percents and improve loading/saving speed - [#1159](https://github.com/qarmin/czkawka/pull/1159)
- Added ability to remove from scan files with excluded extensions - [#1184](https://github.com/qarmin/czkawka/pull/1102)
- Fixed not showing in similar images results, files with same hashes when using reference folders - [#1184](https://github.com/qarmin/czkawka/pull/1102)
- Optimize release binaries with LTO(~25% smaller, ~5/10% faster) - [#1184](https://github.com/qarmin/czkawka/pull/1102)
- Optimize release binaries with LTO(~25/50% smaller, ~5/10% faster) - [#1184](https://github.com/qarmin/czkawka/pull/1102)

## Version 6.1.0 - 15.10.2023r
- BREAKING CHANGE - Changed cache saving method, deduplicated, optimized and simplified procedure(all files needs to be hashed again) - [#1072](https://github.com/qarmin/czkawka/pull/1072), [#1086](https://github.com/qarmin/czkawka/pull/1086)
Expand Down
1 change: 1 addition & 0 deletions krokiet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ directories-next = "2.0"
image_hasher = "1.2"
rayon = "1.8"
fs_extra = "1.3" # TODO replace with less buggy library
trash = "3.3"

# Translations
i18n-embed = { version = "0.14", features = ["fluent-system", "desktop-requester"] }
Expand Down
16 changes: 8 additions & 8 deletions krokiet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ C code.
![Krokiet](https://github.com/qarmin/czkawka/assets/41945903/52628a29-ecd6-4692-9ee4-8a680c889193)

Different toolkit means different look, limitations and features, so you should not expect same features like in Gtk 4
frontend(but of course I want implement most of features from other project).
frontend(but of course I want implement most of the features from other project).

## Usage

Expand Down Expand Up @@ -109,13 +109,13 @@ SLINT_STYLE=material-dark cargo run -- --path .

There are multiple reasons why I decided to use Slint as toolkit for Krokiet over other toolkits.

| Toolkit | Pros | Cons |
|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Gtk 4 | - Hard compilation/cross compilation and bundling all required libraries - mostly on windows </br> - Cambalache can be used to create graphically gui </br> - Good gtk4-rs bindings(but sometimes not really intuitive) | - Hard compilation/cross compilation and bundling all required libraries - mostly on windows </br> - Forcing the use of a specific gui creation style </br> - Strange crashes, not working basic features, etc.(again, mostly on windows) </br> - Forcing to use bugged/outdated but dynamically loaded version of libraries on linux (e.g. 4.6 on Ubuntu 22.04) - not all fixes are backported |
| Qt | - QML support - simplify creating of gui from code it is easy to use and powerful </br> - Very flexible framework <br/> - Typescript/javascript <=> qml interoperability </br> - Probably the most mature GUI library | - New and limited qt bindings <br/> - Hard to cross-compile <br/> - Very easy to create and use invalid state in QML(unexpected null/undefined values, messed properties bindings etc.) <br/> - Commercial license or GPL |
| Slint | - Internal language is compiled to native code <br/> - Live gui preview with Vscode/Vscodium without needing to use rust <br/> - Full rust solution - easy to compile/cross compile, minimal runtime requirements </br> - Static type checks in slint files | - Internal .slint language is more limited than QML <br/> - Out of bounds and similar errors are quietly being corrected instead printing error - this can lead to hard to debug problems <br/> - Only GPL is only available open-source license <br/> - Popup windows almost not exists <br/> - Internal widgets are almost not customizable and usually quite limited |
| Iced | - ~100% rust code - so compilation is simple </br> - Elm architecture - simple to understand | - Mostly maintained by one person - slows down fixing bugs and implementing new features </br> - GUI can be created only from rust code, which really is bad for creating complex GUIs(mostly due rust compile times) </br> - Docs are almost non-existent |
| Tauri | - Easy to create ui(at least for web developers) - uses html/css/js</br>- Quite portable | - Webview dependency - it is not really lightweight and can be hard to compile on some platforms and on Linux e.g. webRTC not working</br>- Cannot select directory - file chooser only can choose files - small thing but important for me</br>- Not very performant Rust <=> Javascript communication |
| Toolkit | Pros | Cons |
|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Gtk 4 | - Good Linux support </br> - Cambalache can be used to create graphically gui </br> - Good gtk4-rs bindings(but sometimes not really intuitive) | - Hard compilation/cross compilation and bundling all required libraries - mostly on windows </br> - Forcing the use of a specific gui creation style </br> - Strange crashes, not working basic features, etc.(again, mostly on windows) </br> - Forcing to use bugged/outdated but dynamically loaded version of libraries on linux (e.g. 4.6 on Ubuntu 22.04) - not all fixes are backported |
| Qt | - QML support - simplify creating of gui from code it is easy to use and powerful </br> - Very flexible framework <br/> - Typescript/javascript <=> qml interoperability </br> - Probably the most mature GUI library | - New and limited qt bindings <br/> - Hard to cross-compile <br/> - Very easy to create and use invalid state in QML(unexpected null/undefined values, messed properties bindings etc.) <br/> - Commercial license or GPL |
| Slint | - Internal language is compiled to native code <br/> - Live gui preview with Vscode/Vscodium without needing to use rust <br/> - Full rust solution - easy to compile/cross compile, minimal runtime requirements </br> - Static type checks in slint files | - Internal .slint language is more limited than QML <br/> - Out of bounds and similar errors are quietly being corrected instead printing error - this can lead to hard to debug problems <br/> - Only GPL is only available open-source license <br/> - Popup windows almost not exists <br/> - Internal widgets are almost not customizable and usually quite limited |
| Iced | - ~100% rust code - so compilation is simple </br> - Elm architecture - simple to understand | - Mostly maintained by one person - slows down fixing bugs and implementing new features </br> - GUI can be created only from rust code, which really is bad for creating complex GUIs(mostly due rust compile times) </br> - Docs are almost non-existent |
| Tauri | - Easy to create ui(at least for web developers) - uses html/css/js</br>- Quite portable | - Webview dependency - it is not really lightweight and can be hard to compile on some platforms and on Linux e.g. webRTC not working</br>- Cannot select directory - file chooser only can choose files - small thing but important for me</br>- Not very performant Rust <=> Javascript communication (less problematic with [Tauri 2](https://github.com/tauri-apps/tauri/pull/7170#issuecomment-1583279023) ) |

Since I don't have time to create really complex and good looking GUI, I needed a helper tool to create GUI not from
Rust(I don't want to use different language, because this will make communication with czkawka_core harder) so I decided
Expand Down
4 changes: 2 additions & 2 deletions krokiet/src/common.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(dead_code)] // TODO later remove
#![allow(dead_code)]
use std::path::PathBuf;

use crate::{CurrentTab, ExcludedDirectoriesModel, IncludedDirectoriesModel, MainListModel, MainWindow, Settings};
Expand Down Expand Up @@ -391,7 +391,7 @@ pub fn split_u64_into_i32s(value: u64) -> (i32, i32) {
}

pub fn connect_i32_into_u64(part1: i32, part2: i32) -> u64 {
((part1 as u64) << 32) | (part2 as u64 & 0xFFFFFFFF)
((part1 as u64) << 32) | (part2 as u64 & 0xFFFF_FFFF)
}

#[cfg(test)]
Expand Down
10 changes: 8 additions & 2 deletions krokiet/src/connect_delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,14 @@ fn remove_selected_items(items_to_remove: Vec<String>, active_tab: CurrentTab, r
items_to_remove
.into_par_iter()
.filter_map(|item| {
if let Err(e) = std::fs::remove_file(item) {
return Some(format!("Error while removing file: {e}"));
if remove_to_trash {
if let Err(e) = trash::delete(item) {
return Some(format!("Error while moving to trash: {e}"));
}
} else {
if let Err(e) = std::fs::remove_file(item) {
return Some(format!("Error while removing file: {e}"));
}
}
None
})
Expand Down
4 changes: 2 additions & 2 deletions krokiet/src/connect_show_preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub fn connect_show_preview(app: &MainWindow) {
let res = load_image(path);
if let Some((load_time, img)) = res {
let start_timer_convert_time = Instant::now();
let slint_image = convert_into_slint_image(img);
let slint_image = convert_into_slint_image(&img);
let convert_time = start_timer_convert_time.elapsed();

let start_set_time = Instant::now();
Expand Down Expand Up @@ -67,7 +67,7 @@ fn set_preview_visible(gui_state: &GuiState, preview: Option<&str>) {
}
}

fn convert_into_slint_image(img: DynamicImage) -> slint::Image {
fn convert_into_slint_image(img: &DynamicImage) -> slint::Image {
let image_buffer: ImageBufferRgba = img.to_rgba8();
let buffer = slint::SharedPixelBuffer::<slint::Rgba8Pixel>::clone_from_slice(image_buffer.as_raw(), image_buffer.width(), image_buffer.height());
slint::Image::from_rgba8(buffer)
Expand Down
1 change: 1 addition & 0 deletions krokiet/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#![allow(unknown_lints)] // May be disabled, but locally I use nightly clippy
#![allow(clippy::comparison_chain)]
#![allow(clippy::collapsible_if)]
#![allow(clippy::collapsible_else_if)]
#![allow(clippy::should_panic_without_expect)]
#![allow(clippy::struct_field_names)] // Generated code
#![allow(clippy::overly_complex_bool_expr)] // Generated code
Expand Down
2 changes: 1 addition & 1 deletion krokiet/src/model_operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn collect_full_path_from_model(items: &[MainListModel], active_tab: Current
.map(|item| {
let path = item.val_str.iter().nth(path_idx).unwrap();
let name = item.val_str.iter().nth(name_idx).unwrap();
format!("{}{}{}", path, MAIN_SEPARATOR, name)
format!("{path}{MAIN_SEPARATOR}{name}")
})
.collect::<Vec<_>>()
}
Expand Down

0 comments on commit 989c423

Please sign in to comment.