on xenial help sign in
Add code for the primary selection filter to show up if no dash navigation is there
commit28b0c3883675e64cdb2dc114d34fd3873ea2ae54 authorAlbert Astals Cid <albert.astals@canonical.com> dateFri 9 Oct 2015, 16:32 (11 years ago) parent6c87dff
5 files changed+27−4
qml/Dash/DashNavigation.qml+1−1 qml/Dash/PageHeaderExtraPanel.qml+20−2 tests/mocks/Unity/fake_scope.cpp+3−1 tests/mocks/Unity/fake_scope.h+2 tests/mocks/Unity/fake_unity_plugin.cpp+1
qml/Dash/DashNavigation.qml+1−1
@@ -35,7 +35,7 @@ Item {
3535 property bool isEnteringChildren: false
3636
3737 visible: height != 0
38− implicitHeight: navigationListView.y + navigationListView.height
38+ implicitHeight: scope && scope.hasNavigation ? navigationListView.y + navigationListView.height : 0
3939
4040 function resetNavigation() {
4141 if (navigationModel.count > 1) {
qml/Dash/PageHeaderExtraPanel.qml+20−2
@@ -17,13 +17,14 @@
1717import QtQuick 2.2
1818import Ubuntu.Components 1.1
1919import Ubuntu.Components.ListItems 1.0
20+import "Filters" as Filters
2021
2122Item {
2223 id: root
2324
2425 readonly property real searchesHeight: recentSearchesRepeater.count > 0 ? searchColumn.height + recentSearchesLabels.height + recentSearchesLabels.anchors.margins : 0
2526
26− implicitHeight: searchesHeight + dashNavigation.implicitHeight
27+ implicitHeight: searchesHeight + dashNavigation.implicitHeight + primaryFilter.height
2728
2829 // Set by parent
2930 property ListModel searchHistory
@@ -32,7 +33,7 @@ Item {
3233 property real windowHeight
3334
3435 // 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
3637
3738 signal historyItemClicked(string text)
3839 signal dashNavigationLeafClicked()
@@ -110,4 +111,21 @@ Item {
110111
111112 onLeafClicked: root.dashNavigationLeafClicked();
112113 }
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+ }
113131}
tests/mocks/Unity/fake_scope.cpp+3−1
@@ -21,6 +21,7 @@
2121
2222#include "fake_filters.h"
2323#include "fake_navigation.h"
24+#include "fake_optionselectorfilter.h"
2425#include "fake_resultsmodel.h"
2526#include "fake_scopes.h"
2627#include "fake_settingsmodel.h"
@@ -46,6 +47,7 @@ Scope::Scope(QString const& id, QString const& name, bool favorite, Scopes* pare
4647 , m_filters(new Filters(this))
4748 , m_returnNullPreview(returnNullPreview)
4849{
50+ m_primaryNavigationFilter = new FakeOptionSelectorFilter("OSF2", "PFTag", "Which food you like More", false, QStringList() << "meat" << "vegetables", this);
4951}
5052
5153QString Scope::id() const
@@ -288,7 +290,7 @@ void Scope::setNavigationState(const QString &navigationId)
288290
289291unity::shell::scopes::FilterBaseInterface* Scope::primaryNavigationFilter() const
290292{
291− return nullptr;
293+ return m_primaryNavigationFilter;
292294}
293295
294296unity::shell::scopes::FiltersInterface* Scope::filters() const
tests/mocks/Unity/fake_scope.h+2
@@ -25,6 +25,7 @@
2525#include <QTimer>
2626
2727class Scopes;
28+class FakeOptionSelectorFilter;
2829
2930class Scope : public unity::shell::scopes::ScopeInterface
3031{
@@ -108,6 +109,7 @@ protected:
108109 unity::shell::scopes::ScopeInterface* m_openScope;
109110 unity::shell::scopes::SettingsModelInterface* m_settings;
110111 unity::shell::scopes::FiltersInterface* m_filters;
112+ FakeOptionSelectorFilter* m_primaryNavigationFilter;
111113
112114 bool m_returnNullPreview;
113115};
tests/mocks/Unity/fake_unity_plugin.cpp+1
@@ -56,5 +56,6 @@ void FakeUnityPlugin::registerTypes(const char *uri)
5656 qmlRegisterUncreatableType<PreviewWidgetModel>(uri, 0, 2, "PreviewWidgetModel", "Can't create new PreviewWidgetModel in QML. Get them from PreviewModel instance.");
5757 qmlRegisterUncreatableType<PreviewStack>(uri, 0, 2, "PreviewStack", "Can't create new PreviewStack in QML. Get them from Scope instance.");
5858 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.");
5960 qmlRegisterUncreatableType<unity::shell::scopes::OptionSelectorOptionsInterface>(uri, 0, 2, "OptionSelectorOptions", "Can't create Filters object in QML. Get them from OptionSelector instance.");
6061}