From 98590adbd1c19e0228f929513c4cbf69b5703531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mikrut?= Date: Thu, 19 Oct 2023 09:32:37 +0200 Subject: [PATCH] AB --- czkawka_slint_gui/Cargo.toml | 3 ++- czkawka_slint_gui/src/main.rs | 20 ++++++++++++++++--- czkawka_slint_gui/ui/main_window.slint | 17 ++++++++++------ .../ui/selectable_tree_view.slint | 11 ++++++---- 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/czkawka_slint_gui/Cargo.toml b/czkawka_slint_gui/Cargo.toml index 815bafd..e7b8978 100644 --- a/czkawka_slint_gui/Cargo.toml +++ b/czkawka_slint_gui/Cargo.toml @@ -13,6 +13,7 @@ build = "build.rs" [dependencies] slint = "1.2.2" rand = "0.8.5" +#czkawka_core = { version = "6.1.0", path = "../czkawka_core" } -[dev-dependencies] +[build-dependencies] slint-build = "1.2.2" \ No newline at end of file diff --git a/czkawka_slint_gui/src/main.rs b/czkawka_slint_gui/src/main.rs index beda760..996fba9 100644 --- a/czkawka_slint_gui/src/main.rs +++ b/czkawka_slint_gui/src/main.rs @@ -1,7 +1,21 @@ +use std::rc::Rc; +use slint::{Model, ModelRc, SharedString, StandardListViewItem, VecModel}; slint::include_modules!(); fn main() { - MainWindow::new().unwrap().run().unwrap(); -} + let app = MainWindow::new().unwrap();//.run().unwrap(); + let row_data: Rc>> = Rc::new(VecModel::default()); -slint::slint! {} + for r in 0..10000000 { + let items = VecModel::default(); + + for c in 0..3 { + items.push(slint::format!("Item {r}.{c}").into()); + } + + row_data.push(ModelRc::new(items)); + } + app.set_empty_folder_model(row_data.into()); + + app.run().unwrap(); +} \ No newline at end of file diff --git a/czkawka_slint_gui/ui/main_window.slint b/czkawka_slint_gui/ui/main_window.slint index 68696fe..0b5fcad 100644 --- a/czkawka_slint_gui/ui/main_window.slint +++ b/czkawka_slint_gui/ui/main_window.slint @@ -8,9 +8,16 @@ enum CurrentTab { export component MainWindow { in-out property active-tab; + in-out property <[[string]]> empty-folder-model: [ + ["kropkarz", "/Xd1", "24.10.2023"] , + ["witasphere", "/Xd1/Imagerren2", "25.11.1991"] , + ["lokkaler", "/Xd1/Vide2", "01.23.1911"] , +]; + + min-width: 200px; VerticalBox { HorizontalBox { - width: 600px; + // min-width: 600px; preferred-height: 300px; tab_bar := VerticalLayout { @@ -28,12 +35,10 @@ export component MainWindow { // TODO - using root.active-tab in visible property will not if root.active-tab == CurrentTab.EmptyFolders: SelectableTableView { + min-width: 200px; + columns: ["Selection", "Folder Name", "Path", "Modification Date"]; - values: [ - ["kropkarz", "/Xd1", "24.10.2023"] , - ["witasphere", "/Xd1/Imagerren2", "25.11.1991"] , - ["lokkaler", "/Xd1/Vide2", "01.23.1911"] , - ]; + values: empty-folder-model; } } HorizontalBox { diff --git a/czkawka_slint_gui/ui/selectable_tree_view.slint b/czkawka_slint_gui/ui/selectable_tree_view.slint index 234a476..3134924 100644 --- a/czkawka_slint_gui/ui/selectable_tree_view.slint +++ b/czkawka_slint_gui/ui/selectable_tree_view.slint @@ -11,7 +11,8 @@ export component SelectableTableView inherits Rectangle { padding: 5px; // Widgets HorizontalLayout { - padding: 5px; spacing: 5px; + padding: 5px; + spacing: 5px; vertical-stretch: 0; for title[idx] in root.columns : HorizontalLayout { width: root.column_sizes[idx]; @@ -32,8 +33,8 @@ export component SelectableTableView inherits Rectangle { moved => { if (self.pressed) { root.column_sizes[idx] += (self.mouse-x - self.pressed-x); - if (root.column_sizes[idx] < 0) { - root.column_sizes[idx] = 0; + if (root.column_sizes[idx] < 20px) { + root.column_sizes[idx] = 20px; } } } @@ -45,7 +46,8 @@ export component SelectableTableView inherits Rectangle { list_view:= ListView { for r[idx] in root.values : Rectangle { private property selected: false; - background: touch-area.has-hover ? (selected ? #333333 : #222222) : (selected ? #333333: #222222); + background: touch-area.has-hover ? (selected ? #cccccc : #dddddd) : (selected ? #cccccc: #dddddd); + // background: touch-area.has-hover ? (selected ? #333333 : #222222) : (selected ? #333333: #222222); touch_area:= TouchArea { clicked => { @@ -61,6 +63,7 @@ export component SelectableTableView inherits Rectangle { CheckBox { //min-width: 200px; width: root.column-sizes[0]; + // preferred-width: root.column-sizes[0]; } HorizontalLayout {