on xenial help sign in
GenericScopeView: On click only activate scope:// uris and clickscope items
7a8ef73Albert Astals
qml/Dash/CardCarousel.qml+1−1
@@ -49,7 +49,7 @@ DashRenderer {
49 objectName: "carouselDelegate" + index
49 objectName: "carouselDelegate" + index
50
50
51 function clicked() { cardCarousel.clicked(index, model.result, loader.item, model) }
51 function clicked() { cardCarousel.clicked(index, model.result, loader.item, model) }
52− function pressAndHold() { cardCarousel.pressAndHold(index) }
52+ function pressAndHold() { cardCarousel.pressAndHold(index, model) }
53
53
54 sourceComponent: cardTool.cardComponent
54 sourceComponent: cardTool.cardComponent
55 onLoaded: {
55 onLoaded: {
qml/Dash/CardGrid.qml+1−1
@@ -74,7 +74,7 @@ DashRenderer {
74 Connections {
74 Connections {
75 target: loader.item
75 target: loader.item
76 onClicked: root.clicked(index, result, loader.item, model)
76 onClicked: root.clicked(index, result, loader.item, model)
77− onPressAndHold: root.pressAndHold(index)
77+ onPressAndHold: root.pressAndHold(index, model)
78 }
78 }
79 }
79 }
80 }
80 }
qml/Dash/CardVerticalJournal.qml+1−1
@@ -62,7 +62,7 @@ DashRenderer {
62 Connections {
62 Connections {
63 target: loader.item
63 target: loader.item
64 onClicked: root.clicked(index, result, loader.item, model)
64 onClicked: root.clicked(index, result, loader.item, model)
65− onPressAndHold: root.pressAndHold(index)
65+ onPressAndHold: root.pressAndHold(index, model)
66 }
66 }
67 }
67 }
68 }
68 }
qml/Dash/DashRenderer.qml+2−1
@@ -47,5 +47,6 @@ Item {
47
47
48 /// Emitted when the user pressed and held on an item
48 /// Emitted when the user pressed and held on an item
49 /// @param index is the index of the held item
49 /// @param index is the index of the held item
50+ /// @param itemModel model of the item
50− signal pressAndHold(int index)
51+ signal pressAndHold(int index, var itemModel)
51}
52}
qml/Dash/GenericScopeView.qml+6−4
@@ -60,7 +60,7 @@ FocusScope {
60 }
60 }
61
61
62 function itemClicked(index, result, item, itemModel, resultsModel, limitedCategoryItemCount) {
62 function itemClicked(index, result, item, itemModel, resultsModel, limitedCategoryItemCount) {
63− if (scope.id === "scopes" || scope.id == "clickscope") {
63+ if (itemModel.uri.indexOf("scope://") === 0 || scope.id === "clickscope") {
64 // TODO Technically it is possible that calling activate() will make the scope emit
64 // TODO Technically it is possible that calling activate() will make the scope emit
65 // previewRequested so that we show a preview but there's no scope that does that yet
65 // previewRequested so that we show a preview but there's no scope that does that yet
66 // so it's not implemented
66 // so it's not implemented
@@ -70,8 +70,10 @@ FocusScope {
70 }
70 }
71 }
71 }
72
72
73− function itemPressedAndHeld(index, resultsModel, limitedCategoryItemCount) {
73+ function itemPressedAndHeld(index, itemModel, resultsModel, limitedCategoryItemCount) {
74+ if (itemModel.uri.indexOf("scope://") !== 0) {
74− openPreview(index, resultsModel, limitedCategoryItemCount);
75+ openPreview(index, resultsModel, limitedCategoryItemCount);
76+ }
75 }
77 }
76
78
77 function openPreview(index, resultsModel, limitedCategoryItemCount) {
79 function openPreview(index, resultsModel, limitedCategoryItemCount) {
@@ -263,7 +265,7 @@ FocusScope {
263 }
265 }
264
266
265 onPressAndHold: {
267 onPressAndHold: {
266− scopeView.itemPressedAndHeld(index, target.model, categoryItemCount());
268+ scopeView.itemPressedAndHeld(index, itemModel, target.model, categoryItemCount());
267 }
269 }
268
270
269 function categoryItemCount() {
271 function categoryItemCount() {
qml/Dash/ScopesOverview.qml+1−1
@@ -365,7 +365,7 @@ Item {
365 }
365 }
366 }
366 }
367
367
368− function itemPressedAndHeld(index, resultsModel, limitedCategoryItemCount) {
368+ function itemPressedAndHeld(index, itemModel, resultsModel, limitedCategoryItemCount) {
369 // Do nothing
369 // Do nothing
370 }
370 }
371 }
371 }
tests/qmltests/Dash/tst_GenericScopeView.qml+2
@@ -28,6 +28,8 @@ Item {
28 width: units.gu(120)
28 width: units.gu(120)
29 height: units.gu(100)
29 height: units.gu(100)
30
30
31+ // TODO Add a test that checks we don't preview things whose uri starts with scope://
32+
31 // BEGIN To reduce warnings
33 // BEGIN To reduce warnings
32 // TODO I think it we should pass down these variables
34 // TODO I think it we should pass down these variables
33 // as needed instead of hoping they will be globally around
35 // as needed instead of hoping they will be globally around