From 668b0875d583bbe7cc7ae9ddcf3efed947927ec4 Mon Sep 17 00:00:00 2001 From: Pierre Lamot <pierre@videolabs.io> Date: Thu, 9 Sep 2021 17:50:52 +0200 Subject: [PATCH] qml: remove coupling from contentModel to SearchBox --- modules/gui/qt/maininterface/qml/BannerSources.qml | 10 ++++++++-- modules/gui/qt/widgets/qml/SearchBox.qml | 8 ++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/gui/qt/maininterface/qml/BannerSources.qml b/modules/gui/qt/maininterface/qml/BannerSources.qml index 7386ed77a0c3..241d7aee3ce3 100644 --- a/modules/gui/qt/maininterface/qml/BannerSources.qml +++ b/modules/gui/qt/maininterface/qml/BannerSources.qml @@ -60,12 +60,19 @@ FocusScope { searchBox.expanded = true } + Binding { + target: contentModel + property: "searchPattern" + value: searchBox.searchPattern + when: !!contentModel + } + Widgets.AcrylicBackground { alternativeColor: VLCStyle.colors.topBanner anchors.fill: parent } - Item { + Item { id: pLBannerSources property alias model: globalMenuGroup.model @@ -377,7 +384,6 @@ FocusScope { Widgets.SearchBox { id: searchBox - contentModel: root.contentModel visible: root.contentModel !== undefined enabled: visible height: VLCStyle.bannerButton_height diff --git a/modules/gui/qt/widgets/qml/SearchBox.qml b/modules/gui/qt/widgets/qml/SearchBox.qml index ce15f05d0f71..9111cb9809f8 100644 --- a/modules/gui/qt/widgets/qml/SearchBox.qml +++ b/modules/gui/qt/widgets/qml/SearchBox.qml @@ -29,11 +29,12 @@ FocusScope { width: content.width - property variant contentModel property alias buttonWidth: icon.width property bool expanded: false + property alias searchPattern: searchBox.text + onExpandedChanged: { if (expanded) { searchBox.forceActiveFocus() @@ -140,11 +141,6 @@ FocusScope { background: Rectangle { color: "transparent" } - onTextChanged: { - if (contentModel !== undefined) - contentModel.searchPattern = text; - } - Navigation.parentItem: root Navigation.leftItem: icon Navigation.rightItem: clearButton.visible ? clearButton : null -- GitLab