on xenial help sign in
Close the PageHeaderExtraPanel when a filter option is selected Fixes: #1569498
e0897ccJosh Arenson
qml/Dash/Filters/FilterOptionSelector.qml+4
@@ -25,6 +25,8 @@ FilterWidget {
25
25
26 implicitHeight: expandingItem.height
26 implicitHeight: expandingItem.height
27
27
28+ signal filterSelected()
29+
28 ListItems.Expandable {
30 ListItems.Expandable {
29 id: expandingItem
31 id: expandingItem
30 objectName: "expandingItem"
32 objectName: "expandingItem"
@@ -67,6 +69,7 @@ FilterWidget {
67 width: parent.width
69 width: parent.width
68 Repeater {
70 Repeater {
69 model: widgetData.options
71 model: widgetData.options
72+ objectName: "optionsRepeater"
70
73
71 ListItems.Standard {
74 ListItems.Standard {
72 text: label
75 text: label
@@ -83,6 +86,7 @@ FilterWidget {
83
86
84 onClicked: {
87 onClicked: {
85 widgetData.options.setChecked(index, !checked);
88 widgetData.options.setChecked(index, !checked);
89+ root.filterSelected()
86 }
90 }
87 }
91 }
88 }
92 }
qml/Dash/Filters/FilterWidgetFactory.qml+8
@@ -31,6 +31,9 @@ Item {
31 //! Widget data, forwarded to the widget as is.
31 //! Widget data, forwarded to the widget as is.
32 property var widgetData: null
32 property var widgetData: null
33
33
34+ // Emitted iff filter type is FilterOptionSelector
35+ signal singleSelectionFilterSelected()
36+
34 implicitHeight: title.height + title.anchors.topMargin + loader.height
37 implicitHeight: title.height + title.anchors.topMargin + loader.height
35
38
36 Label {
39 Label {
@@ -77,5 +80,10 @@ Item {
77 item.widgetId = Qt.binding(function() { return root.widgetId } )
80 item.widgetId = Qt.binding(function() { return root.widgetId } )
78 item.widgetData = Qt.binding(function() { return root.widgetData } )
81 item.widgetData = Qt.binding(function() { return root.widgetData } )
79 }
82 }
83+
84+ Connections {
85+ target: widgetType == Filters.OptionSelectorFilter ? loader.item : null
86+ onFilterSelected: root.singleSelectionFilterSelected()
87+ }
80 }
88 }
81}
89}
qml/Dash/GenericScopeView.qml+5
@@ -689,6 +689,11 @@ FocusScope {
689 categoryView.pageHeader.closePopup();
689 categoryView.pageHeader.closePopup();
690 categoryView.pageHeader.unfocus();
690 categoryView.pageHeader.unfocus();
691 }
691 }
692+
693+ onExtraPanelOptionSelected: {
694+ categoryView.pageHeader.closePopup();
695+ categoryView.pageHeader.unfocus();
696+ }
692 }
697 }
693 }
698 }
694
699
qml/Dash/PageHeaderExtraPanel.qml+3
@@ -36,6 +36,7 @@ Item {
36
36
37 signal historyItemClicked(string text)
37 signal historyItemClicked(string text)
38 signal dashNavigationLeafClicked()
38 signal dashNavigationLeafClicked()
39+ signal extraPanelOptionSelected()
39
40
40 function resetNavigation() {
41 function resetNavigation() {
41 dashNavigation.resetNavigation();
42 dashNavigation.resetNavigation();
@@ -181,6 +182,8 @@ Item {
181 widgetId: filter ? filter.filterId : ""
182 widgetId: filter ? filter.filterId : ""
182 widgetType: filter ? filter.filterType : -1
183 widgetType: filter ? filter.filterType : -1
183 widgetData: filter
184 widgetData: filter
185+
186+ onSingleSelectionFilterSelected: extraPanelOptionSelected()
184 }
187 }
185 }
188 }
186
189
tests/mocks/Unity/fake_scope.cpp+4
@@ -52,6 +52,8 @@ Scope::Scope(QString const& id, QString const& name, bool favorite, Scopes* pare
52 m_primaryNavigationFilter = new FakeOptionSelectorFilter("OSF3", "PFTag", "Which food you like More", false, primaryNavigationFilterOptionLabels, this);
52 m_primaryNavigationFilter = new FakeOptionSelectorFilter("OSF3", "PFTag", "Which food you like More", false, primaryNavigationFilterOptionLabels, this);
53 m_filters->addFakeFilters();
53 m_filters->addFakeFilters();
54 connect(m_filters, &Filters::activeFiltersCountChanged, this, &Scope::activeFiltersCountChanged);
54 connect(m_filters, &Filters::activeFiltersCountChanged, this, &Scope::activeFiltersCountChanged);
55+ connect(m_primaryNavigationFilter, &FakeOptionSelectorFilter::isActiveChanged,
56+ this, &unity::shell::scopes::ScopeInterface::primaryNavigationTagChanged);
55}
57}
56
58
57QString Scope::id() const
59QString Scope::id() const
@@ -325,6 +327,8 @@ unity::shell::scopes::FiltersInterface* Scope::filters() const
325
327
326QString Scope::primaryNavigationTag() const
328QString Scope::primaryNavigationTag() const
327{
329{
330+ if (m_hasPrimaryFilter && m_primaryNavigationFilter->isActive())
331+ return m_primaryNavigationFilter->filterTag();
328 if (m_currentNavigationId == "root")
332 if (m_currentNavigationId == "root")
329 return QString();
333 return QString();
330 else
334 else
tests/qmltests/Dash/tst_Dash.qml+27
@@ -146,6 +146,33 @@ Item {
146 tryCompare(categoryListView, "atYBeginning", true)
146 tryCompare(categoryListView, "atYBeginning", true)
147 }
147 }
148
148
149+ function test_navigationFilterPopupClosesWhenOptionSelected() {
150+ dash.setCurrentScope("LongPrimaryNavigation")
151+
152+ var dashContentList = findChild(dashContent, "dashContentList")
153+ var searchButton = findChild(dashContentList.currentItem, "search_button")
154+ verify(searchButton)
155+ var extraPanel = findChild(dashContentList.currentItem, "peExtraPanel")
156+ verify(extraPanel)
157+
158+ var primaryFilter = findChild(extraPanel, "primaryFilter")
159+ var expandingItem = findChild(primaryFilter, "expandingItem")
160+ verify(expandingItem)
161+ tryCompare(expandingItem, "expanded", false)
162+
163+ mouseClick(searchButton)
164+ expandingItem.expanded = true
165+ tryCompare(expandingItem, "expanded", true)
166+ tryCompareFunction(function() { return expandingItem.height == expandingItem.expandedHeight; }, true);
167+
168+ var optionsRepeater = findChild(expandingItem, "optionsRepeater")
169+ verify(optionsRepeater)
170+ verify(optionsRepeater.itemAt(0))
171+ tryCompare(optionsRepeater.itemAt(0), "visible", true)
172+ mouseClick(optionsRepeater.itemAt(0))
173+ tryCompare(expandingItem, "visible", false)
174+ }
175+
149 function test_manage_dash_clickscope_unfavoritable() {
176 function test_manage_dash_clickscope_unfavoritable() {
150 // Show the manage dash
177 // Show the manage dash
151 touchFlick(dash, dash.width / 2, dash.height - 1, dash.width / 2, units.gu(2));
178 touchFlick(dash, dash.width / 2, dash.height - 1, dash.width / 2, units.gu(2));