From 48c1909fb0352dbf964a04a0c8fdba2d4721a44a Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Thu, 19 Dec 2024 20:03:45 +0100 Subject: [PATCH] live-preview: Remember filter settings in selection popup (#7178) --- tools/lsp/ui/components/selection-popup.slint | 57 ++++++++++++++----- 1 file changed, 43 insertions(+), 14 deletions(-) diff --git a/tools/lsp/ui/components/selection-popup.slint b/tools/lsp/ui/components/selection-popup.slint index 55918ebe4d3..b3ec4347506 100644 --- a/tools/lsp/ui/components/selection-popup.slint +++ b/tools/lsp/ui/components/selection-popup.slint @@ -11,28 +11,28 @@ component FilterList { public function close() { pop.close(); } out property filter: { - if (!self.lcb && !self.icb && self.ocb) { + if (!self.filter-layout && !self.filter-interactive && self.filter-other) { return SelectionStackFilter.Others; - } else if (!self.lcb && self.icb && !self.ocb) { + } else if (!self.filter-layout && self.filter-interactive && !self.filter-other) { return SelectionStackFilter.Interactive; - } else if (!self.lcb && self.icb && self.ocb) { + } else if (!self.filter-layout && self.filter-interactive && self.filter-other) { return SelectionStackFilter.InteractiveAndOthers; - } else if (self.lcb && !self.icb && !self.ocb) { + } else if (self.filter-layout && !self.filter-interactive && !self.filter-other) { return SelectionStackFilter.Layouts; - } else if (self.lcb && !self.icb && self.ocb) { + } else if (self.filter-layout && !self.filter-interactive && self.filter-other) { return SelectionStackFilter.LayoutsAndOthers; - } else if (self.lcb && self.icb && !self.ocb) { + } else if (self.filter-layout && self.filter-interactive && !self.filter-other) { return SelectionStackFilter.LayoutsAndInteractive; - } else if (self.lcb && self.icb && self.ocb) { + } else if (self.filter-layout && self.filter-interactive && self.filter-other) { return SelectionStackFilter.Everything; } return SelectionStackFilter.Nothing; } - out property has-filter: !self.lcb || !self.icb || !self.ocb; + out property has-filter: !self.filter-layout || !self.filter-interactive || !self.filter-other; - private property lcb: true; - private property icb: true; - private property ocb: true; + in-out property filter-interactive: true; + in-out property filter-layout: true; + in-out property filter-other: true; width: 0px; height: 0px; @@ -63,17 +63,17 @@ component FilterList { lcb := CheckBox { text: @tr("Layouts"); - checked <=> root.lcb; + checked <=> root.filter-layout; } icb := CheckBox { text: @tr("Interactive"); - checked <=> root.icb; + checked <=> root.filter-interactive; } ocb := CheckBox { text: @tr("Other"); - checked <=> root.ocb; + checked <=> root.filter-other; } } } @@ -86,6 +86,11 @@ component PopupInner inherits Rectangle { callback close(); + in-out property filter-interactive: true; + in-out property filter-layout: true; + in-out property filter-other: true; + in-out property filter-text: ""; + in property max-popup-height: 900px; in-out property selection-x: 0px; in-out property selection-y: 0px; @@ -249,11 +254,16 @@ component PopupInner inherits Rectangle { filter-edit.clear-focus(); self.checked = filter-state; } + + init => { + self.checked = filter-state; + } } filter-edit := LineEdit { placeholder-text: "Filter"; min-width: 50px; + text <=> root.filter-text; init => { self.focus(); } @@ -478,6 +488,10 @@ component PopupInner inherits Rectangle { filter-list := FilterList { x: filter-button.x + EditorSpaceSettings.default-spacing; y: filter-button.y + filter-button.height + EditorSpaceSettings.default-spacing; + + filter-layout <=> root.filter-layout; + filter-interactive <=> root.filter-interactive; + filter-other <=> root.filter-other; } } @@ -497,6 +511,11 @@ export component SelectionPopup { private property selection-x; private property selection-y; + private property filter-interactive: true; + private property filter-layout: true; + private property filter-other: true; + private property filter-text: ""; + popup := PopupWindow { in property preview-width: root.preview-width; in property preview-height: root.preview-height; @@ -505,6 +524,11 @@ export component SelectionPopup { in-out property selection-y: root.selection-y; in property max-popup-height: root.max-popup-height; + in-out property filter-interactive <=> root.filter-interactive; + in-out property filter-layout <=> root.filter-layout; + in-out property filter-other <=> root.filter-other; + in-out property filter-text <=> root.filter-text; + close-policy: PopupClosePolicy.close-on-click-outside; max-height: root.max-popup-height; @@ -518,6 +542,11 @@ export component SelectionPopup { popup.close(); } + filter-text <=> popup.filter-text; + filter-layout <=> popup.filter-layout; + filter-interactive <=> popup.filter-interactive; + filter-other <=> popup.filter-other; + preview-width <=> popup.preview-width; preview-height <=> popup.preview-height;