on xenial help sign in
Patching in single-preview
19ea80eAndrea Cimitan
debian/control+2−2
@@ -29,7 +29,7 @@ Build-Depends: cmake,
29 libqt5xmlpatterns5-dev,
29 libqt5xmlpatterns5-dev,
30 libsystemsettings-dev,
30 libsystemsettings-dev,
31 libudev-dev,
31 libudev-dev,
32− libunity-api-dev (>= 7.106),
32+ libunity-api-dev (>= 7.107),
33 libusermetricsoutput1-dev,
33 libusermetricsoutput1-dev,
34# Need those X11 libs touch emulation from mouse events in manual QML tests on a X11 desktop
34# Need those X11 libs touch emulation from mouse events in manual QML tests on a X11 desktop
35 libx11-dev[!armhf],
35 libx11-dev[!armhf],
@@ -135,7 +135,7 @@ Depends: qml-module-qtquick-layouts,
135 unity-application-impl-12,
135 unity-application-impl-12,
136 unity-notifications-impl-3,
136 unity-notifications-impl-3,
137 unity-plugin-scopes | unity-scopes-impl,
137 unity-plugin-scopes | unity-scopes-impl,
138− unity-scopes-impl-10,
138+ unity-scopes-impl-11,
139 unity8-fake-env | unity-application-impl,
139 unity8-fake-env | unity-application-impl,
140 ${misc:Depends},
140 ${misc:Depends},
141Breaks: unity8 (<< 7.86),
141Breaks: unity8 (<< 7.86),
qml/Dash/GenericScopeView.qml+13−41
@@ -73,49 +73,30 @@ FocusScope {
73 }
73 }
74
74
75 property var maybePreviewResult;
75 property var maybePreviewResult;
76− property int maybePreviewIndex;
77− property var maybePreviewResultsModel;
78− property int maybePreviewLimitedCategoryItemCount;
79 property string maybePreviewCategoryId;
76 property string maybePreviewCategoryId;
80
77
81 function clearMaybePreviewData() {
78 function clearMaybePreviewData() {
82 scopeView.maybePreviewResult = undefined;
79 scopeView.maybePreviewResult = undefined;
83− scopeView.maybePreviewIndex = -1;
84− scopeView.maybePreviewResultsModel = undefined;
85− scopeView.maybePreviewLimitedCategoryItemCount = -1;
86 scopeView.maybePreviewCategoryId = "";
80 scopeView.maybePreviewCategoryId = "";
87 }
81 }
88
82
89− function itemClicked(index, result, itemModel, resultsModel, limitedCategoryItemCount, categoryId) {
83+ function itemClicked(result, categoryId) {
90 scopeView.maybePreviewResult = result;
84 scopeView.maybePreviewResult = result;
91− scopeView.maybePreviewIndex = index;
92− scopeView.maybePreviewResultsModel = resultsModel;
93− scopeView.maybePreviewLimitedCategoryItemCount = limitedCategoryItemCount;
94 scopeView.maybePreviewCategoryId = categoryId;
85 scopeView.maybePreviewCategoryId = categoryId;
95
86
96 scope.activate(result, categoryId);
87 scope.activate(result, categoryId);
97 }
88 }
98
89
99− function itemPressedAndHeld(index, result, resultsModel, limitedCategoryItemCount, categoryId) {
90+ function itemPressedAndHeld(result, categoryId) {
100 clearMaybePreviewData();
91 clearMaybePreviewData();
101
92
102− openPreview(result, index, resultsModel, limitedCategoryItemCount, categoryId);
93+ openPreview(result, categoryId);
103 }
94 }
104
95
105− function openPreview(result, index, resultsModel, limitedCategoryItemCount, categoryId) {
96+ function openPreview(result, categoryId) {
106− var previewStack = scope.preview(result, categoryId);
97+ var previewModel = scope.preview(result, categoryId);
107− if (previewStack) {
98+ if (previewModel) {
108− if (limitedCategoryItemCount > 0) {
99+ subPageLoader.previewModel = previewModel;
109− previewLimitModel.model = resultsModel;
110− previewLimitModel.limit = limitedCategoryItemCount;
111− subPageLoader.model = previewLimitModel;
112− } else {
113− subPageLoader.model = resultsModel;
114− }
115− subPageLoader.initialIndex = -1;
116− subPageLoader.initialIndex = index;
117− subPageLoader.categoryId = categoryId;
118− subPageLoader.previewStack = previewStack;
119 subPageLoader.openSubPage("preview");
100 subPageLoader.openSubPage("preview");
120 }
101 }
121 }
102 }
@@ -166,9 +147,6 @@ FocusScope {
166 onPreviewRequested: { // (QVariant const& result)
147 onPreviewRequested: { // (QVariant const& result)
167 if (result === scopeView.maybePreviewResult) {
148 if (result === scopeView.maybePreviewResult) {
168 openPreview(result,
149 openPreview(result,
169− scopeView.maybePreviewIndex,
170− scopeView.maybePreviewResultsModel,
171− scopeView.maybePreviewLimitedCategoryItemCount,
172 scopeView.maybePreviewCategoryId);
150 scopeView.maybePreviewCategoryId);
173
151
174 clearMaybePreviewData();
152 clearMaybePreviewData();
@@ -390,11 +368,11 @@ FocusScope {
390 Connections {
368 Connections {
391 target: rendererLoader.item
369 target: rendererLoader.item
392 onClicked: { // (int index, var result, var item, var itemModel)
370 onClicked: { // (int index, var result, var item, var itemModel)
393− scopeView.itemClicked(index, result, itemModel, target.model, categoryItemCount(), baseItem.category);
371+ scopeView.itemClicked(result, baseItem.category);
394 }
372 }
395
373
396 onPressAndHold: { // (int index, var result, var itemModel)
374 onPressAndHold: { // (int index, var result, var itemModel)
397− scopeView.itemPressedAndHeld(index, result, target.model, categoryItemCount(), baseItem.category);
375+ scopeView.itemPressedAndHeld(result, baseItem.category);
398 }
376 }
399
377
400 function categoryItemCount() {
378 function categoryItemCount() {
@@ -768,13 +746,10 @@ FocusScope {
768 property var scope: scopeView.scope
746 property var scope: scopeView.scope
769 property var scopeStyle: scopeView.scopeStyle
747 property var scopeStyle: scopeView.scopeStyle
770 property int initialIndex: -1
748 property int initialIndex: -1
771− property var previewStack;
749+ property var previewModel;
772− property string categoryId
773− property var model: null
774
750
775 readonly property bool processing: item && item.processing || false
751 readonly property bool processing: item && item.processing || false
776 readonly property int count: item && item.count || 0
752 readonly property int count: item && item.count || 0
777− readonly property int currentIndex: item && item.currentIndex || 0
778 readonly property var currentItem: item && item.currentItem || null
753 readonly property var currentItem: item && item.currentItem || null
779
754
780 property string subPage: ""
755 property string subPage: ""
@@ -789,7 +764,7 @@ FocusScope {
789 }
764 }
790
765
791 source: switch(subPage) {
766 source: switch(subPage) {
792− case "preview": return "PreviewListView.qml";
767+ case "preview": return "PreviewView.qml";
793 case "settings": return "ScopeSettingsPage.qml";
768 case "settings": return "ScopeSettingsPage.qml";
794 default: return "";
769 default: return "";
795 }
770 }
@@ -799,11 +774,8 @@ FocusScope {
799 item.scopeStyle = Qt.binding(function() { return subPageLoader.scopeStyle; } )
774 item.scopeStyle = Qt.binding(function() { return subPageLoader.scopeStyle; } )
800 if (subPage == "preview") {
775 if (subPage == "preview") {
801 item.open = Qt.binding(function() { return subPageLoader.open; } )
776 item.open = Qt.binding(function() { return subPageLoader.open; } )
802− item.initialIndex = Qt.binding(function() { return subPageLoader.initialIndex; } )
777+ item.previewModel = subPageLoader.previewModel;
803− item.model = Qt.binding(function() { return subPageLoader.model; } )
778+ subPageLoader.previewModel = null;
804− item.categoryId = Qt.binding(function() { return subPageLoader.categoryId; } )
805− item.initialIndexPreviewStack = subPageLoader.previewStack;
806− subPageLoader.previewStack = null;
807 }
779 }
808 open = true;
780 open = true;
809 }
781 }
qml/Dash/PreviewListView.qml+24−67
@@ -23,20 +23,14 @@ import "Previews" as Previews
23Item {
23Item {
24 id: root
24 id: root
25
25
26− property int initialIndex: -1
26+ property bool open: false
27− property var initialIndexPreviewStack: null
28 property var scope: null
27 property var scope: null
29 property var scopeStyle: null
28 property var scopeStyle: null
30− property string categoryId
31− property bool usedInitialIndex: false
32
29
33 property alias showSignatureLine: header.showSignatureLine
30 property alias showSignatureLine: header.showSignatureLine
34
31
35− property alias open: previewListView.open
32+ property alias currentItem: previewLoader.item
36− property alias model: previewListView.model
33+ property var previewModel
37− property alias currentIndex: previewListView.currentIndex
38− property alias currentItem: previewListView.currentItem
39− property alias count: previewListView.count
40
34
41 readonly property bool processing: currentItem && (!currentItem.previewModel.loaded
35 readonly property bool processing: currentItem && (!currentItem.previewModel.loaded
42 || currentItem.previewModel.processingAction)
36 || currentItem.previewModel.processingAction)
@@ -55,73 +49,36 @@ Item {
55 onBackClicked: root.backClicked()
49 onBackClicked: root.backClicked()
56 }
50 }
57
51
58− ListView {
52+ onOpenChanged: {
59− id: previewListView
53+ if (!open) {
54+ // Cancel any pending preview requests or actions
55+ if (currentItem && currentItem.previewData !== undefined) {
56+ currentItem.previewData.cancelAction();
57+ }
58+ root.scope.cancelActivation();
59+ }
60+ }
61+
62+ Loader {
63+ id: previewLoader
60− objectName: "listView"
64+ objectName: "loader"
61 anchors {
65 anchors {
62 top: header.bottom
66 top: header.bottom
63 bottom: parent.bottom
67 bottom: parent.bottom
64 left: parent.left
68 left: parent.left
65 right: parent.right
69 right: parent.right
66 }
70 }
67− orientation: ListView.Horizontal
68− highlightRangeMode: ListView.StrictlyEnforceRange
69− snapMode: ListView.SnapOneItem
70− boundsBehavior: Flickable.DragAndOvershootBounds
71− highlightMoveDuration: 250
72− flickDeceleration: units.gu(625)
73− maximumFlickVelocity: width * 5
74− cacheBuffer: 0
75−
76− property bool open: false
77
71
78− onOpenChanged: {
79− if (!open) {
80− // Cancel any pending preview requests or actions
81− if (previewListView.currentItem && previewListView.currentItem.previewData !== undefined) {
82− previewListView.currentItem.previewData.cancelAction();
83− }
84− root.scope.cancelActivation();
85− model = undefined;
86− }
87− }
88−
89− onModelChanged: {
90− if (count > 0 && initialIndex >= 0 && !usedInitialIndex) {
91− usedInitialIndex = true;
92− previewListView.positionViewAtIndex(initialIndex, ListView.SnapPosition);
93− }
94− }
95−
96− delegate: Previews.Preview {
72+ sourceComponent: Previews.Preview {
97 id: preview
73 id: preview
98− objectName: "preview" + index
74+ objectName: "preview"
99− height: previewListView.height
75+ height: previewLoader.height
100− width: previewListView.width
76+ width: previewLoader.width
101−
102− isCurrent: ListView.isCurrentItem
103−
104− readonly property var previewStack: {
105− if (root.open) {
106− if (index === root.initialIndex) {
107− return root.initialIndexPreviewStack;
108− } else {
109− return root.scope.preview(result, root.categoryId);
110− }
111− } else {
112− return null;
113− }
114− }
115−
116− previewModel: {
117− if (previewStack) {
118− return previewStack.getPreviewModel(0);
119− } else {
120− return null;
121− }
122− }
77+ }
123
78
124− scopeStyle: root.scopeStyle
79+ onLoaded: {
80+ item.scopeStyle = Qt.binding(function() { return root.scopeStyle; });
81+ item.previewModel = Qt.binding(function() { return root.previewModel; });
125 }
82 }
126 }
83 }
127
84
qml/Dash/Previews/Preview.qml−4
@@ -34,9 +34,6 @@ Item {
34 */
34 */
35 property var previewModel
35 property var previewModel
36
36
37− //! \brief Should be set to true if this preview is currently displayed.
38− property bool isCurrent: false
39−
40 //! \brief The ScopeStyle component.
37 //! \brief The ScopeStyle component.
41 property var scopeStyle: null
38 property var scopeStyle: null
42
39
@@ -88,7 +85,6 @@ Item {
88 widgetId: model.widgetId
85 widgetId: model.widgetId
89 widgetType: model.type
86 widgetType: model.type
90 widgetData: model.properties
87 widgetData: model.properties
91− isCurrentPreview: root.isCurrent
92 scopeStyle: root.scopeStyle
88 scopeStyle: root.scopeStyle
93 parentFlickable: column
89 parentFlickable: column
94
90
qml/Dash/Previews/PreviewExpandable.qml−1
@@ -84,7 +84,6 @@ PreviewWidget {
84 widgetId: model.widgetId
84 widgetId: model.widgetId
85 widgetType: model.type
85 widgetType: model.type
86 widgetData: model.properties
86 widgetData: model.properties
87− isCurrentPreview: root.isCurrentPreview
88 scopeStyle: root.scopeStyle
87 scopeStyle: root.scopeStyle
89 anchors {
88 anchors {
90 left: parent.left
89 left: parent.left
qml/Dash/Previews/PreviewRatingEdit.qml−1
@@ -68,7 +68,6 @@ PreviewWidget {
68
68
69 widgetId: root.widgetId
69 widgetId: root.widgetId
70 widgetData: root.widgetData
70 widgetData: root.widgetData
71− isCurrentPreview: root.isCurrentPreview
72 scopeStyle: root.scopeStyle
71 scopeStyle: root.scopeStyle
73
72
74 ratingValue: widgetData["rating"]
73 ratingValue: widgetData["rating"]
qml/Dash/Previews/PreviewWidget.qml−3
@@ -19,9 +19,6 @@ import QtQuick 2.4
19/*! Interface for preview widgets. */
19/*! Interface for preview widgets. */
20
20
21Item {
21Item {
22− //! Specifies the preview widget being currently used or not
23− property bool isCurrentPreview: true
24−
25 //! The widget identifier
22 //! The widget identifier
26 property string widgetId
23 property string widgetId
27
24
qml/Dash/Previews/PreviewWidgetFactory.qml−4
@@ -37,9 +37,6 @@ Loader {
37 //! Should the widget show in expanded mode (For those that support it)
37 //! Should the widget show in expanded mode (For those that support it)
38 property bool expanded: widgetType !== "expandable" || widgetData["expanded"] === true
38 property bool expanded: widgetType !== "expandable" || widgetData["expanded"] === true
39
39
40− //! Set to true if the parent preview is displayed.
41− property bool isCurrentPreview: false
42−
43 //! Set margins width.
40 //! Set margins width.
44 property real widgetMargins: status === Loader.Ready ? item.widgetMargins : units.gu(1)
41 property real widgetMargins: status === Loader.Ready ? item.widgetMargins : units.gu(1)
45
42
@@ -82,7 +79,6 @@ Loader {
82 onLoaded: {
79 onLoaded: {
83 item.widgetId = Qt.binding(function() { return root.widgetId } )
80 item.widgetId = Qt.binding(function() { return root.widgetId } )
84 item.widgetData = Qt.binding(function() { return root.widgetData } )
81 item.widgetData = Qt.binding(function() { return root.widgetData } )
85− item.isCurrentPreview = Qt.binding(function() { return root.isCurrentPreview } )
86 item.expanded = Qt.binding(function() { return root.expanded } )
82 item.expanded = Qt.binding(function() { return root.expanded } )
87 item.scopeStyle = Qt.binding(function() { return root.scopeStyle } )
83 item.scopeStyle = Qt.binding(function() { return root.scopeStyle } )
88 item.parentFlickable = Qt.binding(function() { return root.parentFlickable } )
84 item.parentFlickable = Qt.binding(function() { return root.parentFlickable } )
tests/mocks/Unity/CMakeLists.txt+1−3
@@ -7,7 +7,7 @@ add_subdirectory(Notifications)
7add_subdirectory(DashCommunicator)
7add_subdirectory(DashCommunicator)
8
8
9pkg_search_module(GOBJECT gobject-2.0 REQUIRED)
9pkg_search_module(GOBJECT gobject-2.0 REQUIRED)
10−pkg_check_modules(SCOPES_API REQUIRED unity-shell-scopes=10)
10+pkg_check_modules(SCOPES_API REQUIRED unity-shell-scopes=11)
11
11
12include_directories(
12include_directories(
13 ${CMAKE_CURRENT_BINARY_DIR}
13 ${CMAKE_CURRENT_BINARY_DIR}
@@ -27,13 +27,11 @@ set(UnityQML_SOURCES
27 fake_navigation.cpp
27 fake_navigation.cpp
28 fake_resultsmodel.cpp
28 fake_resultsmodel.cpp
29 fake_previewmodel.cpp
29 fake_previewmodel.cpp
30− fake_previewstack.cpp
31 fake_previewwidgetmodel.cpp
30 fake_previewwidgetmodel.cpp
32 fake_unity_plugin.cpp
31 fake_unity_plugin.cpp
33 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/CategoriesInterface.h
32 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/CategoriesInterface.h
34 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/NavigationInterface.h
33 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/NavigationInterface.h
35 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewModelInterface.h
34 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewModelInterface.h
36− ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewStackInterface.h
37 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewWidgetModelInterface.h
35 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewWidgetModelInterface.h
38 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ResultsModelInterface.h
36 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ResultsModelInterface.h
39 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ScopeInterface.h
37 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ScopeInterface.h
tests/mocks/Unity/Unity.qmltypes+33−50
@@ -1,4 +1,4 @@
1−import QtQuick.tooling 1.1
1+import QtQuick.tooling 1.2
2
2
3// This file describes the plugin-supplied types contained in the library.
3// This file describes the plugin-supplied types contained in the library.
4// It is used for QML tooling purposes only.
4// It is used for QML tooling purposes only.
@@ -7,17 +7,10 @@ import QtQuick.tooling 1.1
7// 'qmlplugindump -notrelocatable Unity 0.2 tests/mocks'
7// 'qmlplugindump -notrelocatable Unity 0.2 tests/mocks'
8
8
9Module {
9Module {
10+ dependencies: ["QtQuick 2.4", "Unity.Indicators 0.1"]
10 Component {
11 Component {
11 name: "Categories"
12 name: "Categories"
12 prototype: "unity::shell::scopes::CategoriesInterface"
13 prototype: "unity::shell::scopes::CategoriesInterface"
13− Method {
14− name: "addSpecialCategory"
15− Parameter { name: "categoryId"; type: "string" }
16− Parameter { name: "name"; type: "string" }
17− Parameter { name: "icon"; type: "string" }
18− Parameter { name: "rawTemplate"; type: "string" }
19− Parameter { name: "countObject"; type: "QObject"; isPointer: true }
20− }
21 Method {
14 Method {
22 name: "overrideCategoryJson"
15 name: "overrideCategoryJson"
23 type: "bool"
16 type: "bool"
@@ -60,18 +53,6 @@ Module {
60 Parameter { type: "bool" }
53 Parameter { type: "bool" }
61 }
54 }
62 }
55 }
63− Component {
64− name: "PreviewStack"
65− prototype: "unity::shell::scopes::PreviewStackInterface"
66− exports: ["Unity/PreviewStack 0.2"]
67− isCreatable: false
68− exportMetaObjectRevisions: [0]
69− Method {
70− name: "getPreviewModel"
71− type: "unity::shell::scopes::PreviewModelInterface*"
72− Parameter { name: "index"; type: "int" }
73− }
74− }
75 Component {
56 Component {
76 name: "PreviewWidgetModel"
57 name: "PreviewWidgetModel"
77 prototype: "unity::shell::scopes::PreviewWidgetModelInterface"
58 prototype: "unity::shell::scopes::PreviewWidgetModelInterface"
@@ -95,11 +76,11 @@ Module {
95 prototype: "unity::shell::scopes::ScopeInterface"
76 prototype: "unity::shell::scopes::ScopeInterface"
96 exports: ["Unity/MockScope 0.2"]
77 exports: ["Unity/MockScope 0.2"]
97 exportMetaObjectRevisions: [0]
78 exportMetaObjectRevisions: [0]
79+ Signal { name: "refreshed" }
98 Signal {
80 Signal {
99− name: "performQuery"
81+ name: "queryPerformed"
100 Parameter { name: "query"; type: "string" }
82 Parameter { name: "query"; type: "string" }
101 }
83 }
102− Signal { name: "refreshed" }
103 Method {
84 Method {
104 name: "setId"
85 name: "setId"
105 Parameter { name: "id"; type: "string" }
86 Parameter { name: "id"; type: "string" }
@@ -115,11 +96,13 @@ Module {
115 Method {
96 Method {
116 name: "activate"
97 name: "activate"
117 Parameter { name: "result"; type: "QVariant" }
98 Parameter { name: "result"; type: "QVariant" }
99+ Parameter { name: "categoryId"; type: "string" }
118 }
100 }
119 Method {
101 Method {
120 name: "preview"
102 name: "preview"
121− type: "PreviewStack*"
103+ type: "PreviewModel*"
122 Parameter { name: "result"; type: "QVariant" }
104 Parameter { name: "result"; type: "QVariant" }
105+ Parameter { name: "categoryId"; type: "string" }
123 }
106 }
124 Method { name: "cancelActivation" }
107 Method { name: "cancelActivation" }
125 Method {
108 Method {
@@ -142,6 +125,12 @@ Module {
142 Parameter { name: "isAltNavigation"; type: "bool" }
125 Parameter { name: "isAltNavigation"; type: "bool" }
143 }
126 }
144 Method { name: "refresh" }
127 Method { name: "refresh" }
128+ Method {
129+ name: "activateAction"
130+ Parameter { name: "result"; type: "QVariant" }
131+ Parameter { name: "categoryId"; type: "string" }
132+ Parameter { name: "actionId"; type: "string" }
133+ }
145 }
134 }
146 Component {
135 Component {
147 name: "Scopes"
136 name: "Scopes"
@@ -181,6 +170,10 @@ Module {
181 Parameter { name: "scopeId"; type: "string" }
170 Parameter { name: "scopeId"; type: "string" }
182 Parameter { name: "index"; type: "int" }
171 Parameter { name: "index"; type: "int" }
183 }
172 }
173+ Method {
174+ name: "closeScope"
175+ Parameter { name: "scope"; type: "unity::shell::scopes::ScopeInterface"; isPointer: true }
176+ }
184 Method {
177 Method {
185 name: "getScopeFromAll"
178 name: "getScopeFromAll"
186 type: "Scope*"
179 type: "Scope*"
@@ -214,14 +207,6 @@ Module {
214 Parameter { name: "categoryId"; type: "string" }
207 Parameter { name: "categoryId"; type: "string" }
215 Parameter { name: "json"; type: "string" }
208 Parameter { name: "json"; type: "string" }
216 }
209 }
217− Method {
218− name: "addSpecialCategory"
219− Parameter { name: "categoryId"; type: "string" }
220− Parameter { name: "name"; type: "string" }
221− Parameter { name: "icon"; type: "string" }
222− Parameter { name: "rawTemplate"; type: "string" }
223− Parameter { name: "countObject"; type: "QObject"; isPointer: true }
224− }
225 }
210 }
226 Component {
211 Component {
227 name: "unity::shell::scopes::NavigationInterface"
212 name: "unity::shell::scopes::NavigationInterface"
@@ -270,22 +255,6 @@ Module {
270 Parameter { type: "QVariantMap" }
255 Parameter { type: "QVariantMap" }
271 }
256 }
272 }
257 }
273− Component {
274− name: "unity::shell::scopes::PreviewStackInterface"
275− prototype: "QAbstractListModel"
276− Enum {
277− name: "Roles"
278− values: {
279− "RolePreviewModel": 0
280− }
281− }
282− Property { name: "widgetColumnCount"; type: "int" }
283− Method {
284− name: "getPreviewModel"
285− type: "unity::shell::scopes::PreviewModelInterface*"
286− Parameter { name: "index"; type: "int" }
287− }
288− }
289 Component {
258 Component {
290 name: "unity::shell::scopes::PreviewWidgetModelInterface"
259 name: "unity::shell::scopes::PreviewWidgetModelInterface"
291 prototype: "QAbstractListModel"
260 prototype: "QAbstractListModel"
@@ -316,7 +285,8 @@ Module {
316 "RoleSummary": 9,
285 "RoleSummary": 9,
317 "RoleAttributes": 10,
286 "RoleAttributes": 10,
318 "RoleBackground": 11,
287 "RoleBackground": 11,
319− "RoleOverlayColor": 12
288+ "RoleOverlayColor": 12,
289+ "RoleQuickPreviewData": 13
320 }
290 }
321 }
291 }
322 Property { name: "categoryId"; type: "string" }
292 Property { name: "categoryId"; type: "string" }
@@ -343,6 +313,7 @@ Module {
343 Property { name: "description"; type: "string"; isReadonly: true }
313 Property { name: "description"; type: "string"; isReadonly: true }
344 Property { name: "searchHint"; type: "string"; isReadonly: true }
314 Property { name: "searchHint"; type: "string"; isReadonly: true }
345 Property { name: "searchInProgress"; type: "bool"; isReadonly: true }
315 Property { name: "searchInProgress"; type: "bool"; isReadonly: true }
316+ Property { name: "activationInProgress"; type: "bool"; isReadonly: true }
346 Property { name: "favorite"; type: "bool" }
317 Property { name: "favorite"; type: "bool" }
347 Property { name: "shortcut"; type: "string"; isReadonly: true }
318 Property { name: "shortcut"; type: "string"; isReadonly: true }
348 Property {
319 Property {
@@ -393,11 +364,13 @@ Module {
393 Method {
364 Method {
394 name: "activate"
365 name: "activate"
395 Parameter { name: "result"; type: "QVariant" }
366 Parameter { name: "result"; type: "QVariant" }
367+ Parameter { name: "categoryId"; type: "string" }
396 }
368 }
397 Method {
369 Method {
398 name: "preview"
370 name: "preview"
399− type: "unity::shell::scopes::PreviewStackInterface*"
371+ type: "unity::shell::scopes::PreviewModelInterface*"
400 Parameter { name: "result"; type: "QVariant" }
372 Parameter { name: "result"; type: "QVariant" }
373+ Parameter { name: "categoryId"; type: "string" }
401 }
374 }
402 Method { name: "cancelActivation" }
375 Method { name: "cancelActivation" }
403 Method {
376 Method {
@@ -424,6 +397,12 @@ Module {
424 Parameter { name: "cannedQuery"; type: "string" }
397 Parameter { name: "cannedQuery"; type: "string" }
425 }
398 }
426 Method { name: "refresh" }
399 Method { name: "refresh" }
400+ Method {
401+ name: "activateAction"
402+ Parameter { name: "result"; type: "QVariant" }
403+ Parameter { name: "categoryId"; type: "string" }
404+ Parameter { name: "actionId"; type: "string" }
405+ }
427 }
406 }
428 Component {
407 Component {
429 name: "unity::shell::scopes::ScopesInterface"
408 name: "unity::shell::scopes::ScopesInterface"
@@ -464,6 +443,10 @@ Module {
464 Parameter { name: "scopeId"; type: "string" }
443 Parameter { name: "scopeId"; type: "string" }
465 Parameter { name: "index"; type: "int" }
444 Parameter { name: "index"; type: "int" }
466 }
445 }
446+ Method {
447+ name: "closeScope"
448+ Parameter { name: "scope"; type: "unity::shell::scopes::ScopeInterface"; isPointer: true }
449+ }
467 }
450 }
468 Component {
451 Component {
469 name: "unity::shell::scopes::SettingsModelInterface"
452 name: "unity::shell::scopes::SettingsModelInterface"
tests/mocks/Unity/fake_previewstack.cppdeleted−68
@@ -1,68 +0,0 @@
1−/*
2− * Copyright (C) 2014 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−// self
18−#include "fake_previewstack.h"
19−
20−// local
21−#include "fake_previewmodel.h"
22−#include "fake_scope.h"
23−
24−PreviewStack::PreviewStack(Scope *scope)
25− : unity::shell::scopes::PreviewStackInterface(nullptr)
26−{
27− m_previews << new PreviewModel(this, scope);
28−}
29−
30−PreviewStack::~PreviewStack()
31−{
32−}
33−
34−void PreviewStack::setWidgetColumnCount(int columnCount)
35−{
36− if (columnCount != 1) {
37− qFatal("PreviewStack::setWidgetColumnCount != 1 not implemented");
38− }
39−}
40−
41−int PreviewStack::widgetColumnCount() const
42−{
43− return 1;
44−}
45−
46−int PreviewStack::rowCount(const QModelIndex&) const
47−{
48− return m_previews.size();
49−}
50−
51−unity::shell::scopes::PreviewModelInterface* PreviewStack::getPreviewModel(int index) const
52−{
53− if (index >= m_previews.size()) {
54− return nullptr;
55− }
56−
57− return m_previews.at(index);
58−}
59−
60−QVariant PreviewStack::data(const QModelIndex& index, int role) const
61−{
62− switch (role) {
63− case RolePreviewModel:
64− return QVariant::fromValue(m_previews.at(index.row()));
65− default:
66− return QVariant();
67− }
68−}
tests/mocks/Unity/fake_previewstack.hdeleted−52
@@ -1,52 +0,0 @@
1−/*
2− * Copyright (C) 2014 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−
18−#ifndef FAKE_PREVIEWSTACK_H
19−#define FAKE_PREVIEWSTACK_H
20−
21−#include <unity/shell/scopes/PreviewStackInterface.h>
22−
23−#include <QSharedPointer>
24−#include <QVariantMap>
25−
26−class PreviewModel;
27−
28−class Scope;
29−
30−class PreviewStack : public unity::shell::scopes::PreviewStackInterface
31−{
32− Q_OBJECT
33−
34−public:
35− explicit PreviewStack(Scope* scope = 0);
36− virtual ~PreviewStack();
37−
38− QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
39− int rowCount(const QModelIndex& parent = QModelIndex()) const override;
40−
41− Q_INVOKABLE unity::shell::scopes::PreviewModelInterface* getPreviewModel(int index) const override;
42−
43− void setWidgetColumnCount(int columnCount) override;
44− int widgetColumnCount() const override;
45−
46−private:
47− QList<PreviewModel*> m_previews;
48−};
49−
50−Q_DECLARE_METATYPE(PreviewStack*)
51−
52−#endif // FAKE_PREVIEWSTACK_H
tests/mocks/Unity/fake_scope.cpp+2−2
@@ -199,14 +199,14 @@ void Scope::activate(QVariant const& result, QString const& categoryId)
199 }
199 }
200}
200}
201
201
202−PreviewStack* Scope::preview(QVariant const& result, QString const& /*categoryId*/)
202+PreviewModel* Scope::preview(QVariant const& result, QString const& /*categoryId*/)
203{
203{
204 Q_UNUSED(result);
204 Q_UNUSED(result);
205
205
206 if (m_returnNullPreview) {
206 if (m_returnNullPreview) {
207 return nullptr;
207 return nullptr;
208 } else {
208 } else {
209− return new PreviewStack(this);
209+ return new PreviewModel(this);
210 }
210 }
211}
211}
212
212
tests/mocks/Unity/fake_scope.h+2−2
@@ -20,7 +20,7 @@
20#include <unity/shell/scopes/ScopeInterface.h>
20#include <unity/shell/scopes/ScopeInterface.h>
21
21
22#include "fake_categories.h"
22#include "fake_categories.h"
23−#include "fake_previewstack.h"
23+#include "fake_previewmodel.h"
24
24
25#include <QTimer>
25#include <QTimer>
26
26
@@ -62,7 +62,7 @@ public:
62 Q_INVOKABLE void setSearchInProgress(const bool inProg); // This is not invokable in the Interface, here for testing benefits
62 Q_INVOKABLE void setSearchInProgress(const bool inProg); // This is not invokable in the Interface, here for testing benefits
63
63
64 Q_INVOKABLE void activate(QVariant const& result, QString const& categoryId) override;
64 Q_INVOKABLE void activate(QVariant const& result, QString const& categoryId) override;
65− Q_INVOKABLE PreviewStack* preview(QVariant const& result, QString const& categoryId) override;
65+ Q_INVOKABLE PreviewModel* preview(QVariant const& result, QString const& categoryId) override;
66 Q_INVOKABLE void cancelActivation() override;
66 Q_INVOKABLE void cancelActivation() override;
67 Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface* scope) override;
67 Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface* scope) override;
68
68
tests/mocks/Unity/fake_unity_plugin.cpp+1−2
@@ -47,10 +47,9 @@ void FakeUnityPlugin::registerTypes(const char *uri)
47 qmlRegisterUncreatableType<unity::shell::scopes::SettingsModelInterface>(uri, 0, 2, "SettingsModel", "Can't create SettingsModel object in QML.");
47 qmlRegisterUncreatableType<unity::shell::scopes::SettingsModelInterface>(uri, 0, 2, "SettingsModel", "Can't create SettingsModel object in QML.");
48 qmlRegisterUncreatableType<unity::shell::scopes::NavigationInterface>(uri, 0, 2, "Navigation", "Can't create Navigation object in QML.");
48 qmlRegisterUncreatableType<unity::shell::scopes::NavigationInterface>(uri, 0, 2, "Navigation", "Can't create Navigation object in QML.");
49 qmlRegisterUncreatableType<unity::shell::scopes::CategoriesInterface>(uri, 0, 2, "Categories", "Can't create Categories object in QML.");
49 qmlRegisterUncreatableType<unity::shell::scopes::CategoriesInterface>(uri, 0, 2, "Categories", "Can't create Categories object in QML.");
50− qmlRegisterUncreatableType<unity::shell::scopes::PreviewModelInterface>(uri, 0, 2, "PreviewModel", "Can't create new PreviewModel in QML. Get them from PreviewStack instance.");
50+ qmlRegisterUncreatableType<unity::shell::scopes::PreviewModelInterface>(uri, 0, 2, "PreviewModel", "Can't create new PreviewModel in QML. Get them from Scope instance.");
51 qmlRegisterUncreatableType<ResultsModel>(uri, 0, 2, "ResultsModel", "Can't create ResultsModel object in QML.");
51 qmlRegisterUncreatableType<ResultsModel>(uri, 0, 2, "ResultsModel", "Can't create ResultsModel object in QML.");
52 qmlRegisterType<ResultsModel>(uri, 0, 2, "FakeResultsModel");
52 qmlRegisterType<ResultsModel>(uri, 0, 2, "FakeResultsModel");
53 qmlRegisterType<PreviewModel>(uri, 0, 2, "FakePreviewModel");
53 qmlRegisterType<PreviewModel>(uri, 0, 2, "FakePreviewModel");
54 qmlRegisterUncreatableType<PreviewWidgetModel>(uri, 0, 2, "PreviewWidgetModel", "Can't create new PreviewWidgetModel in QML. Get them from PreviewModel instance.");
54 qmlRegisterUncreatableType<PreviewWidgetModel>(uri, 0, 2, "PreviewWidgetModel", "Can't create new PreviewWidgetModel in QML. Get them from PreviewModel instance.");
55− qmlRegisterUncreatableType<PreviewStack>(uri, 0, 2, "PreviewStack", "Can't create new PreviewStack in QML. Get them from Scope instance.");
56}
55}
tests/qmltests/CMakeLists.txt+1−1
@@ -28,7 +28,7 @@ add_unity8_qmlbenchmark(Dash CardBenchmark 1000)
28add_unity8_qmltest(Dash CardTool)
28add_unity8_qmltest(Dash CardTool)
29add_unity8_qmltest(Dash GenericScopeView)
29add_unity8_qmltest(Dash GenericScopeView)
30add_unity8_qmltest(Dash DashPageHeader)
30add_unity8_qmltest(Dash DashPageHeader)
31−add_unity8_qmltest(Dash PreviewListView)
31+add_unity8_qmltest(Dash PreviewView)
32add_unity8_qmltest(Dash/Previews Preview)
32add_unity8_qmltest(Dash/Previews Preview)
33add_unity8_qmltest(Dash/Previews PreviewActions)
33add_unity8_qmltest(Dash/Previews PreviewActions)
34add_unity8_qmltest(Dash/Previews PreviewAudioPlayback)
34add_unity8_qmltest(Dash/Previews PreviewAudioPlayback)
tests/qmltests/Dash/tst_PreviewListView.qml+25−16
@@ -36,8 +36,8 @@ Rectangle {
36 id: mockResultsModel
36 id: mockResultsModel
37 }
37 }
38
38
39− PreviewListView {
39+ PreviewView {
40− id: listView
40+ id: view
41 anchors.fill: parent
41 anchors.fill: parent
42 scope: mockScope
42 scope: mockScope
43 scopeStyle: ScopeStyle {
43 scopeStyle: ScopeStyle {
@@ -45,12 +45,23 @@ Rectangle {
45 }
45 }
46 }
46 }
47
47
48+ Item {
49+ Repeater {
50+ id: repeater
51+ model: mockResultsModel
52+ Item {
53+ property var previewModel: mockScope.preview(model.result, model.categoryId);
54+ }
55+ }
56+ }
57+
58+
48 UT.UnityTestCase {
59 UT.UnityTestCase {
49 id: testCase
60 id: testCase
50− name: "PreviewListView"
61+ name: "PreviewView"
51 when: windowShown
62 when: windowShown
52
63
53− property MouseArea mouseArea: findChild(listView, "processingMouseArea")
64+ property MouseArea mouseArea: findChild(view, "processingMouseArea")
54
65
55 SignalSpy {
66 SignalSpy {
56 id: clickedSpy
67 id: clickedSpy
@@ -59,43 +70,41 @@ Rectangle {
59 }
70 }
60
71
61 function init() {
72 function init() {
62− listView.model = mockResultsModel;
63− listView.currentIndex = 1;
64− listView.open = true;
73+ view.open = true;
74+ view.previewModel = repeater.itemAt(0).previewModel
65 verify(testCase.mouseArea, "Can't find the processingMouseArea object.");
75 verify(testCase.mouseArea, "Can't find the processingMouseArea object.");
66 }
76 }
67
77
68 function cleanup() {
78 function cleanup() {
69− listView.open = false;
79+ view.open = false;
70− listView.model = null;
71 clickedSpy.clear();
80 clickedSpy.clear();
72 }
81 }
73
82
74 function test_notProcessing() {
83 function test_notProcessing() {
75 expectFail("", "processingMouseArea should not receive the click.");
84 expectFail("", "processingMouseArea should not receive the click.");
76− mouseClick(listView);
85+ mouseClick(view);
77 clickedSpy.wait();
86 clickedSpy.wait();
78 }
87 }
79
88
80 function test_processing() {
89 function test_processing() {
81− verify(listView.currentItem, "currentItem is not ready yet");
90+ verify(view.currentItem, "currentItem is not ready yet");
82− listView.currentItem.previewModel.setLoaded(false);
91+ view.currentItem.previewModel.setLoaded(false);
83
92
84− tryCompare(listView, "processing", true);
93+ tryCompare(view, "processing", true);
85
94
86− mouseClick(listView);
95+ mouseClick(view);
87 clickedSpy.wait();
96 clickedSpy.wait();
88 }
97 }
89
98
90 function test_title() {
99 function test_title() {
91− var header = findChild(listView, "innerPageHeader");
100+ var header = findChild(view, "innerPageHeader");
92 verify(header, "Could not find the preview header");
101 verify(header, "Could not find the preview header");
93
102
94 compare(header.config.title, "Mock Scope");
103 compare(header.config.title, "Mock Scope");
95 }
104 }
96
105
97 function test_header_style() {
106 function test_header_style() {
98− var header = findChild(listView, "pageHeader");
107+ var header = findChild(view, "pageHeader");
99 verify(header, "Could not find the header");
108 verify(header, "Could not find the header");
100
109
101 var innerHeader = findChild(header, "innerPageHeader");
110 var innerHeader = findChild(header, "innerPageHeader");