1
0
Fork 0
mirror of synced 2024-05-17 19:03:08 +12:00
This commit is contained in:
Rafał Mikrut 2023-10-29 13:19:28 +01:00
parent 4663f4ef00
commit d367f33e40
6 changed files with 88 additions and 16 deletions

View file

@ -17,8 +17,6 @@ build = "build.rs"
# Try to use only needed features from https://github.com/slint-ui/slint/blob/master/api/rs/slint/Cargo.toml#L23-L31
slint = { git = "https://github.com/slint-ui/slint.git", default-features = false, features = ["std",
"backend-winit",
"renderer-femtovg",
"renderer-software",
"accessibility",
"compat-1-2"
] }
@ -35,7 +33,7 @@ handsome_logger = "0.8.0"
slint-build = { git = "https://github.com/slint-ui/slint.git" }
[features]
default = ["winit_femtovg"]
default = ["winit_femtovg", "winit_software"]
skia_opengl = ["slint/renderer-skia-opengl"]
skia_vulkan = ["slint/renderer-skia-vulkan"]
software = ["slint/renderer-software"]

View file

@ -2,19 +2,68 @@
NAME_TODO is new Czkawka frontend written in Slint(written mostly in Rust) in opposite to Gtk 4 frontend which uses mostly C code.
Different
Different toolkit means different look, limitations and features, so you should not expect same features like in Gtk 4 frontend.
## Requirements
Slint version of app should not have any special runtime requirements - it should work on almost any OpenGL 3 capable device.
Slint version of app should not have any special runtime requirements - it should work on almost any OpenGL ES 2 capable device.
Alternatively, it can be run with software rendering.
## Compilation
Default compilation is done by `cargo build --release`.
Default compilation is done by `cargo build --release` and should work on most systems.
All dependencies should be handled by cargo, except windows where you need to install m.
You need the latest available version of Rust to compile it, because NAME_TODO aims to support the latest slint verions,
that should provide best experience(fixed more bugs/new features).
The only exception is building skia frontend, that require
The only exception is building non default skia renderer, that require on windows msvc compiler(not sure how to exactly install it).
Also skia renderer is written in C++ and uses on platforms like x86_64 and arm64 prebuild binaries, so if you are using different architecture, this library will be build from source, which can take a lot of time and require additional dependencies.
## Additional Renderers
By default, only femtovg(opengl) and software renderer are enabled, but you can enable more renderers by compiling app with additional features.
Most of the users will want to use app with windowing system/compositor, so features starting with `winit` in name are recommended.
E.g.
```
cargo build --release --features "winit_skia_opengl"
cargo build --release --features "winit_software"
```
to run app with different renderers you need to use it, by adding `SLINT_BACKEND` environment
```
SLINT_BACKEND=winit-femtovg ./target/release/czkawka_slint_gui
SLINT_BACKEND=software ./target/release/czkawka_slint_gui
SLINT_BACKEND=skia ./target/release/czkawka_slint_gui # This uses now opengl - https://github.com/slint-ui/slint/discussions/3799
```
when you will use invalid/non-existing backend, app will show warning
```
slint winit: unrecognized renderer skia, falling back to FemtoVG
```
to check what is really used, add `SLINT_DEBUG_PERFORMANCE=refresh_lazy,console,overlay` env
```
SLINT_DEBUG_PERFORMANCE=refresh_lazy,console,overlay cargo run
```
should print something like
```
Slint: Build config: debug; Backend: software
```
## How to help?
- Suggesting possible design changes in the gui - of course, they should be possible to be simply implemented in the slint keeping in mind the performance aspect as well
- Modifying user interface - gui is written in simple language similar to qml - [slint live preview example](https://slint.dev/releases/1.2.2/editor/?load_demo=examples/printerdemo/ui/printerdemo.slint)
- Improving libraries used by NAME_TODO e.g. czkawka_core, image-rs etc.
- Improving app rust code
## Why Slint?
There are multiple reasons why I decided to use Slint as toolkit for NAME_TODO 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/> - Big cross compilation problems and hard to setup on non windows platforms <br/> - Very easy to create and use invalid state in QML(unexpected null/undefined values 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 | - Internal .slint language is more limited than QML(javascript flexibility is big pl) <br/> - Out of bounds and similar errors are quietly being corrected instead printing error - this can lead to hard to debug problems <br/> - Commercial license or GPL(is available also different ) |
| 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) and this is also </br> - Docs are almost non-existent |
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 to not look at Iced which only allows to create GUI from Rust.
GTK and QT also I throw away due cross compilation problems caused mostly by using C/C++, so only Slint left.

View file

@ -17,12 +17,13 @@ use crate::connect_scan::connect_scan_button;
use crate::connect_progress_receiver::connect_progress_gathering;
use crate::connect_stop::connect_stop_button;
use czkawka_core::common::setup_logger;
use czkawka_core::common_dir_traversal::ProgressData;
use slint::{ModelRc, VecModel};
slint::include_modules!();
fn main() {
handsome_logger::init().unwrap();
setup_logger(false);
let app = MainWindow::new().unwrap(); //.run().unwrap();

View file

@ -8,7 +8,6 @@ component TabItem {
in property <string> text;
in property <CurrentTab> curr_tab;
Rectangle {
width: parent.width;
horizontal-stretch: 1.0;
@ -17,6 +16,10 @@ component TabItem {
touch_area:= TouchArea {
clicked => {
if (root.active-tab == root.curr-tab) {
return;
}
root.active-tab = root.curr-tab;
}
}
@ -24,10 +27,24 @@ component TabItem {
HorizontalLayout {
width: parent.width;
alignment: LayoutAlignment.end;
Rectangle {
visible: (root.active-tab == root.curr-tab);
width: 5px;
background: ColorPalette.tab_selected_color;
layout_rectangle := VerticalLayout {
empty_rectangle := Rectangle {
}
current_rectangle := Rectangle {
visible: (root.active-tab == root.curr-tab);
border-radius: 2px;
width: 5px;
height: 0px;
background: ColorPalette.tab_selected_color;
animate height {
duration: 150ms;
easing: ease;
}
}
empty_rectangle2 := Rectangle {
}
}
}
Text {
@ -35,6 +52,14 @@ component TabItem {
width: parent.width;
horizontal-alignment: center;
}
states [
is-selected when root.active-tab == root.curr-tab: {
current_rectangle.height: layout_rectangle.height;
}
is-not-selected when root.active-tab != root.curr-tab: {
current_rectangle.height: 0px;
}
]
}
export component LeftSidePanel {

View file

@ -7,7 +7,6 @@ import { ActionButtons } from "action_buttons.slint";
import { Progress } from "progress.slint";
import {MainListModel} from "common.slint";
export component MainWindow inherits Window {
callback deleted;
callback scan_stopping;

View file

@ -76,7 +76,7 @@ export component SelectableTableView inherits Rectangle {
forward-focus: focus-item;
for r[idx] in root.values : Rectangle {
border-radius: 20px;
border-radius: 5px;
forward-focus: focus-item;
height: 20px;
background: r.header-row ? ColorPalette.list_view_normal_header_color : (touch-area.has-hover ? (r.selected_row ? ColorPalette.list-view-normal-selected-header : ColorPalette.list_view_normal_color) : (r.selected_row ? ColorPalette.list-view-normal-selected-header: ColorPalette.list_view_normal_color));