on xenial help sign in
Close the PageHeaderExtraPanel when a filter option is selected Fixes: #1569498

Approved by: Albert Astals Cid

commite0897cc61939c18f62c30bded10af013333d7b72 authorJosh Arenson <joshua.arenson@canonical.com> dateFri 27 May 2016, 13:51 (10 years ago) parent974747c0f112b8
6 files changed+51
qml/Dash/Filters/FilterOptionSelector.qml+4 qml/Dash/Filters/FilterWidgetFactory.qml+8 qml/Dash/GenericScopeView.qml+5 qml/Dash/PageHeaderExtraPanel.qml+3 tests/mocks/Unity/fake_scope.cpp+4 tests/qmltests/Dash/tst_Dash.qml+27
qml/Dash/Filters/FilterOptionSelector.qml+4
@@ -25,6 +25,8 @@ FilterWidget {
2525
2626 implicitHeight: expandingItem.height
2727
28+ signal filterSelected()
29+
2830 ListItems.Expandable {
2931 id: expandingItem
3032 objectName: "expandingItem"
@@ -67,6 +69,7 @@ FilterWidget {
6769 width: parent.width
6870 Repeater {
6971 model: widgetData.options
72+ objectName: "optionsRepeater"
7073
7174 ListItems.Standard {
7275 text: label
@@ -83,6 +86,7 @@ FilterWidget {
8386
8487 onClicked: {
8588 widgetData.options.setChecked(index, !checked);
89+ root.filterSelected()
8690 }
8791 }
8892 }
qml/Dash/Filters/FilterWidgetFactory.qml+8
@@ -31,6 +31,9 @@ Item {
3131 //! Widget data, forwarded to the widget as is.
3232 property var widgetData: null
3333
34+ // Emitted iff filter type is FilterOptionSelector
35+ signal singleSelectionFilterSelected()
36+
3437 implicitHeight: title.height + title.anchors.topMargin + loader.height
3538
3639 Label {
@@ -77,5 +80,10 @@ Item {
7780 item.widgetId = Qt.binding(function() { return root.widgetId } )
7881 item.widgetData = Qt.binding(function() { return root.widgetData } )
7982 }
83+
84+ Connections {
85+ target: widgetType == Filters.OptionSelectorFilter ? loader.item : null
86+ onFilterSelected: root.singleSelectionFilterSelected()
87+ }
8088 }
8189}
qml/Dash/GenericScopeView.qml+5
@@ -689,6 +689,11 @@ FocusScope {
689689 categoryView.pageHeader.closePopup();
690690 categoryView.pageHeader.unfocus();
691691 }
692+
693+ onExtraPanelOptionSelected: {
694+ categoryView.pageHeader.closePopup();
695+ categoryView.pageHeader.unfocus();
696+ }
692697 }
693698 }
694699
qml/Dash/PageHeaderExtraPanel.qml+3
@@ -36,6 +36,7 @@ Item {
3636
3737 signal historyItemClicked(string text)
3838 signal dashNavigationLeafClicked()
39+ signal extraPanelOptionSelected()
3940
4041 function resetNavigation() {
4142 dashNavigation.resetNavigation();
@@ -181,6 +182,8 @@ Item {
181182 widgetId: filter ? filter.filterId : ""
182183 widgetType: filter ? filter.filterType : -1
183184 widgetData: filter
185+
186+ onSingleSelectionFilterSelected: extraPanelOptionSelected()
184187 }
185188 }
186189
tests/mocks/Unity/fake_scope.cpp+4
@@ -52,6 +52,8 @@ Scope::Scope(QString const& id, QString const& name, bool favorite, Scopes* pare
5252 m_primaryNavigationFilter = new FakeOptionSelectorFilter("OSF3", "PFTag", "Which food you like More", false, primaryNavigationFilterOptionLabels, this);
5353 m_filters->addFakeFilters();
5454 connect(m_filters, &Filters::activeFiltersCountChanged, this, &Scope::activeFiltersCountChanged);
55+ connect(m_primaryNavigationFilter, &FakeOptionSelectorFilter::isActiveChanged,
56+ this, &unity::shell::scopes::ScopeInterface::primaryNavigationTagChanged);
5557}
5658
5759QString Scope::id() const
@@ -325,6 +327,8 @@ unity::shell::scopes::FiltersInterface* Scope::filters() const
325327
326328QString Scope::primaryNavigationTag() const
327329{
330+ if (m_hasPrimaryFilter && m_primaryNavigationFilter->isActive())
331+ return m_primaryNavigationFilter->filterTag();
328332 if (m_currentNavigationId == "root")
329333 return QString();
330334 else
tests/qmltests/Dash/tst_Dash.qml+27
@@ -146,6 +146,33 @@ Item {
146146 tryCompare(categoryListView, "atYBeginning", true)
147147 }
148148
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+
149176 function test_manage_dash_clickscope_unfavoritable() {
150177 // Show the manage dash
151178 touchFlick(dash, dash.width / 2, dash.height - 1, dash.width / 2, units.gu(2));