1
0
Fork 0
mirror of synced 2024-10-01 01:27:17 +13:00
czkawka/krokiet/ui/main_window.slint

165 lines
6.2 KiB
Text
Raw Normal View History

2023-11-08 09:52:43 +13:00
import { Button, VerticalBox ,TextEdit, HorizontalBox, TabWidget, ListView, StandardListView, StandardTableView, CheckBox, LineEdit} from "std-widgets.slint";
2023-10-18 08:31:08 +13:00
import {SelectableTableView} from "selectable_tree_view.slint";
2023-10-21 19:36:56 +13:00
import {LeftSidePanel} from "left_side_panel.slint";
2023-10-22 22:32:13 +13:00
import {MainList} from "main_lists.slint";
2023-10-23 09:12:59 +13:00
import {CurrentTab, ProgressToSend} from "common.slint";
2023-10-22 22:32:13 +13:00
import { ActionButtons } from "action_buttons.slint";
2023-10-23 09:12:59 +13:00
import { Progress } from "progress.slint";
2023-10-29 07:08:14 +13:00
import {MainListModel} from "common.slint";
2023-11-08 09:52:43 +13:00
import {Settings} from "settings.slint";
import {Callabler} from "callabler.slint";
2023-11-02 04:36:38 +13:00
import { BottomPanel } from "bottom_panel.slint";
2023-11-08 09:52:43 +13:00
import {ColorPalette} from "color_palette.slint";
2023-11-02 04:36:38 +13:00
2023-11-08 09:52:43 +13:00
export {Settings, Callabler}
2023-10-29 07:08:14 +13:00
2023-10-21 19:36:56 +13:00
export component MainWindow inherits Window {
2023-10-22 10:33:29 +13:00
callback deleted;
2023-10-27 07:57:17 +13:00
callback scan_stopping;
callback scan_starting(CurrentTab);
2023-10-22 23:18:41 +13:00
callback item_opened(string);
2023-11-02 09:52:25 +13:00
callback folder-choose-requested(bool);
2023-10-23 09:12:59 +13:00
2023-11-11 04:49:54 +13:00
callback scan_ended(string);
2023-10-27 07:57:17 +13:00
2023-10-22 10:33:29 +13:00
min-width: 300px;
2023-11-05 22:01:37 +13:00
preferred-width: 800px;
2023-10-22 22:32:13 +13:00
min-height: 300px;
preferred-height: 600px;
2023-10-21 19:36:56 +13:00
2023-10-27 07:57:17 +13:00
in-out property <bool> stop_requested: false;
2023-10-21 19:36:56 +13:00
in-out property <bool> scanning: false;
2023-10-23 09:12:59 +13:00
in-out property <ProgressToSend> progress_datas : {
current_progress: 15,
all_progress: 20,
step_name: "Cache",
};
2023-10-21 19:36:56 +13:00
in-out property <CurrentTab> active-tab: CurrentTab.EmptyFolders;
2023-10-29 07:08:14 +13:00
in-out property <[MainListModel]> empty_folder_model: [
2023-10-21 19:36:56 +13:00
{checked: false, selected_row: false, header_row: true, val: ["kropkarz", "/Xd1", "24.10.2023"]} ,
2023-10-22 10:33:29 +13:00
{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"]} ,
2023-10-21 19:36:56 +13:00
{checked: true, selected_row: false, header_row: false, val: ["lokkaler", "/Xd1/Vide2", "01.23.1911"]}
];
2023-10-29 07:08:14 +13:00
in-out property <[MainListModel]> empty_files_model: [];
in-out property <[MainListModel]> similar_images_model: [];
2023-10-21 19:36:56 +13:00
2023-10-18 08:31:08 +13:00
VerticalBox {
HorizontalBox {
2023-10-22 22:32:13 +13:00
vertical-stretch: 1.0;
2023-10-18 08:31:08 +13:00
preferred-height: 300px;
2023-10-21 19:36:56 +13:00
LeftSidePanel {
2023-10-22 22:32:13 +13:00
horizontal-stretch: 0.0;
scanning <=> root.scanning;
2023-10-21 19:36:56 +13:00
active-tab <=> root.active-tab;
2023-10-18 08:31:08 +13:00
}
2023-10-23 09:12:59 +13:00
VerticalLayout {
2023-10-22 22:32:13 +13:00
horizontal-stretch: 1.0;
2023-10-23 09:12:59 +13:00
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)}
}
2023-10-27 07:57:17 +13:00
if root.scanning: Progress {
2023-10-23 09:12:59 +13:00
horizontal-stretch: 0.0;
progress_datas <=> root.progress_datas;
}
2023-10-21 19:36:56 +13:00
}
2023-10-18 08:31:08 +13:00
}
2023-11-02 05:47:45 +13:00
action_buttons := ActionButtons {
2023-10-22 22:32:13 +13:00
vertical-stretch: 0.0;
scanning <=> root.scanning;
active-tab <=> root.active-tab;
2023-10-27 07:57:17 +13:00
stop_requested <=> root.stop-requested;
2023-10-22 22:32:13 +13:00
deleted => {root.deleted();}
2023-10-28 07:07:36 +13:00
scan_stopping => {
text_summary.text = "Stopping scan, please wait...";
root.scan_stopping();
}
scan_starting(item) => {
text-summary.text = "Searching...";
root.scan_starting(item);
}
2023-10-27 07:57:17 +13:00
}
2023-10-28 07:07:36 +13:00
text_summary := LineEdit {
2023-10-27 07:57:17 +13:00
read-only: true;
2023-10-18 08:31:08 +13:00
}
2023-11-03 06:29:38 +13:00
bottom_panel := BottomPanel {
2023-11-08 09:52:43 +13:00
property <bool> included-directories; // TODO why cannot set popup_item property? Strange limitation
2023-11-02 05:47:45 +13:00
bottom-panel-visibility <=> action_buttons.bottom-panel-visibility;
2023-11-02 04:36:38 +13:00
vertical-stretch: 0.0;
2023-11-02 09:52:25 +13:00
folder-choose-requested(included-directories) => {root.folder-choose-requested(included-directories)}
2023-11-08 09:52:43 +13:00
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;
2023-11-11 04:49:54 +13:00
background: ColorPalette.popup_background;
2023-11-08 09:52:43 +13:00
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();
}
}
}
}
}
}
}
2023-10-18 08:31:08 +13:00
}
2023-10-27 07:57:17 +13:00
2023-11-11 04:49:54 +13:00
scan_ended(scan_text) => {
text-summary.text = scan_text;
2023-10-27 07:57:17 +13:00
root.scanning = false;
root.stop_requested = false;
}
2023-10-18 08:31:08 +13:00
}