on xenial help sign in
Unity ScopeView and GenericScopeView
955ccf3Albert Astals
Dash/GenericScopeView.qml+47−2
@@ -16,15 +16,60 @@
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18import Ubuntu.Components 0.1
18import Ubuntu.Components 0.1
19+import Utils 0.1
20+import Unity 0.1
19import "../Components"
21import "../Components"
20import "../Components/ListItems" as ListItems
22import "../Components/ListItems" as ListItems
21
23
22−ScopeView {
24+FocusScope {
23 id: scopeView
25 id: scopeView
26+
27+ property Scope scope
28+ property SortFilterProxyModel categories: categoryFilter
29+ property bool isCurrent
30+ property ListModel searchHistory
31+ property alias moving: categoryView.moving
32+
33+ signal endReached
34+ signal movementStarted
35+ signal positionedAtBeginning
36+
24 readonly property alias previewShown: previewListView.onScreen
37 readonly property alias previewShown: previewListView.onScreen
25 property bool enableHeightBehaviorOnNextCreation: false
38 property bool enableHeightBehaviorOnNextCreation: false
26
39
27− moving: categoryView.moving
40+ // FIXME delay the search so that daemons have time to settle, note that
41+ // removing this will break ScopeView::test_changeScope
42+ onScopeChanged: {
43+ if (scope) {
44+ timer.restart();
45+ scope.activateApplication.connect(activateApp);
46+ }
47+ }
48+
49+ function activateApp(desktopFilePath) {
50+ shell.activateApplication(desktopFilePath);
51+ }
52+
53+ Binding {
54+ target: scope
55+ property: "isActive"
56+ value: isCurrent
57+ }
58+
59+ Timer {
60+ id: timer
61+ interval: 2000
62+ onTriggered: scope.searchQuery = ""
63+ }
64+
65+ SortFilterProxyModel {
66+ id: categoryFilter
67+ model: scope ? scope.categories : null
68+ dynamicSortFilter: true
69+ filterRole: Categories.RoleCount
70+ filterRegExp: /^0$/
71+ invertMatch: true
72+ }
28
73
29 onIsCurrentChanged: {
74 onIsCurrentChanged: {
30 pageHeader.resetSearch();
75 pageHeader.resetSearch();
Dash/ScopeView.qmldeleted−65
@@ -1,65 +0,0 @@
1−/*
2− * Copyright (C) 2013 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.0
18−import Utils 0.1
19−import Unity 0.1
20−
21−FocusScope {
22− property Scope scope
23− property SortFilterProxyModel categories: categoryFilter
24− property bool isCurrent
25− property ListModel searchHistory
26− property bool moving: false
27−
28− signal endReached
29− signal movementStarted
30− signal positionedAtBeginning
31−
32− // FIXME delay the search so that daemons have time to settle, note that
33− // removing this will break ScopeView::test_changeScope
34− onScopeChanged: {
35− if (scope) {
36− timer.restart();
37− scope.activateApplication.connect(activateApp);
38− }
39− }
40−
41− function activateApp(desktopFilePath) {
42− shell.activateApplication(desktopFilePath);
43− }
44−
45− Binding {
46− target: scope
47− property: "isActive"
48− value: isCurrent
49− }
50−
51− Timer {
52− id: timer
53− interval: 2000
54− onTriggered: scope.searchQuery = ""
55− }
56−
57− SortFilterProxyModel {
58− id: categoryFilter
59− model: scope ? scope.categories : null
60− dynamicSortFilter: true
61− filterRole: Categories.RoleCount
62− filterRegExp: /^0$/
63− invertMatch: true
64− }
65−}
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+8−4
@@ -1196,11 +1196,15 @@ void ListViewWithPageHeader::layout()
1196 }
1196 }
1197 }
1197 }
1198 QQmlContext *context = QQmlEngine::contextForObject(item->m_item)->parentContext();
1198 QQmlContext *context = QQmlEngine::contextForObject(item->m_item)->parentContext();
1199+ if (context) {
1199− const qreal clipFrom = visibleFrom + (!item->m_sectionItem && m_topSectionItem && !QQuickItemPrivate::get(m_topSectionItem)->culled ? m_topSectionItem->height() : 0);
1200+ const qreal clipFrom = visibleFrom + (!item->m_sectionItem && m_topSectionItem && !QQuickItemPrivate::get(m_topSectionItem)->culled ? m_topSectionItem->height() : 0);
1200− if (!cull && pos < clipFrom) {
1201+ if (!cull && pos < clipFrom) {
1201− context->setContextProperty(QLatin1String("heightToClip"), clipFrom - pos);
1202+ context->setContextProperty(QLatin1String("heightToClip"), clipFrom - pos);
1203+ } else {
1204+ context->setContextProperty(QLatin1String("heightToClip"), QVariant::fromValue<int>(0));
1205+ }
1202 } else {
1206 } else {
1203− context->setContextProperty(QLatin1String("heightToClip"), QVariant::fromValue<int>(0));
1207+ qWarning() << "ListViewWithPageHeader::layout::No context for item found, if you see this outside tests please report";
1204 }
1208 }
1205// qDebug() << "ListViewWithPageHeader::layout" << item->m_item;
1209// qDebug() << "ListViewWithPageHeader::layout" << item->m_item;
1206 pos += item->height();
1210 pos += item->height();
tests/qmltests/CMakeLists.txt−1
@@ -47,7 +47,6 @@ add_qml_test(Dash DashContent IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest
47add_qml_test(Dash DashPreview)
47add_qml_test(Dash DashPreview)
48add_qml_test(Dash GenericPreview)
48add_qml_test(Dash GenericPreview)
49add_qml_test(Dash GenericScopeView IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
49add_qml_test(Dash GenericScopeView IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
50−add_qml_test(Dash ScopeView IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
51add_qml_test(Dash FilterGrids IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins ${CMAKE_CURRENT_SOURCE_DIR}/plugins
50add_qml_test(Dash FilterGrids IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins ${CMAKE_CURRENT_SOURCE_DIR}/plugins
52 ${CMAKE_BINARY_DIR}/tests/mocks)
51 ${CMAKE_BINARY_DIR}/tests/mocks)
53add_qml_test(Dash/Apps RunningApplicationsGrid IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
52add_qml_test(Dash/Apps RunningApplicationsGrid IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
tests/qmltests/Dash/qml/FakeScopeView.qml+4−68
@@ -19,13 +19,14 @@ import Unity 0.1
19
19
20import "../../../../Dash"
20import "../../../../Dash"
21
21
22−ScopeView {
22+GenericScopeView {
23 id: fakeScopeView
23 id: fakeScopeView
24
24
25 property alias backColor : back.color
25 property alias backColor : back.color
26
26
27 onEndReached: {
27 onEndReached: {
28− if (shell != undefined && shell.scopeStatus != undefined) {
28+ if (scope != undefined && shell != undefined && shell.scopeStatus != undefined) {
29+ console.log("scope", scope)
29 shell.scopeStatus[scope.id].endReached++;
30 shell.scopeStatus[scope.id].endReached++;
30 }
31 }
31 }
32 }
@@ -44,71 +45,6 @@ ScopeView {
44 id: back
45 id: back
45 anchors.fill: parent
46 anchors.fill: parent
46 color: "grey"
47 color: "grey"
47− }
48+ z: -1
48−
49− function randomBg()
50− {
51− var hex1=new Array("4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F")
52− var bg="#"+hex1[Math.floor(Math.random()*hex1.length)]+
53− hex1[Math.floor(Math.random()*hex1.length)]+
54− hex1[Math.floor(Math.random()*hex1.length)]+
55− hex1[Math.floor(Math.random()*hex1.length)]+
56− hex1[Math.floor(Math.random()*hex1.length)]+
57− hex1[Math.floor(Math.random()*hex1.length)]
58− return bg
59− }
60−
61−
62− ListView {
63− id: listView
64− anchors.fill: parent
65− model: scope ? scope.categories : null
66− orientation: ListView.Vertical
67−
68− delegate: Column {
69− id: column
70− width: listView.width
71− height: childrenRect.height
72−
73− Rectangle {
74− width: listView.width
75− height: units.gu(3)
76− color: randomBg()
77−
78− Text {
79− text: name
80− font.family: "Ubuntu"
81− font.weight: Font.Bold
82− font.pixelSize: 20
83− anchors.horizontalCenter: parent.horizontalCenter
84− }
85− }
86− GridView {
87− id: resultsGrid
88− model: results
89− cellWidth: units.gu(10); cellHeight: units.gu(10)
90− height: childrenRect.height
91− width: listView.width
92− interactive: false
93−
94− delegate: Component {
95− id: resultDelegate
96− Item {
97− width: resultsGrid.cellWidth; height: resultsGrid.cellHeight
98− Column {
99− anchors.verticalCenter: parent.verticalCenter
100− anchors.horizontalCenter: parent.horizontalCenter
101− Image {
102− width: units.gu(5)
103− height: units.gu(5)
104− source: icon
105− anchors.horizontalCenter: parent.horizontalCenter
106− }
107− Text { text: title; anchors.horizontalCenter: parent.horizontalCenter }
108− }
109− }
110− }
111− }
112− }
113 }
49 }
114}
50}
tests/qmltests/Dash/tst_DashContent.qml+12
@@ -28,6 +28,18 @@ Item {
28
28
29 property ListModel searchHistory: ListModel {}
29 property ListModel searchHistory: ListModel {}
30
30
31+ Item {
32+ // Fake. Make a few components less noisy
33+ id: greeter
34+ signal shownChanged
35+ }
36+
37+ Item {
38+ // Fake. Make a few components less noisy
39+ id: panel
40+ signal searchClicked
41+ }
42+
31 property var scopeStatus: {
43 property var scopeStatus: {
32 'MockScope1': { 'movementStarted': 0, 'positionedAtBeginning': 0 },
44 'MockScope1': { 'movementStarted': 0, 'positionedAtBeginning': 0 },
33 'MockScope2': { 'movementStarted': 0, 'positionedAtBeginning': 0 },
45 'MockScope2': { 'movementStarted': 0, 'positionedAtBeginning': 0 },
tests/qmltests/Dash/tst_GenericScopeView.qml+7
@@ -187,6 +187,13 @@ Item {
187
187
188 closePreview();
188 closePreview();
189 }
189 }
190+
191+ function test_changeScope() {
192+ genericScopeView.scope.searchQuery = "test"
193+ genericScopeView.scope = scopes.get(1)
194+ genericScopeView.scope = scopes.get(0)
195+ tryCompare(genericScopeView.scope, "searchQuery", "")
196+ }
190 }
197 }
191 }
198 }
192}
199}
tests/qmltests/Dash/tst_ScopeView.qmldeleted−52
@@ -1,52 +0,0 @@
1−/*
2− * Copyright 2013 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.0
18−import QtTest 1.0
19−import Unity 0.1
20−import ".."
21−import "../../../Dash"
22−import Ubuntu.Components 0.1
23−
24−Item {
25− width: units.gu(120)
26− height: units.gu(80)
27−
28− Scopes {
29− id: scopes
30− }
31−
32− ScopeView {
33− id: scopeView
34− anchors.fill: parent
35−
36− TestCase {
37− name: "ScopeView"
38− when: scopes.loaded
39−
40− function init() {
41− scopeView.scope = scopes.get(0)
42− }
43−
44− function test_changeScope() {
45− scopeView.scope.searchQuery = "test"
46− scopeView.scope = scopes.get(1)
47− scopeView.scope = scopes.get(0)
48− tryCompare(scopeView.scope, "searchQuery", "")
49− }
50− }
51− }
52−}