on xenial help sign in
Add code for the primary selection filter to show up if no dash navigation is there
28b0c38Albert Astals Cid
qml/Dash/DashNavigation.qml+1−1
@@ -35,7 +35,7 @@ Item {
35 property bool isEnteringChildren: false
35 property bool isEnteringChildren: false
36
36
37 visible: height != 0
37 visible: height != 0
38− implicitHeight: navigationListView.y + navigationListView.height
38+ implicitHeight: scope && scope.hasNavigation ? navigationListView.y + navigationListView.height : 0
39
39
40 function resetNavigation() {
40 function resetNavigation() {
41 if (navigationModel.count > 1) {
41 if (navigationModel.count > 1) {
qml/Dash/PageHeaderExtraPanel.qml+20−2
@@ -17,13 +17,14 @@
17import QtQuick 2.2
17import QtQuick 2.2
18import Ubuntu.Components 1.1
18import Ubuntu.Components 1.1
19import Ubuntu.Components.ListItems 1.0
19import Ubuntu.Components.ListItems 1.0
20+import "Filters" as Filters
20
21
21Item {
22Item {
22 id: root
23 id: root
23
24
24 readonly property real searchesHeight: recentSearchesRepeater.count > 0 ? searchColumn.height + recentSearchesLabels.height + recentSearchesLabels.anchors.margins : 0
25 readonly property real searchesHeight: recentSearchesRepeater.count > 0 ? searchColumn.height + recentSearchesLabels.height + recentSearchesLabels.anchors.margins : 0
25
26
26− implicitHeight: searchesHeight + dashNavigation.implicitHeight
27+ implicitHeight: searchesHeight + dashNavigation.implicitHeight + primaryFilter.height
27
28
28 // Set by parent
29 // Set by parent
29 property ListModel searchHistory
30 property ListModel searchHistory
@@ -32,7 +33,7 @@ Item {
32 property real windowHeight
33 property real windowHeight
33
34
34 // Used by PageHeader
35 // Used by PageHeader
35− readonly property bool hasContents: searchHistory.count > 0 || scope && scope.hasNavigation
36+ readonly property bool hasContents: searchHistory.count > 0 || scope && scope.hasNavigation || scope && scope.primaryNavigationFilter
36
37
37 signal historyItemClicked(string text)
38 signal historyItemClicked(string text)
38 signal dashNavigationLeafClicked()
39 signal dashNavigationLeafClicked()
@@ -110,4 +111,21 @@ Item {
110
111
111 onLeafClicked: root.dashNavigationLeafClicked();
112 onLeafClicked: root.dashNavigationLeafClicked();
112 }
113 }
114+
115+ Filters.FilterWidgetFactory {
116+ id: primaryFilter
117+ active: scope && !scope.hasNavigation
118+
119+ property var filter: active ? scope.primaryNavigationFilter : null
120+
121+ anchors {
122+ top: recentSearchesRepeater.count > 0 ? searchColumn.bottom : parent.top
123+ left: parent.left
124+ right: parent.right
125+ }
126+
127+ widgetId: filter ? filter.filterId : ""
128+ widgetType: filter ? filter.filterType : -1
129+ widgetData: filter
130+ }
113}
131}
tests/mocks/Unity/fake_scope.cpp+3−1
@@ -21,6 +21,7 @@
21
21
22#include "fake_filters.h"
22#include "fake_filters.h"
23#include "fake_navigation.h"
23#include "fake_navigation.h"
24+#include "fake_optionselectorfilter.h"
24#include "fake_resultsmodel.h"
25#include "fake_resultsmodel.h"
25#include "fake_scopes.h"
26#include "fake_scopes.h"
26#include "fake_settingsmodel.h"
27#include "fake_settingsmodel.h"
@@ -46,6 +47,7 @@ Scope::Scope(QString const& id, QString const& name, bool favorite, Scopes* pare
46 , m_filters(new Filters(this))
47 , m_filters(new Filters(this))
47 , m_returnNullPreview(returnNullPreview)
48 , m_returnNullPreview(returnNullPreview)
48{
49{
50+ m_primaryNavigationFilter = new FakeOptionSelectorFilter("OSF2", "PFTag", "Which food you like More", false, QStringList() << "meat" << "vegetables", this);
49}
51}
50
52
51QString Scope::id() const
53QString Scope::id() const
@@ -288,7 +290,7 @@ void Scope::setNavigationState(const QString &navigationId)
288
290
289unity::shell::scopes::FilterBaseInterface* Scope::primaryNavigationFilter() const
291unity::shell::scopes::FilterBaseInterface* Scope::primaryNavigationFilter() const
290{
292{
291− return nullptr;
293+ return m_primaryNavigationFilter;
292}
294}
293
295
294unity::shell::scopes::FiltersInterface* Scope::filters() const
296unity::shell::scopes::FiltersInterface* Scope::filters() const
tests/mocks/Unity/fake_scope.h+2
@@ -25,6 +25,7 @@
25#include <QTimer>
25#include <QTimer>
26
26
27class Scopes;
27class Scopes;
28+class FakeOptionSelectorFilter;
28
29
29class Scope : public unity::shell::scopes::ScopeInterface
30class Scope : public unity::shell::scopes::ScopeInterface
30{
31{
@@ -108,6 +109,7 @@ protected:
108 unity::shell::scopes::ScopeInterface* m_openScope;
109 unity::shell::scopes::ScopeInterface* m_openScope;
109 unity::shell::scopes::SettingsModelInterface* m_settings;
110 unity::shell::scopes::SettingsModelInterface* m_settings;
110 unity::shell::scopes::FiltersInterface* m_filters;
111 unity::shell::scopes::FiltersInterface* m_filters;
112+ FakeOptionSelectorFilter* m_primaryNavigationFilter;
111
113
112 bool m_returnNullPreview;
114 bool m_returnNullPreview;
113};
115};
tests/mocks/Unity/fake_unity_plugin.cpp+1
@@ -56,5 +56,6 @@ void FakeUnityPlugin::registerTypes(const char *uri)
56 qmlRegisterUncreatableType<PreviewWidgetModel>(uri, 0, 2, "PreviewWidgetModel", "Can't create new PreviewWidgetModel in QML. Get them from PreviewModel instance.");
56 qmlRegisterUncreatableType<PreviewWidgetModel>(uri, 0, 2, "PreviewWidgetModel", "Can't create new PreviewWidgetModel in QML. Get them from PreviewModel instance.");
57 qmlRegisterUncreatableType<PreviewStack>(uri, 0, 2, "PreviewStack", "Can't create new PreviewStack in QML. Get them from Scope instance.");
57 qmlRegisterUncreatableType<PreviewStack>(uri, 0, 2, "PreviewStack", "Can't create new PreviewStack in QML. Get them from Scope instance.");
58 qmlRegisterUncreatableType<unity::shell::scopes::FiltersInterface>(uri, 0, 2, "Filters", "Can't create Filters object in QML. Get them from Scope instance.");
58 qmlRegisterUncreatableType<unity::shell::scopes::FiltersInterface>(uri, 0, 2, "Filters", "Can't create Filters object in QML. Get them from Scope instance.");
59+ qmlRegisterUncreatableType<unity::shell::scopes::FilterBaseInterface>(uri, 0, 2, "Filter", "Can't create Filter object in QML. Get them from Scope instance.");
59 qmlRegisterUncreatableType<unity::shell::scopes::OptionSelectorOptionsInterface>(uri, 0, 2, "OptionSelectorOptions", "Can't create Filters object in QML. Get them from OptionSelector instance.");
60 qmlRegisterUncreatableType<unity::shell::scopes::OptionSelectorOptionsInterface>(uri, 0, 2, "OptionSelectorOptions", "Can't create Filters object in QML. Get them from OptionSelector instance.");
60}
61}