From a4d0c1366256d4e552990bde63734b7ceea0ad80 Mon Sep 17 00:00:00 2001 From: Noelia Date: Tue, 31 May 2022 11:25:30 +0200 Subject: [PATCH] feat(StatusTagSelector): Added property `showSortedListOnlyWhenText` and make dynamic the `implicitHeight` Added property `showSortedListOnlyWhenText` and make dynamic the `implicitHeight` calculation. --- src/StatusQ/Components/StatusTagSelector.qml | 26 ++++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/StatusQ/Components/StatusTagSelector.qml b/src/StatusQ/Components/StatusTagSelector.qml index b2112847..7fe3be89 100644 --- a/src/StatusQ/Components/StatusTagSelector.qml +++ b/src/StatusQ/Components/StatusTagSelector.qml @@ -59,10 +59,6 @@ import StatusQ.Core.Theme 0.1 Item { id: root - implicitWidth: 448 - implicitHeight: (104 + contactsLabel.height + contactsLabel.anchors.topMargin + (userListView.model.count * 64)) > root.maxHeight ? root.maxHeight : - (104 + contactsLabel.height + contactsLabel.anchors.topMargin + (userListView.model.count * 64)) - /*! \qmlproperty real StatusTagSelector::maxHeight This property holds the maximum height of the component. @@ -123,6 +119,12 @@ Item { This property holds the asorted names model. */ property ListModel namesModel: ListModel { } + /*! + \qmlproperty bool StatusTagSelector::showSortedListOnlyWhenText + This property will decide if the sorted list view info is displayed before entering some text in the input or after. + By default is set to false. + */ + property bool showSortedListOnlyWhenText: false /*! \qmlmethod @@ -181,6 +183,19 @@ Item { */ signal removeMember(string memberId) + QtObject { + id: d + + property real suggestionContainerHeight: suggestionsContainer.visible ? contactsLabel.height + contactsLabel.anchors.topMargin + + suggestionsContainer.anchors.topMargin + suggestionsContainer.anchors.bottomMargin + + 2 * bgRect.anchors.margins + + userListView.anchors.topMargin + userListView.anchors.bottomMargin + + (userListView.model.count * 64): 0 + } + + implicitWidth: 448 + implicitHeight: (tagSelectorRect.height + d.suggestionContainerHeight) > root.maxHeight ? root.maxHeight : (tagSelectorRect.height + d.suggestionContainerHeight) + Rectangle { id: tagSelectorRect width: parent.width @@ -317,7 +332,8 @@ Item { bottomMargin: 16//Style.current.padding } clip: true - visible: ((edit.text === "") || (root.sortedList.count > 0)) + visible: (!root.showSortedListOnlyWhenText && ((root.sortedList.count > 0) || (edit.text === ""))) || + ((edit.text !== "") && (root.sortedList.count > 0)) x: ((root.namesModel.count > 0) && (root.sortedList.count > 0) && ((edit.x + 8) <= (root.width - suggestionsContainer.width))) ? (edit.x + 8) : 0 background: Rectangle {