on xenial help sign in
Let the scopes/scopes-plugin-shell take care of activates that are previews Fixes: #1428063
12953f8Albert Astals Cid
debian/changelog+6
@@ -1,3 +1,9 @@
1+unity8 (8.11-0ubuntu1) UNRELEASED; urgency=medium
2+
3+ * Increase version because of new scopes shell communication protocol
4+
5+ -- Albert Astals Cid <albert.astals@canonical.com> Tue, 04 Aug 2015 17:16:32 +0200
6+
1unity8 (8.10+15.10.20150804-0ubuntu1) wily; urgency=medium
7unity8 (8.10+15.10.20150804-0ubuntu1) wily; urgency=medium
2
8
3 [ Kevin Gunn ]
9 [ Kevin Gunn ]
debian/control+1−1
@@ -128,7 +128,7 @@ Depends: qml-module-qtquick-layouts,
128 unity-application-impl-6,
128 unity-application-impl-6,
129 unity-notifications-impl-3,
129 unity-notifications-impl-3,
130 unity-plugin-scopes | unity-scopes-impl,
130 unity-plugin-scopes | unity-scopes-impl,
131− unity-scopes-impl-6,
131+ unity-scopes-impl-7,
132 unity8-fake-env | unity-application-impl,
132 unity8-fake-env | unity-application-impl,
133 ${misc:Depends},
133 ${misc:Depends},
134Breaks: unity8 (<< 7.86),
134Breaks: unity8 (<< 7.86),
qml/Dash/GenericScopeView.qml+45−21
@@ -72,28 +72,39 @@ FocusScope {
72 pageHeaderLoader.item.resetSearch()
72 pageHeaderLoader.item.resetSearch()
73 }
73 }
74
74
75− function itemClicked(index, result, item, itemModel, resultsModel, limitedCategoryItemCount, categoryId) {
75+ property var maybePreviewResult;
76− if (itemModel.uri.indexOf("scope://") === 0 || scope.id === "clickscope" || (scope.id === "videoaggregator" && categoryId === "myvideos-getstarted")) {
76+ property int maybePreviewIndex;
77− // TODO Technically it is possible that calling activate() will make the scope emit
77+ property var maybePreviewResultsModel;
78− // previewRequested so that we show a preview but there's no scope that does that yet
78+ property int maybePreviewLimitedCategoryItemCount;
79− // so it's not implemented
79+ property string maybePreviewCategoryId;
80− scope.activate(result)
80+
81− } else {
81+ function clearMaybePreviewData() {
82− if (scope.preview(result)) {
82+ scopeView.maybePreviewResult = undefined;
83− openPreview(index, resultsModel, limitedCategoryItemCount);
83+ scopeView.maybePreviewIndex = -1;
84− }
84+ scopeView.maybePreviewResultsModel = undefined;
85− }
85+ scopeView.maybePreviewLimitedCategoryItemCount = -1;
86+ scopeView.maybePreviewCategoryId = "";
86 }
87 }
87
88
89+ function itemClicked(index, result, itemModel, resultsModel, limitedCategoryItemCount, categoryId) {
90+ scopeView.maybePreviewResult = result;
91+ scopeView.maybePreviewIndex = index;
92+ scopeView.maybePreviewResultsModel = resultsModel;
93+ scopeView.maybePreviewLimitedCategoryItemCount = limitedCategoryItemCount;
94+ scopeView.maybePreviewCategoryId = categoryId;
95+
96+ scope.activate(result, categoryId);
97+ }
98+
88− function itemPressedAndHeld(index, result, itemModel, resultsModel, limitedCategoryItemCount, categoryId) {
99+ function itemPressedAndHeld(index, result, resultsModel, limitedCategoryItemCount, categoryId) {
89− if (itemModel.uri.indexOf("scope://") !== 0 && !(scope.id === "videoaggregator" && categoryId === "myvideos-getstarted")) {
100+ clearMaybePreviewData();
101+
90− if (scope.preview(result)) {
102+ if (scope.preview(result, categoryId)) {
91− openPreview(index, resultsModel, limitedCategoryItemCount);
103+ openPreview(index, resultsModel, limitedCategoryItemCount, categoryId);
92− }
93 }
104 }
94 }
105 }
95
106
96− function openPreview(index, resultsModel, limitedCategoryItemCount) {
107+ function openPreview(index, resultsModel, limitedCategoryItemCount, categoryId) {
97 if (limitedCategoryItemCount > 0) {
108 if (limitedCategoryItemCount > 0) {
98 previewLimitModel.model = resultsModel;
109 previewLimitModel.model = resultsModel;
99 previewLimitModel.limit = limitedCategoryItemCount;
110 previewLimitModel.limit = limitedCategoryItemCount;
@@ -103,6 +114,7 @@ FocusScope {
103 }
114 }
104 subPageLoader.initialIndex = -1;
115 subPageLoader.initialIndex = -1;
105 subPageLoader.initialIndex = index;
116 subPageLoader.initialIndex = index;
117+ subPageLoader.categoryId = categoryId;
106 subPageLoader.openSubPage("preview");
118 subPageLoader.openSubPage("preview");
107 }
119 }
108
120
@@ -149,6 +161,16 @@ FocusScope {
149 target: scopeView.scope
161 target: scopeView.scope
150 onShowDash: subPageLoader.closeSubPage()
162 onShowDash: subPageLoader.closeSubPage()
151 onHideDash: subPageLoader.closeSubPage()
163 onHideDash: subPageLoader.closeSubPage()
164+ onPreviewRequested: { // (QVariant const& result)
165+ if (result === scopeView.maybePreviewResult) {
166+ openPreview(scopeView.maybePreviewIndex,
167+ scopeView.maybePreviewResultsModel,
168+ scopeView.maybePreviewLimitedCategoryItemCount,
169+ scopeView.maybePreviewCategoryId);
170+
171+ clearMaybePreviewData();
172+ }
173+ }
152 }
174 }
153
175
154 Connections {
176 Connections {
@@ -357,12 +379,12 @@ FocusScope {
357
379
358 Connections {
380 Connections {
359 target: rendererLoader.item
381 target: rendererLoader.item
360− onClicked: {
382+ onClicked: { // (int index, var result, var item, var itemModel)
361− scopeView.itemClicked(index, result, item, itemModel, target.model, categoryItemCount(), baseItem.category);
383+ scopeView.itemClicked(index, result, itemModel, target.model, categoryItemCount(), baseItem.category);
362 }
384 }
363
385
364− onPressAndHold: {
386+ onPressAndHold: { // (int index, var result, var itemModel)
365− scopeView.itemPressedAndHeld(index, result, itemModel, target.model, categoryItemCount(), baseItem.category);
387+ scopeView.itemPressedAndHeld(index, result, target.model, categoryItemCount(), baseItem.category);
366 }
388 }
367
389
368 function categoryItemCount() {
390 function categoryItemCount() {
@@ -736,6 +758,7 @@ FocusScope {
736 property var scope: scopeView.scope
758 property var scope: scopeView.scope
737 property var scopeStyle: scopeView.scopeStyle
759 property var scopeStyle: scopeView.scopeStyle
738 property int initialIndex: -1
760 property int initialIndex: -1
761+ property string categoryId
739 property var model: null
762 property var model: null
740
763
741 readonly property bool processing: item && item.processing || false
764 readonly property bool processing: item && item.processing || false
@@ -767,6 +790,7 @@ FocusScope {
767 item.open = Qt.binding(function() { return subPageLoader.open; } )
790 item.open = Qt.binding(function() { return subPageLoader.open; } )
768 item.initialIndex = Qt.binding(function() { return subPageLoader.initialIndex; } )
791 item.initialIndex = Qt.binding(function() { return subPageLoader.initialIndex; } )
769 item.model = Qt.binding(function() { return subPageLoader.model; } )
792 item.model = Qt.binding(function() { return subPageLoader.model; } )
793+ item.categoryId = Qt.binding(function() { return subPageLoader.categoryId; } )
770 }
794 }
771 open = true;
795 open = true;
772 }
796 }
qml/Dash/PreviewListView.qml+2−1
@@ -26,6 +26,7 @@ Item {
26 property int initialIndex: -1
26 property int initialIndex: -1
27 property var scope: null
27 property var scope: null
28 property var scopeStyle: null
28 property var scopeStyle: null
29+ property string categoryId
29
30
30 property alias showSignatureLine: header.showSignatureLine
31 property alias showSignatureLine: header.showSignatureLine
31
32
@@ -99,7 +100,7 @@ Item {
99 isCurrent: ListView.isCurrentItem
100 isCurrent: ListView.isCurrentItem
100
101
101 previewModel: {
102 previewModel: {
102− var previewStack = root.scope.preview(result);
103+ var previewStack = root.scope.preview(result, root.categoryId);
103 return previewStack.getPreviewModel(0);
104 return previewStack.getPreviewModel(0);
104 }
105 }
105 scopeStyle: root.scopeStyle
106 scopeStyle: root.scopeStyle
qml/Dash/ScopesList.qml+1−1
@@ -124,7 +124,7 @@ Item {
124 onRequestFavorite: root.requestFavorite(scopeId, favorite);
124 onRequestFavorite: root.requestFavorite(scopeId, favorite);
125 onRequestEditMode: root.state = "edit";
125 onRequestEditMode: root.state = "edit";
126 onRequestScopeMoveTo: root.requestFavoriteMoveTo(scopeId, index);
126 onRequestScopeMoveTo: root.requestFavoriteMoveTo(scopeId, index);
127− onRequestActivate: root.scope.activate(result);
127+ onRequestActivate: root.scope.activate(result, categoryId);
128 onRequestRestore: root.requestRestore(scopeId);
128 onRequestRestore: root.requestRestore(scopeId);
129 }
129 }
130 }
130 }
tests/mocks/Unity/CMakeLists.txt+1−1
@@ -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=6)
10+pkg_check_modules(SCOPES_API REQUIRED unity-shell-scopes=7)
11
11
12include_directories(
12include_directories(
13 ${CMAKE_CURRENT_BINARY_DIR}
13 ${CMAKE_CURRENT_BINARY_DIR}
tests/mocks/Unity/fake_scope.cpp+5−3
@@ -181,18 +181,20 @@ void Scope::setNoResultsHint(const QString& str)
181 }
181 }
182}
182}
183
183
184−void Scope::activate(QVariant const& result)
184+void Scope::activate(QVariant const& result, QString const& categoryId)
185{
185{
186− qDebug() << "Called activate on scope" << m_id << "with result" << result;
186+ qDebug() << "Called activate on scope" << m_id << "with result" << result << "and category" << categoryId;
187 if (result.toString() == "Result.2.2") {
187 if (result.toString() == "Result.2.2") {
188 Scopes *scopes = dynamic_cast<Scopes*>(parent());
188 Scopes *scopes = dynamic_cast<Scopes*>(parent());
189 m_openScope = scopes->getScopeFromAll("MockScope9");
189 m_openScope = scopes->getScopeFromAll("MockScope9");
190 scopes->addTempScope(m_openScope);
190 scopes->addTempScope(m_openScope);
191 Q_EMIT openScope(m_openScope);
191 Q_EMIT openScope(m_openScope);
192+ } else {
193+ Q_EMIT previewRequested(result);
192 }
194 }
193}
195}
194
196
195−PreviewStack* Scope::preview(QVariant const& result)
197+PreviewStack* Scope::preview(QVariant const& result, QString const& /*categoryId*/)
196{
198{
197 Q_UNUSED(result);
199 Q_UNUSED(result);
198
200
tests/mocks/Unity/fake_scope.h+2−2
@@ -60,8 +60,8 @@ public:
60 Q_INVOKABLE void setName(const QString &name); // This is not invokable in the Interface, here for testing benefits
60 Q_INVOKABLE void setName(const QString &name); // This is not invokable in the Interface, here for testing benefits
61 Q_INVOKABLE void setSearchInProgress(const bool inProg); // This is not invokable in the Interface, here for testing benefits
61 Q_INVOKABLE void setSearchInProgress(const bool inProg); // This is not invokable in the Interface, here for testing benefits
62
62
63− Q_INVOKABLE void activate(QVariant const& result) override;
63+ Q_INVOKABLE void activate(QVariant const& result, QString const& categoryId) override;
64− Q_INVOKABLE PreviewStack* preview(QVariant const& result) override;
64+ Q_INVOKABLE PreviewStack* preview(QVariant const& result, QString const& categoryId) override;
65 Q_INVOKABLE void cancelActivation() override;
65 Q_INVOKABLE void cancelActivation() override;
66 Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface* scope) override;
66 Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface* scope) override;
67
67
tests/mocks/Unity/fake_scopesoverview.cpp+1−1
@@ -41,7 +41,7 @@ void ScopesOverview::setSearchQuery(const QString& search_query)
41 Q_EMIT categoriesChanged();
41 Q_EMIT categoriesChanged();
42}
42}
43
43
44−Q_INVOKABLE void ScopesOverview::activate(QVariant const& result)
44+Q_INVOKABLE void ScopesOverview::activate(QVariant const& result, QString const& /*categoryId*/)
45{
45{
46 Scopes *scopes = dynamic_cast<Scopes*>(parent());
46 Scopes *scopes = dynamic_cast<Scopes*>(parent());
47 if (scopes->getScope(result.toString())) {
47 if (scopes->getScope(result.toString())) {
tests/mocks/Unity/fake_scopesoverview.h+1−1
@@ -32,7 +32,7 @@ public:
32 ScopesOverview(Scopes* parent = 0);
32 ScopesOverview(Scopes* parent = 0);
33
33
34 void setSearchQuery(const QString& search_query) override;
34 void setSearchQuery(const QString& search_query) override;
35− Q_INVOKABLE void activate(QVariant const& result) override;
35+ Q_INVOKABLE void activate(QVariant const& result, QString const& categoryId) override;
36
36
37 // This is implementation detail
37 // This is implementation detail
38 void setFavorite(Scope *scope, bool favorite);
38 void setFavorite(Scope *scope, bool favorite);