on xenial help sign in
GenericScopeView: On click only activate scope:// uris and clickscope items

The rest of clicks result in a preview, also scope:// uris don't get a preview Approved by: Michał Sawicz, Pawel Stolowski

commit7a8ef73a5d47ec0fa62a5fec206aea4acc1a7570 authorAlbert Astals <albert.astals@canonical.com> dateMon 11 Aug 2014, 19:02 (12 years ago) parent6ae8535d53390b
7 files changed+14−9
qml/Dash/CardCarousel.qml+1−1 qml/Dash/CardGrid.qml+1−1 qml/Dash/CardVerticalJournal.qml+1−1 qml/Dash/DashRenderer.qml+2−1 qml/Dash/GenericScopeView.qml+6−4 qml/Dash/ScopesOverview.qml+1−1 tests/qmltests/Dash/tst_GenericScopeView.qml+2
qml/Dash/CardCarousel.qml+1−1
@@ -49,7 +49,7 @@ DashRenderer {
4949 objectName: "carouselDelegate" + index
5050
5151 function clicked() { cardCarousel.clicked(index, model.result, loader.item, model) }
52− function pressAndHold() { cardCarousel.pressAndHold(index) }
52+ function pressAndHold() { cardCarousel.pressAndHold(index, model) }
5353
5454 sourceComponent: cardTool.cardComponent
5555 onLoaded: {
qml/Dash/CardGrid.qml+1−1
@@ -74,7 +74,7 @@ DashRenderer {
7474 Connections {
7575 target: loader.item
7676 onClicked: root.clicked(index, result, loader.item, model)
77− onPressAndHold: root.pressAndHold(index)
77+ onPressAndHold: root.pressAndHold(index, model)
7878 }
7979 }
8080 }
qml/Dash/CardVerticalJournal.qml+1−1
@@ -62,7 +62,7 @@ DashRenderer {
6262 Connections {
6363 target: loader.item
6464 onClicked: root.clicked(index, result, loader.item, model)
65− onPressAndHold: root.pressAndHold(index)
65+ onPressAndHold: root.pressAndHold(index, model)
6666 }
6767 }
6868 }
qml/Dash/DashRenderer.qml+2−1
@@ -47,5 +47,6 @@ Item {
4747
4848 /// Emitted when the user pressed and held on an item
4949 /// @param index is the index of the held item
50− signal pressAndHold(int index)
50+ /// @param itemModel model of the item
51+ signal pressAndHold(int index, var itemModel)
5152}
qml/Dash/GenericScopeView.qml+6−4
@@ -60,7 +60,7 @@ FocusScope {
6060 }
6161
6262 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") {
6464 // TODO Technically it is possible that calling activate() will make the scope emit
6565 // previewRequested so that we show a preview but there's no scope that does that yet
6666 // so it's not implemented
@@ -70,8 +70,10 @@ FocusScope {
7070 }
7171 }
7272
73− function itemPressedAndHeld(index, resultsModel, limitedCategoryItemCount) {
74− openPreview(index, resultsModel, limitedCategoryItemCount);
73+ function itemPressedAndHeld(index, itemModel, resultsModel, limitedCategoryItemCount) {
74+ if (itemModel.uri.indexOf("scope://") !== 0) {
75+ openPreview(index, resultsModel, limitedCategoryItemCount);
76+ }
7577 }
7678
7779 function openPreview(index, resultsModel, limitedCategoryItemCount) {
@@ -263,7 +265,7 @@ FocusScope {
263265 }
264266
265267 onPressAndHold: {
266− scopeView.itemPressedAndHeld(index, target.model, categoryItemCount());
268+ scopeView.itemPressedAndHeld(index, itemModel, target.model, categoryItemCount());
267269 }
268270
269271 function categoryItemCount() {
qml/Dash/ScopesOverview.qml+1−1
@@ -365,7 +365,7 @@ Item {
365365 }
366366 }
367367
368− function itemPressedAndHeld(index, resultsModel, limitedCategoryItemCount) {
368+ function itemPressedAndHeld(index, itemModel, resultsModel, limitedCategoryItemCount) {
369369 // Do nothing
370370 }
371371 }
tests/qmltests/Dash/tst_GenericScopeView.qml+2
@@ -28,6 +28,8 @@ Item {
2828 width: units.gu(120)
2929 height: units.gu(100)
3030
31+ // TODO Add a test that checks we don't preview things whose uri starts with scope://
32+
3133 // BEGIN To reduce warnings
3234 // TODO I think it we should pass down these variables
3335 // as needed instead of hoping they will be globally around