Added select
This commit is contained in:
parent
8939d514bf
commit
305af6a391
0
krokiet/src/connect_select.rs
Normal file
0
krokiet/src/connect_select.rs
Normal file
|
@ -22,7 +22,12 @@ pub fn connect_show_preview(app: &MainWindow) {
|
|||
let active_tab = gui_state.get_active_tab();
|
||||
|
||||
if active_tab == CurrentTab::SimilarImages && !settings.get_similar_images_show_image_preview() {
|
||||
gui_state.set_preview_visible(false);
|
||||
set_preview_visible(&gui_state, None);
|
||||
return;
|
||||
}
|
||||
|
||||
// Do not load the same image again
|
||||
if image_path == gui_state.get_preview_image_path() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -42,13 +47,23 @@ pub fn connect_show_preview(app: &MainWindow) {
|
|||
"Loading image took: {:?}, converting image took: {:?}, setting image took: {:?}",
|
||||
load_time, convert_time, set_time
|
||||
);
|
||||
gui_state.set_preview_visible(true);
|
||||
set_preview_visible(&gui_state, Some(image_path.as_str()));
|
||||
} else {
|
||||
gui_state.set_preview_visible(false);
|
||||
set_preview_visible(&gui_state, None);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn set_preview_visible(gui_state: &GuiState, preview: Option<&str>) {
|
||||
if let Some(preview) = preview {
|
||||
gui_state.set_preview_image_path(preview.into());
|
||||
gui_state.set_preview_visible(true);
|
||||
} else {
|
||||
gui_state.set_preview_image_path("".into());
|
||||
gui_state.set_preview_visible(false);
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
|
|
|
@ -42,6 +42,7 @@ mod connect_directories_changes;
|
|||
mod connect_open;
|
||||
mod connect_progress_receiver;
|
||||
mod connect_scan;
|
||||
mod connect_select;
|
||||
mod connect_show_preview;
|
||||
mod connect_stop;
|
||||
mod connect_translation;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { SelectMode } from "common.slint";
|
||||
|
||||
export global Callabler {
|
||||
// Bottom panel operations
|
||||
callback remove_item_directories(bool);
|
||||
|
@ -7,7 +9,7 @@ export global Callabler {
|
|||
callback item_opened(string);
|
||||
|
||||
callback delete_selected_items();
|
||||
// callback ();
|
||||
callback select_items(SelectMode);
|
||||
|
||||
// Preview
|
||||
callback load_image_preview(string);
|
||||
|
|
|
@ -38,4 +38,10 @@ export struct IncludedDirectoriesModel {
|
|||
export struct ExcludedDirectoriesModel {
|
||||
path: string,
|
||||
selected_row: bool,
|
||||
}
|
||||
|
||||
export enum SelectMode {
|
||||
SelectAll,
|
||||
UnselectAll,
|
||||
InvertSelection
|
||||
}
|
|
@ -8,6 +8,7 @@ export global GuiState {
|
|||
in-out property <string> info_text: "Nothing to report";
|
||||
in-out property <bool> preview_visible;
|
||||
in-out property <image> preview_image;
|
||||
in-out property <string> preview_image_path;
|
||||
|
||||
in-out property <float> maximum_threads: 40;
|
||||
|
||||
|
|
|
@ -79,6 +79,7 @@ export component ExcludedDirectories {
|
|||
VerticalLayout {
|
||||
HorizontalLayout {
|
||||
spacing: 5px;
|
||||
padding-left: 5px;
|
||||
Text {
|
||||
text: "Path";
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ export component PopupSelectResults inherits Rectangle {
|
|||
Rectangle {
|
||||
width: parent.width;
|
||||
height: parent.height;
|
||||
border-radius: 5px;
|
||||
background: ColorPalette.popup_background;
|
||||
VerticalLayout {
|
||||
for i in model: Button {
|
||||
|
|
Loading…
Reference in a new issue