Opening items
This commit is contained in:
parent
7e7a603f4c
commit
fbe0295f6d
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1329,6 +1329,7 @@ version = "6.1.0"
|
|||
dependencies = [
|
||||
"chrono",
|
||||
"czkawka_core",
|
||||
"open",
|
||||
"rand",
|
||||
"slint",
|
||||
"slint-build",
|
||||
|
|
|
@ -16,6 +16,7 @@ slint = { git = "https://github.com/slint-ui/slint.git", branch = "olivier/fix-3
|
|||
rand = "0.8.5"
|
||||
czkawka_core = { version = "6.1.0", path = "../czkawka_core" }
|
||||
chrono = "0.4.31"
|
||||
open="5.0.0"
|
||||
|
||||
[build-dependencies]
|
||||
#slint-build = "1.2.2"
|
||||
|
|
15
czkawka_slint_gui/src/connect_open.rs
Normal file
15
czkawka_slint_gui/src/connect_open.rs
Normal file
|
@ -0,0 +1,15 @@
|
|||
use crate::MainWindow;
|
||||
use slint::{ComponentHandle, Model, ModelRc, SharedString, VecModel};
|
||||
use std::borrow::BorrowMut;
|
||||
|
||||
pub fn connect_open_items(app: &MainWindow) {
|
||||
app.on_item_opened(move |path| {
|
||||
match open::that(&*path) {
|
||||
Ok(_) => {}
|
||||
Err(e) => {
|
||||
eprintln!("Failed to open file: {}", e);
|
||||
}
|
||||
};
|
||||
// TODO - this should be added to line edit
|
||||
});
|
||||
}
|
|
@ -1,10 +1,12 @@
|
|||
mod connect_delete;
|
||||
mod connect_open;
|
||||
mod connect_scan;
|
||||
|
||||
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 slint::{ModelRc, SharedString, VecModel};
|
||||
|
@ -17,6 +19,7 @@ fn main() {
|
|||
|
||||
connect_delete_button(&app);
|
||||
connect_scan_button(&app);
|
||||
connect_open_items(&app);
|
||||
|
||||
app.run().unwrap();
|
||||
}
|
||||
|
|
|
@ -2,4 +2,9 @@ export enum CurrentTab {
|
|||
EmptyFolders,
|
||||
EmptyFiles,
|
||||
SimilarImages,
|
||||
}
|
||||
|
||||
export enum TypeOfOpenedItem {
|
||||
CurrentItem,
|
||||
ParentItem,
|
||||
}
|
|
@ -1,9 +1,10 @@
|
|||
import { Button, VerticalBox , HorizontalBox, TabWidget, ListView, StandardListView, StandardTableView, CheckBox} from "std-widgets.slint";
|
||||
import {SelectableTableView} from "selectable_tree_view.slint";
|
||||
import {LeftSidePanel} from "left_side_panel.slint";
|
||||
import {CurrentTab} from "common.slint";
|
||||
import {CurrentTab, TypeOfOpenedItem} from "common.slint";
|
||||
|
||||
export component MainList {
|
||||
callback item_opened(string);
|
||||
in-out property <CurrentTab> active-tab;
|
||||
|
||||
in-out property <[{checked: bool, header_row: bool, selected_row: bool, val:[string]}]> empty_folder_model;
|
||||
|
@ -18,6 +19,9 @@ export component MainList {
|
|||
last-column: "Modification Date";
|
||||
column-sizes: [30px, 100px, 100px, 100px];
|
||||
values <=> empty-folder-model;
|
||||
parentPathIdx: 2;
|
||||
fileNameIdx: 1;
|
||||
item_opened(item) => {item_opened(item)}
|
||||
}
|
||||
if root.active-tab == CurrentTab.EmptyFiles: SelectableTableView {
|
||||
min-width: 200px;
|
||||
|
@ -26,6 +30,9 @@ export component MainList {
|
|||
last-column: "Modification Date";
|
||||
column-sizes: [30px, 100px, 100px, 100px];
|
||||
values <=> empty-files-model;
|
||||
parentPathIdx: 2;
|
||||
fileNameIdx: 1;
|
||||
item_opened(item) => {item_opened(item)}
|
||||
}
|
||||
if root.active-tab == CurrentTab.SimilarImages: SelectableTableView {
|
||||
min-width: 200px;
|
||||
|
@ -34,5 +41,8 @@ export component MainList {
|
|||
last-column: "Modification Date";
|
||||
column-sizes: [30px, 100px, 100px, 100px];
|
||||
values <=> similar-images-model;
|
||||
parentPathIdx: 2;
|
||||
fileNameIdx: 1;
|
||||
item_opened(item) => {item_opened(item)}
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ import { ActionButtons } from "action_buttons.slint";
|
|||
export component MainWindow inherits Window {
|
||||
callback deleted;
|
||||
callback scanned(CurrentTab);
|
||||
callback item_opened(string);
|
||||
min-width: 300px;
|
||||
preferred-width: 1024px;
|
||||
min-height: 300px;
|
||||
|
@ -68,6 +69,8 @@ export component MainWindow inherits Window {
|
|||
empty_folder_model <=> root.empty_folder_model;
|
||||
empty_files_model <=> root.empty_files_model;
|
||||
similar_images_model <=> root.similar_images_model;
|
||||
|
||||
item_opened(item) => {item_opened(item)}
|
||||
}
|
||||
}
|
||||
ActionButtons {
|
||||
|
|
|
@ -1,14 +1,21 @@
|
|||
import { Button, VerticalBox , HorizontalBox, TabWidget, ListView, StandardListView, StandardTableView, CheckBox} from "std-widgets.slint";
|
||||
import {TypeOfOpenedItem} from "common.slint";
|
||||
|
||||
export component SelectableTableView inherits Rectangle {
|
||||
callback item_opened(string);
|
||||
|
||||
in property <[string]> columns;
|
||||
in property <string> last_column;
|
||||
in-out property <[{checked: bool, header_row: bool, selected_row: bool, val:[string]}]> values;
|
||||
|
||||
in-out property <[length]> column_sizes: [200px, 100px, 100px, 100px];
|
||||
in-out property <[length]> column_sizes;
|
||||
private property <[length]> real_sizes: [0px,0px,0px,0px,0px,0px,0px,0px,0px,0px,0px,0px,0px,0px,0px,0px,0px,0px];
|
||||
private property <int> column_number: column-sizes.length + 1;
|
||||
|
||||
// This idx, starts from zero, but since first is always a checkbox, and is not in model.val values, remove 1 from idx
|
||||
in-out property <int> parentPathIdx;
|
||||
in-out property <int> fileNameIdx;
|
||||
|
||||
in-out property <int> selected_item: -1;
|
||||
|
||||
VerticalBox {
|
||||
|
@ -74,6 +81,14 @@ export component SelectableTableView inherits Rectangle {
|
|||
}
|
||||
}
|
||||
}
|
||||
pointer-event(event) => {
|
||||
// TODO this should be clicked by double-click
|
||||
if (event.button == PointerEventButton.right && event.kind == PointerEventKind.up) {
|
||||
root.item_opened(r.val[root.parentPathIdx - 1])
|
||||
} else if (event.button == PointerEventButton.middle && event.kind == PointerEventKind.up) {
|
||||
root.item_opened(r.val[root.parentPathIdx - 1] + "/" + r.val[root.fileNameIdx - 1])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalLayout {
|
||||
|
|
Loading…
Reference in a new issue