on xenial help sign in
First implementation of the filter popover
e298198Albert Astals Cid
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 @@
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18import Ubuntu.Components 1.1
18import Ubuntu.Components 1.1
19+import Ubuntu.Components.Popups 1.2
19import "../Components/SearchHistoryModel"
20import "../Components/SearchHistoryModel"
20import Utils 0.1
21import Utils 0.1
21import Unity 0.2
22import Unity 0.2
@@ -621,6 +622,7 @@ FocusScope {
621 extraPanel: peExtraPanel
622 extraPanel: peExtraPanel
622 searchHistory: SearchHistoryModel
623 searchHistory: SearchHistoryModel
623 searchHint: scopeView.scope && scopeView.scope.searchHint || i18n.ctr("Label: Hint for dash search line edit", "Search")
624 searchHint: scopeView.scope && scopeView.scope.searchHint || i18n.ctr("Label: Hint for dash search line edit", "Search")
625+ scopeHasFilters: scopeView.scope.filters != null
624 showBackButton: scopeView.hasBackAction
626 showBackButton: scopeView.hasBackAction
625 searchEntryEnabled: true
627 searchEntryEnabled: true
626 settingsEnabled: scopeView.scope && scopeView.scope.settings && scopeView.scope.settings.count > 0 || false
628 settingsEnabled: scopeView.scope && scopeView.scope.settings && scopeView.scope.settings.count > 0 || false
@@ -643,6 +645,9 @@ FocusScope {
643 openPopup();
645 openPopup();
644 }
646 }
645 }
647 }
648+ onShowFiltersPopup: { // item
649+ PopupUtils.open(Qt.resolvedUrl("FiltersPopover.qml"), item, { "contentWidth": scopeView.width - units.gu(2) } );
650+ }
646 }
651 }
647
652
648 PageHeaderExtraPanel {
653 PageHeaderExtraPanel {
qml/Dash/PageHeader.qml+11−3
@@ -17,7 +17,6 @@
17import QtQuick 2.2
17import QtQuick 2.2
18import Ubuntu.Components 1.1
18import Ubuntu.Components 1.1
19import Ubuntu.Components.Themes.Ambiance 1.1
19import Ubuntu.Components.Themes.Ambiance 1.1
20−import Ubuntu.Components.Popups 1.0
21import Ubuntu.Components.ListItems 1.0
20import Ubuntu.Components.ListItems 1.0
22import "../Components"
21import "../Components"
23
22
@@ -27,6 +26,7 @@ Item {
27 implicitHeight: headerContainer.height + bottomContainer.height + signatureLineHeight
26 implicitHeight: headerContainer.height + bottomContainer.height + signatureLineHeight
28 readonly property real signatureLineHeight: showSignatureLine ? units.gu(2) : 0
27 readonly property real signatureLineHeight: showSignatureLine ? units.gu(2) : 0
29
28
29+ property bool scopeHasFilters: false
30 property bool showBackButton: false
30 property bool showBackButton: false
31 property bool backIsClose: false
31 property bool backIsClose: false
32 property string title
32 property string title
@@ -55,6 +55,7 @@ Item {
55 signal settingsClicked()
55 signal settingsClicked()
56 signal favoriteClicked()
56 signal favoriteClicked()
57 signal searchTextFieldFocused()
57 signal searchTextFieldFocused()
58+ signal showFiltersPopup(var item)
58
59
59 onScopeStyleChanged: refreshLogo()
60 onScopeStyleChanged: refreshLogo()
60 onSearchQueryChanged: {
61 onSearchQueryChanged: {
@@ -204,15 +205,18 @@ Item {
204 }
205 }
205
206
206 secondaryItem: AbstractButton {
207 secondaryItem: AbstractButton {
208+ id: clearOrSettingsButton
207 height: searchTextField.height
209 height: searchTextField.height
208 width: height
210 width: height
209 enabled: searchTextField.text.length > 0 || root.navigationTag != ""
211 enabled: searchTextField.text.length > 0 || root.navigationTag != ""
210
212
213+ readonly property bool clearIsSettings: !searchTextField.focus && root.scopeHasFilters
214+
211 Image {
215 Image {
212 objectName: "clearIcon"
216 objectName: "clearIcon"
213 anchors.fill: parent
217 anchors.fill: parent
214 anchors.margins: units.gu(.75)
218 anchors.margins: units.gu(.75)
215− source: "image://theme/clear"
219+ source: parent.clearIsSettings ? "image://theme/settings" : "image://theme/clear"
216 opacity: parent.enabled
220 opacity: parent.enabled
217 visible: opacity > 0
221 visible: opacity > 0
218 Behavior on opacity {
222 Behavior on opacity {
@@ -221,7 +225,11 @@ Item {
221 }
225 }
222
226
223 onClicked: {
227 onClicked: {
228+ if (clearIsSettings) {
229+ root.showFiltersPopup(clearOrSettingsButton);
230+ } else {
224− root.clearSearch(true);
231+ root.clearSearch(true);
232+ }
225 }
233 }
226 }
234 }
227
235