on xenial help sign in
Let the scopes/scopes-plugin-shell take care of activates that are previews
commitb03b656b4153f4fceff61386bc230d5056a3b8bf authorAlbert Astals Cid <albert.astals@canonical.com> dateTue 7 Jul 2015, 12:33 (11 years ago) parent77048da
1 file changed+33−20
qml/Dash/GenericScopeView.qml+33−20
qml/Dash/GenericScopeView.qml+33−20
@@ -67,24 +67,28 @@ FocusScope {
6767 subPageLoader.closeSubPage()
6868 }
6969
70− function itemClicked(index, result, item, itemModel, resultsModel, limitedCategoryItemCount, categoryId) {
71− if (itemModel.uri.indexOf("scope://") === 0 || scope.id === "clickscope" || (scope.id === "videoaggregator" && categoryId === "myvideos-getstarted")) {
72− // TODO Technically it is possible that calling activate() will make the scope emit
73− // previewRequested so that we show a preview but there's no scope that does that yet
74− // so it's not implemented
75− scope.activate(result)
76− } else {
77− if (scope.preview(result)) {
78− openPreview(index, resultsModel, limitedCategoryItemCount);
79− }
80− }
70+ property var maybePreviewResult;
71+ property var maybePreviewIndex;
72+ property var maybePreviewResultsModel;
73+ property var maybePreviewLimitedCategoryItemCount;
74+
75+ function itemClicked(index, result, itemModel, resultsModel, limitedCategoryItemCount, categoryId) {
76+ scopeView.maybePreviewResult = result;
77+ scopeView.maybePreviewIndex = index;
78+ scopeView.maybePreviewResultsModel = resultsModel;
79+ scopeView.maybePreviewLimitedCategoryItemCount = limitedCategoryItemCount;
80+
81+ scope.activate(result, categoryId);
8182 }
8283
83− function itemPressedAndHeld(index, result, itemModel, resultsModel, limitedCategoryItemCount, categoryId) {
84− if (itemModel.uri.indexOf("scope://") !== 0 && !(scope.id === "videoaggregator" && categoryId === "myvideos-getstarted")) {
85− if (scope.preview(result)) {
86− openPreview(index, resultsModel, limitedCategoryItemCount);
87− }
84+ function itemPressedAndHeld(index, result, resultsModel, limitedCategoryItemCount, categoryId) {
85+ scopeView.maybePreviewResult = undefined;
86+ scopeView.maybePreviewIndex = undefined;
87+ scopeView.maybePreviewResultsModel = undefined;
88+ scopeView.maybePreviewLimitedCategoryItemCount = undefined;
89+
90+ if (scope.preview(result, categoryId)) {
91+ openPreview(index, resultsModel, limitedCategoryItemCount);
8892 }
8993 }
9094
@@ -144,6 +148,15 @@ FocusScope {
144148 target: scopeView.scope
145149 onShowDash: subPageLoader.closeSubPage()
146150 onHideDash: subPageLoader.closeSubPage()
151+ onPreviewRequested: { // (QVariant const& result)
152+ if (result === scopeView.maybePreviewResult) {
153+ scopeView.maybePreviewResult = undefined;
154+ openPreview(scopeView.maybePreviewIndex, scopeView.maybePreviewResultsModel, scopeView.maybePreviewLimitedCategoryItemCount);
155+ scopeView.maybePreviewIndex = undefined;
156+ scopeView.maybePreviewResultsModel = undefined;
157+ scopeView.maybePreviewLimitedCategoryItemCount = undefined;
158+ }
159+ }
147160 }
148161
149162 Connections {
@@ -345,12 +358,12 @@ FocusScope {
345358
346359 Connections {
347360 target: rendererLoader.item
348− onClicked: {
349− scopeView.itemClicked(index, result, item, itemModel, target.model, categoryItemCount(), baseItem.category);
361+ onClicked: { // (int index, var result, var item, var itemModel)
362+ scopeView.itemClicked(index, result, itemModel, target.model, categoryItemCount(), baseItem.category);
350363 }
351364
352− onPressAndHold: {
353− scopeView.itemPressedAndHeld(index, result, itemModel, target.model, categoryItemCount(), baseItem.category);
365+ onPressAndHold: { // (int index, var result, var itemModel)
366+ scopeView.itemPressedAndHeld(index, result, target.model, categoryItemCount(), baseItem.category);
354367 }
355368
356369 function categoryItemCount() {