1
0
Fork 0
mirror of synced 2024-06-01 18:19:46 +12:00
czkawka/krokiet/ui/main_window.slint
2023-11-10 16:49:54 +01:00

165 lines
6.2 KiB
Plaintext

import { Button, VerticalBox ,TextEdit, HorizontalBox, TabWidget, ListView, StandardListView, StandardTableView, CheckBox, LineEdit} from "std-widgets.slint";
import {SelectableTableView} from "selectable_tree_view.slint";
import {LeftSidePanel} from "left_side_panel.slint";
import {MainList} from "main_lists.slint";
import {CurrentTab, ProgressToSend} from "common.slint";
import { ActionButtons } from "action_buttons.slint";
import { Progress } from "progress.slint";
import {MainListModel} from "common.slint";
import {Settings} from "settings.slint";
import {Callabler} from "callabler.slint";
import { BottomPanel } from "bottom_panel.slint";
import {ColorPalette} from "color_palette.slint";
export {Settings, Callabler}
export component MainWindow inherits Window {
callback deleted;
callback scan_stopping;
callback scan_starting(CurrentTab);
callback item_opened(string);
callback folder-choose-requested(bool);
callback scan_ended(string);
min-width: 300px;
preferred-width: 800px;
min-height: 300px;
preferred-height: 600px;
in-out property <bool> stop_requested: false;
in-out property <bool> scanning: false;
in-out property <ProgressToSend> progress_datas : {
current_progress: 15,
all_progress: 20,
step_name: "Cache",
};
in-out property <CurrentTab> active-tab: CurrentTab.EmptyFolders;
in-out property <[MainListModel]> empty_folder_model: [
{checked: false, selected_row: false, header_row: true, val: ["kropkarz", "/Xd1", "24.10.2023"]} ,
{checked: false, selected_row: false, header_row: false, val: ["witasphere", "/Xd1/Imagerren2", "25.11.1991"]} ,
{checked: false, selected_row: false, header_row: false, val: ["witasphere", "/Xd1/Imagerren2", "25.11.1991"]} ,
{checked: true, selected_row: false, header_row: false, val: ["lokkaler", "/Xd1/Vide2", "01.23.1911"]}
];
in-out property <[MainListModel]> empty_files_model: [];
in-out property <[MainListModel]> similar_images_model: [];
VerticalBox {
HorizontalBox {
vertical-stretch: 1.0;
preferred-height: 300px;
LeftSidePanel {
horizontal-stretch: 0.0;
scanning <=> root.scanning;
active-tab <=> root.active-tab;
}
VerticalLayout {
horizontal-stretch: 1.0;
MainList {
vertical-stretch: 1.0;
active-tab <=> root.active-tab;
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)}
}
if root.scanning: Progress {
horizontal-stretch: 0.0;
progress_datas <=> root.progress_datas;
}
}
}
action_buttons := ActionButtons {
vertical-stretch: 0.0;
scanning <=> root.scanning;
active-tab <=> root.active-tab;
stop_requested <=> root.stop-requested;
deleted => {root.deleted();}
scan_stopping => {
text_summary.text = "Stopping scan, please wait...";
root.scan_stopping();
}
scan_starting(item) => {
text-summary.text = "Searching...";
root.scan_starting(item);
}
}
text_summary := LineEdit {
read-only: true;
}
bottom_panel := BottomPanel {
property <bool> included-directories; // TODO why cannot set popup_item property? Strange limitation
bottom-panel-visibility <=> action_buttons.bottom-panel-visibility;
vertical-stretch: 0.0;
folder-choose-requested(included-directories) => {root.folder-choose-requested(included-directories)}
show_manual_add_dialog(included-directories) => {
self.included-directories = included-directories;
popup-item.show()
}
}
}
popup_item := PopupWindow {
height: root.height;
width: root.width;
property <bool> included_directories;
private property <string> text_data;
close-on-click: false;
HorizontalLayout {
alignment: LayoutAlignment.center;
VerticalLayout {
alignment: LayoutAlignment.center;
Rectangle {
clip: true;
width: popup_item.width - 20px;
height: popup_item.height - 20px;
border-radius: 20px;
background: ColorPalette.popup_background;
VerticalLayout {
Text {
text: "Please add directories one per line";
horizontal-alignment: TextHorizontalAlignment.center;
}
TextEdit {
vertical-stretch: 1.0;
text <=> text-data;
}
HorizontalLayout {
min-height: 20px;
Button {
enabled: text-data != "";
text: "OK";
clicked => {
Callabler.added_manual_directories(bottom-panel.included-directories, text_data);
popup-item.close();
}
}
Button {
text: "Cancel";
clicked => {
popup-item.close();
}
}
}
}
}
}
}
}
scan_ended(scan_text) => {
text-summary.text = scan_text;
root.scanning = false;
root.stop_requested = false;
}
}