1
0
Fork 0
mirror of synced 2024-05-17 19:03:08 +12:00

Formatter

This commit is contained in:
Rafał Mikrut 2023-11-10 17:11:32 +01:00
parent 812164bce9
commit a0e151e5fe
10 changed files with 108 additions and 98 deletions

View file

@ -7,11 +7,9 @@ import {BottomPanelVisibility} from "common.slint";
export component VisibilityButton inherits Button {
in-out property <BottomPanelVisibility> button_visibility;
in-out property <BottomPanelVisibility> bottom_panel_visibility;
enabled: bottom_panel_visibility != button-visibility;
height: 30px;
width: 70px;
clicked => {
bottom-panel-visibility = button_visibility;
}
@ -21,7 +19,6 @@ export component ActionButtons inherits HorizontalLayout {
callback deleted;
callback scan_stopping;
callback scan_starting(CurrentTab);
in-out property <BottomPanelVisibility> bottom_panel_visibility: BottomPanelVisibility.Directories;
in-out property <bool> stop_requested: false;
in-out property <bool> scanning;
@ -29,8 +26,7 @@ export component ActionButtons inherits HorizontalLayout {
out property <int> name;
height: 30px;
spacing: 4px;
scan_button:= Button {
scan_button := Button {
height: parent.height;
enabled: !scanning;
text: "Scan";
@ -39,7 +35,8 @@ export component ActionButtons inherits HorizontalLayout {
root.scan_starting(active-tab);
}
}
stop_button:= Button {
stop_button := Button {
height: parent.height;
enabled: scanning && !stop_requested;
text: "Stop";
@ -53,7 +50,7 @@ export component ActionButtons inherits HorizontalLayout {
horizontal-stretch: 0.5;
}
delete_button:= Button {
delete_button := Button {
height: parent.height;
enabled: !scanning;
text: "Delete";
@ -61,7 +58,7 @@ export component ActionButtons inherits HorizontalLayout {
root.deleted();
}
}
Rectangle {
horizontal-stretch: 0.5;
}
@ -90,4 +87,4 @@ export component ActionButtons inherits HorizontalLayout {
text: "None";
}
}
}
}

View file

@ -7,7 +7,6 @@ import {Callabler} from "callabler.slint";
component DirectoriesPanel {
callback folder-choose-requested(bool);
callback show_manual_add_dialog(bool);
// Included directories
HorizontalLayout {
VerticalLayout {
@ -18,22 +17,26 @@ component DirectoriesPanel {
folder-choose-requested(true);
}
}
Button {
text: "Remove";
clicked => {
Callabler.remove_item_directories(true, included-list.current-item);
}
}
Button {
text: "Manual Add";
clicked => {
show_manual_add_dialog(true);
}
}
Rectangle {
vertical-stretch: 1.0;
}
}
VerticalLayout {
horizontal-stretch: 1.0;
Rectangle {
@ -41,6 +44,7 @@ component DirectoriesPanel {
text: "Included Directories";
}
}
included_list := StandardListView {
model: Settings.included-directories;
}
@ -55,22 +59,26 @@ component DirectoriesPanel {
folder-choose-requested(false);
}
}
Button {
text: "Remove";
clicked => {
Callabler.remove_item_directories(false, excluded-list.current-item);
}
}
Button {
text: "Manual Add";
clicked => {
show_manual_add_dialog(false);
}
}
Rectangle {
vertical-stretch: 1.0;
}
}
VerticalLayout {
horizontal-stretch: 1.0;
Rectangle {
@ -78,6 +86,7 @@ component DirectoriesPanel {
text: "Excluded Directories";
}
}
excluded_list := StandardListView {
model: Settings.excluded-directories;
}
@ -89,26 +98,26 @@ component TextErrorsPanel inherits TextEdit {
height: 20px;
read-only: true;
text <=> Settings.info_text;
}
export component BottomPanel {
in-out property <BottomPanelVisibility> bottom_panel_visibility: BottomPanelVisibility.Directories;
callback folder-choose-requested(bool);
callback show_manual_add_dialog(bool);
min-height: bottom-panel-visibility == BottomPanelVisibility.NotVisible ? 0px : 150px;
min-width: bottom-panel-visibility == BottomPanelVisibility.NotVisible ? 0px : 400px;
if bottom-panel-visibility == BottomPanelVisibility.Directories: DirectoriesPanel {
width: parent.width;
height: parent.height;
folder-choose-requested(included-directories) => {root.folder-choose-requested(included-directories)}
show_manual_add_dialog(included-directories) => {root.show_manual_add_dialog(included-directories)}
folder-choose-requested(included-directories) => {
root.folder-choose-requested(included-directories)
}
show_manual_add_dialog(included-directories) => {
root.show_manual_add_dialog(included-directories)
}
}
if bottom-panel-visibility == BottomPanelVisibility.TextErrors : TextErrorsPanel {
if bottom-panel-visibility == BottomPanelVisibility.TextErrors: TextErrorsPanel {
width: parent.width;
height: parent.height;
}

View file

@ -1,4 +1,4 @@
export global Callabler {
export global Callabler {
callback remove_item_directories(bool, int);
callback added_manual_directories(bool, string);
}
}

View file

@ -2,14 +2,12 @@ import { StyleMetrics } from "std-widgets.slint";
export global ColorPalette {
// Tabs at left side
in-out property<color> tab_selected_color: StyleMetrics.dark-color-scheme ? #353535 : #5e5e5e;
in-out property<color> tab_hovered_color: StyleMetrics.dark-color-scheme ? #49494926 : #80808014;
in-out property <color> tab_selected_color: StyleMetrics.dark-color-scheme ? #353535 : #5e5e5e;
in-out property <color> tab_hovered_color: StyleMetrics.dark-color-scheme ? #49494926 : #80808014;
// ListView
in-out property<color> list_view_normal_color: StyleMetrics.dark-color-scheme ? #222222 : #dddddd;
in-out property<color> list_view_normal_header_color: StyleMetrics.dark-color-scheme ? #111111 : #888888;
in-out property<color> list_view_normal_selected_header: StyleMetrics.dark-color-scheme ? #444444 : #cccccc;
in-out property <color> list_view_normal_color: StyleMetrics.dark-color-scheme ? #222222 : #dddddd;
in-out property <color> list_view_normal_header_color: StyleMetrics.dark-color-scheme ? #111111 : #888888;
in-out property <color> list_view_normal_selected_header: StyleMetrics.dark-color-scheme ? #444444 : #cccccc;
// Popup
in-out property<color> popup_background: StyleMetrics.dark-color-scheme ? #353535 : #5e5e5e;
}
in-out property <color> popup_background: StyleMetrics.dark-color-scheme ? #353535 : #5e5e5e;
}

View file

@ -7,50 +7,47 @@ component TabItem {
in-out property <CurrentTab> active-tab;
in property <string> text;
in property <CurrentTab> curr_tab;
Rectangle {
width: parent.width;
horizontal-stretch: 1.0;
background: touch-area.has-hover ? ColorPalette.tab-hovered-color : transparent;
touch_area:= TouchArea {
touch_area := TouchArea {
clicked => {
if (root.active-tab == root.curr-tab) {
return;
}
root.active-tab = root.curr-tab;
}
}
}
HorizontalLayout {
width: parent.width;
alignment: LayoutAlignment.end;
layout_rectangle := VerticalLayout {
empty_rectangle := Rectangle {
empty_rectangle := Rectangle { }
}
current_rectangle := Rectangle {
visible: (root.active-tab == root.curr-tab);
border-radius: 2px;
width: 5px;
height: 0px;
background: ColorPalette.tab_selected_color;
animate height {
animate height{
duration: 150ms;
easing: ease;
easing: ease;
}
}
empty_rectangle2 := Rectangle {
}
empty_rectangle2 := Rectangle { }
}
}
Text {
text: root.text;
width: parent.width;
horizontal-alignment: center;
}
states [
is-selected when root.active-tab == root.curr-tab: {
current_rectangle.height: layout_rectangle.height;
@ -65,7 +62,6 @@ export component LeftSidePanel {
in-out property <CurrentTab> active-tab;
in-out property <bool> scanning;
width: 120px;
VerticalLayout {
spacing: 20px;
Rectangle {
@ -75,6 +71,7 @@ export component LeftSidePanel {
source: @image-url("../icons/logo.png");
}
}
VerticalLayout {
// spacing: 3px;
alignment: center;
@ -86,6 +83,7 @@ export component LeftSidePanel {
active-tab <=> root.active-tab;
curr_tab: CurrentTab.EmptyFolders;
}
TabItem {
height: parent.element-size;
scanning: scanning;
@ -93,6 +91,7 @@ export component LeftSidePanel {
active-tab <=> root.active-tab;
curr_tab: CurrentTab.EmptyFiles;
}
TabItem {
height: parent.element-size;
scanning: scanning;
@ -101,6 +100,7 @@ export component LeftSidePanel {
curr_tab: CurrentTab.SimilarImages;
}
}
HorizontalLayout {
height: 20px;
alignment: end;
@ -110,4 +110,4 @@ export component LeftSidePanel {
}
}
}
}
}

View file

@ -7,45 +7,46 @@ import {MainListModel} from "common.slint";
export component MainList {
callback item_opened(string);
in-out property <CurrentTab> active-tab;
in-out property <[MainListModel]> empty_folder_model;
in-out property <[MainListModel]> empty_files_model;
in-out property <[MainListModel]> similar_images_model;
// TODO - using root.active-tab in visible property will not clear model
// TODO - using root.active-tab in visible property will not clear model
if root.active-tab == CurrentTab.EmptyFolders: SelectableTableView {
min-width: 200px;
columns: ["Selection", "Folder Name", "Path"];
last-column: "Modification Date";
column-sizes: [35px, 100px, 350px, 300px];
values <=> empty-folder-model;
parentPathIdx: 2;
fileNameIdx: 1;
item_opened(item) => {item_opened(item)}
item_opened(item) => {
item_opened(item)
}
}
if root.active-tab == CurrentTab.EmptyFiles: SelectableTableView {
min-width: 200px;
columns: ["Selection", "File Name", "Path"];
last-column: "Modification Date";
column-sizes: [35px, 100px, 350px, 100px];
values <=> empty-files-model;
parentPathIdx: 2;
fileNameIdx: 1;
item_opened(item) => {item_opened(item)}
item_opened(item) => {
item_opened(item)
}
}
if root.active-tab == CurrentTab.SimilarImages: SelectableTableView {
min-width: 200px;
columns: ["Selection", "File Name", "Path"];
last-column: "Modification Date";
column-sizes: [35px, 100px, 350px, 100px];
values <=> similar-images-model;
parentPathIdx: 2;
fileNameIdx: 1;
item_opened(item) => {item_opened(item)}
item_opened(item) => {
item_opened(item)
}
}
}
}

View file

@ -19,22 +19,18 @@ export component MainWindow inherits Window {
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 : {
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"]} ,
@ -44,12 +40,10 @@ export component MainWindow inherits Window {
];
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;
@ -65,20 +59,26 @@ export component MainWindow inherits Window {
empty_files_model <=> root.empty_files_model;
similar_images_model <=> root.similar_images_model;
item_opened(item) => {item_opened(item)}
item_opened(item) => {
item_opened(item)
}
}
if root.scanning: Progress {
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();}
deleted => {
root.deleted();
}
scan_stopping => {
text_summary.text = "Stopping scan, please wait...";
root.scan_stopping();
@ -88,15 +88,20 @@ export component MainWindow inherits Window {
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
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)}
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()
@ -107,12 +112,9 @@ export component MainWindow inherits Window {
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 {
@ -128,10 +130,12 @@ export component MainWindow inherits Window {
text: "Please add directories one per line";
horizontal-alignment: TextHorizontalAlignment.center;
}
TextEdit {
vertical-stretch: 1.0;
text <=> text-data;
}
HorizontalLayout {
min-height: 20px;
Button {
@ -142,6 +146,7 @@ export component MainWindow inherits Window {
popup-item.close();
}
}
Button {
text: "Cancel";
clicked => {
@ -153,7 +158,6 @@ export component MainWindow inherits Window {
}
}
}
}
scan_ended(scan_text) => {

View file

@ -9,12 +9,12 @@ export component Progress {
in-out property <ProgressToSend> progress_datas;
preferred-width: 400px;
preferred-height: 40px;
VerticalLayout {
Text {
text: progress-datas.step-name;
horizontal-alignment: TextHorizontalAlignment.center;
}
HorizontalLayout {
spacing: 5px;
VerticalLayout {
@ -23,11 +23,13 @@ export component Progress {
vertical-alignment: TextVerticalAlignment.center;
text: "Current Stage:";
}
Text {
vertical-alignment: TextVerticalAlignment.center;
text: "All Stages:";
}
}
VerticalLayout {
spacing: 5px;
VerticalLayout {
@ -38,25 +40,28 @@ export component Progress {
progress: progress_datas.current-progress / 100.0;
}
}
VerticalLayout {
alignment: LayoutAlignment.center;
ProgressIndicator {
height: 8px;
progress: progress_datas.all-progress / 100.0;
progress: progress_datas.all-progress / 100.0;
}
}
}
VerticalLayout {
spacing: 5px;
Text {
vertical-alignment: TextVerticalAlignment.center;
text: progress_datas.current-progress + "%";
text: progress_datas.current-progress + "%";
}
Text {
vertical-alignment: TextVerticalAlignment.center;
text: progress_datas.all-progress + "%";
text: progress_datas.all-progress + "%";
}
}
}
}
}
}

View file

@ -6,23 +6,17 @@ import {MainListModel} from "common.slint";
export component SelectableTableView inherits Rectangle {
callback item_opened(string);
in property <[string]> columns;
in property <string> last_column;
in-out property <[MainListModel]> values;
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 <[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;
forward-focus: focus_item;
// TODO not works
focus_item := FocusScope {
key-released(event) => {
@ -35,18 +29,20 @@ export component SelectableTableView inherits Rectangle {
padding: 5px;
forward-focus: focus-item;
HorizontalLayout {
padding: 5px;
padding: 5px;
spacing: 5px;
vertical-stretch: 0;
for title[idx] in root.columns : HorizontalLayout {
for title [idx] in root.columns: HorizontalLayout {
width: root.column-sizes[idx];
Text {
overflow: elide;
text: title;
}
Text { overflow: elide; text: title; }
Rectangle {
width: 1px;
background: gray;
forward-focus: focus-item;
TouchArea {
width: 5px;
x: (parent.width - self.width) / 2;
@ -69,18 +65,22 @@ export component SelectableTableView inherits Rectangle {
}
}
}
Text { overflow: elide; text: last-column; }
Text {
overflow: elide;
text: last-column;
}
}
list_view := ListView {
min-width: 100px;
forward-focus: focus-item;
for r[idx] in root.values : Rectangle {
for r [idx] in root.values: Rectangle {
border-radius: 5px;
forward-focus: focus-item;
height: 20px;
background: r.header-row ? ColorPalette.list_view_normal_header_color : (touch-area.has-hover ? (r.selected_row ? ColorPalette.list-view-normal-selected-header : ColorPalette.list_view_normal_color) : (r.selected_row ? ColorPalette.list-view-normal-selected-header: ColorPalette.list_view_normal_color));
touch_area:= TouchArea {
background: r.header-row ? ColorPalette.list_view_normal_header_color : (touch-area.has-hover ? (r.selected_row ? ColorPalette.list-view-normal-selected-header : ColorPalette.list_view_normal_color) : (r.selected_row ? ColorPalette.list-view-normal-selected-header : ColorPalette.list_view_normal_color));
touch_area := TouchArea {
forward-focus: focus-item;
clicked => {
if (!r.header_row) {
@ -109,7 +109,6 @@ export component SelectableTableView inherits Rectangle {
HorizontalLayout {
forward-focus: focus-item;
CheckBox {
visible: !r.header-row;
checked: r.checked && !r.header-row;
@ -122,14 +121,12 @@ export component SelectableTableView inherits Rectangle {
HorizontalLayout {
spacing: 5px;
for f[idx] in r.val : Text {
for f [idx] in r.val: Text {
width: root.column-sizes[idx + 1];
text: f;
font-size: 12px;
forward-focus: focus-item;
vertical-alignment: center;
overflow: elide;
}
}
@ -137,4 +134,4 @@ export component SelectableTableView inherits Rectangle {
}
}
}
}
}

View file

@ -1,6 +1,5 @@
export global Settings {
export global Settings {
in-out property <[StandardListViewItem]> included_directories: [{text: "ABCD"}, {text: "BCDA"}];
in-out property <[StandardListViewItem]> excluded_directories: [{text: "ABCD"}, {text: "BCDA"}, {text: "CDFFF"}];
in-out property <string> info_text: "Nothing to report";
}
}