on xenial help sign in
First implementation of the filter popover
commite29819843503191393c228c696149f91d065c63d authorAlbert Astals Cid <albert.astals@canonical.com> dateFri 2 Oct 2015, 11:08 (11 years ago) parentc388596
6 files changed+161−3
qml/Dash/Filters/FilterOptionSelector.qml+24 qml/Dash/Filters/FilterWidget.qml+29 qml/Dash/Filters/FilterWidgetFactory.qml+49 qml/Dash/FiltersPopover.qml+43 qml/Dash/GenericScopeView.qml+5 qml/Dash/PageHeader.qml+11−3
qml/Dash/Filters/FilterOptionSelector.qmlnew file+24
@@ -0,0 +1,24 @@
1+/*
2+ * Copyright (C) 2015 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.4
18+
19+/*! Interface for filter widgets. */
20+
21+FilterWidget {
22+ // TODO
23+ implicitHeight: units.gu(4)
24+}
qml/Dash/Filters/FilterWidget.qmlnew file+29
@@ -0,0 +1,29 @@
1+/*
2+ * Copyright (C) 2015 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.4
18+
19+/*! Interface for filter widgets. */
20+
21+Item {
22+ //! The widget identifier
23+ property string widgetId
24+
25+ //! Variable used to contain widget's data
26+ property var widgetData
27+
28+ objectName: widgetId
29+}
qml/Dash/Filters/FilterWidgetFactory.qmlnew file+49
@@ -0,0 +1,49 @@
1+/*
2+ * Copyright (C) 2015 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.4
18+import Unity 0.2
19+
20+//! \brief This component loads the widgets based on widgetData["type"].
21+
22+Loader {
23+ id: root
24+
25+ //! Identifier of the widget.
26+ property string widgetId: ""
27+
28+ //! Type of the widget to display.
29+ property int widgetType
30+
31+ //! Widget data, forwarded to the widget as is.
32+ property var widgetData: null
33+
34+ source: widgetSource
35+
36+ //! \cond private
37+ readonly property url widgetSource: {
38+ switch (widgetType) {
39+ case Filters.OptionSelectorFilter: return "FilterOptionSelector.qml";
40+ default: return "";
41+ }
42+ }
43+ //! \endcond
44+
45+ onLoaded: {
46+ item.widgetId = Qt.binding(function() { return root.widgetId } )
47+ item.widgetData = Qt.binding(function() { return root.widgetData } )
48+ }
49+}
qml/Dash/FiltersPopover.qmlnew file+43
@@ -0,0 +1,43 @@
1+/*
2+ * Copyright (C) 2013-2015 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.4
18+import Ubuntu.Components 1.2
19+import Ubuntu.Components.Popups 1.2
20+import "Filters" as Filters
21+
22+Popover {
23+ Column {
24+ anchors {
25+ top: parent.top
26+ left: parent.left
27+ right: parent.right
28+ }
29+
30+ Repeater {
31+ id: repeater
32+ model: scopeView.scope.filters
33+
34+ delegate: Filters.FilterWidgetFactory {
35+ width: parent.width
36+
37+ widgetId: id
38+ widgetType: type
39+ widgetData: filter
40+ }
41+ }
42+ }
43+}
qml/Dash/GenericScopeView.qml+5
@@ -16,6 +16,7 @@
1616
1717import QtQuick 2.0
1818import Ubuntu.Components 1.1
19+import Ubuntu.Components.Popups 1.2
1920import "../Components/SearchHistoryModel"
2021import Utils 0.1
2122import Unity 0.2
@@ -621,6 +622,7 @@ FocusScope {
621622 extraPanel: peExtraPanel
622623 searchHistory: SearchHistoryModel
623624 searchHint: scopeView.scope && scopeView.scope.searchHint || i18n.ctr("Label: Hint for dash search line edit", "Search")
625+ scopeHasFilters: scopeView.scope.filters != null
624626 showBackButton: scopeView.hasBackAction
625627 searchEntryEnabled: true
626628 settingsEnabled: scopeView.scope && scopeView.scope.settings && scopeView.scope.settings.count > 0 || false
@@ -643,6 +645,9 @@ FocusScope {
643645 openPopup();
644646 }
645647 }
648+ onShowFiltersPopup: { // item
649+ PopupUtils.open(Qt.resolvedUrl("FiltersPopover.qml"), item, { "contentWidth": scopeView.width - units.gu(2) } );
650+ }
646651 }
647652
648653 PageHeaderExtraPanel {
qml/Dash/PageHeader.qml+11−3
@@ -17,7 +17,6 @@
1717import QtQuick 2.2
1818import Ubuntu.Components 1.1
1919import Ubuntu.Components.Themes.Ambiance 1.1
20−import Ubuntu.Components.Popups 1.0
2120import Ubuntu.Components.ListItems 1.0
2221import "../Components"
2322
@@ -27,6 +26,7 @@ Item {
2726 implicitHeight: headerContainer.height + bottomContainer.height + signatureLineHeight
2827 readonly property real signatureLineHeight: showSignatureLine ? units.gu(2) : 0
2928
29+ property bool scopeHasFilters: false
3030 property bool showBackButton: false
3131 property bool backIsClose: false
3232 property string title
@@ -55,6 +55,7 @@ Item {
5555 signal settingsClicked()
5656 signal favoriteClicked()
5757 signal searchTextFieldFocused()
58+ signal showFiltersPopup(var item)
5859
5960 onScopeStyleChanged: refreshLogo()
6061 onSearchQueryChanged: {
@@ -204,15 +205,18 @@ Item {
204205 }
205206
206207 secondaryItem: AbstractButton {
208+ id: clearOrSettingsButton
207209 height: searchTextField.height
208210 width: height
209211 enabled: searchTextField.text.length > 0 || root.navigationTag != ""
210212
213+ readonly property bool clearIsSettings: !searchTextField.focus && root.scopeHasFilters
214+
211215 Image {
212216 objectName: "clearIcon"
213217 anchors.fill: parent
214218 anchors.margins: units.gu(.75)
215− source: "image://theme/clear"
219+ source: parent.clearIsSettings ? "image://theme/settings" : "image://theme/clear"
216220 opacity: parent.enabled
217221 visible: opacity > 0
218222 Behavior on opacity {
@@ -221,7 +225,11 @@ Item {
221225 }
222226
223227 onClicked: {
224− root.clearSearch(true);
228+ if (clearIsSettings) {
229+ root.showFiltersPopup(clearOrSettingsButton);
230+ } else {
231+ root.clearSearch(true);
232+ }
225233 }
226234 }
227235