1
0
Fork 0
mirror of synced 2024-05-17 19:03:08 +12:00
This commit is contained in:
Rafał Mikrut 2023-10-19 09:32:37 +02:00
parent c753c06620
commit 98590adbd1
4 changed files with 37 additions and 14 deletions

View file

@ -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"

View file

@ -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<VecModel<ModelRc<SharedString>>> = 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();
}

View file

@ -8,9 +8,16 @@ enum CurrentTab {
export component MainWindow {
in-out property <CurrentTab> 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 {

View file

@ -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 <bool> 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 {