on xenial help sign in
working with ensureVisible
a0a970aDiego Sarmentero
Dash/Apps/AppPreview.qml+22−2
@@ -142,6 +142,22 @@ DashPreview {
142 rated: root.previewData.infoMap["rated"] ? root.previewData.infoMap["rated"].value : 0
142 rated: root.previewData.infoMap["rated"] ? root.previewData.infoMap["rated"].value : 0
143 }
143 }
144
144
145+ AppReviews {
146+ id: appReviews2
147+ objectName: "appReviews2"
148+ // TODO: This should make this visible when the feature for reviews/comments is complete.
149+// visible: false
150+ anchors { left: parent.left; right: parent.right }
151+
152+ model: root.previewData.infoMap["comments"] ? root.previewData.infoMap["comments"].value : undefined
153+
154+ onSendReview: root.sendUserReview(review);
155+
156+ onEditing: {
157+ root.ensureVisible(appReviews);
158+ }
159+ }
160+
145 Label {
161 Label {
146 anchors { left: parent.left; right: parent.right }
162 anchors { left: parent.left; right: parent.right }
147 text: root.previewData.description
163 text: root.previewData.description
@@ -186,16 +202,20 @@ DashPreview {
186
202
187 ListItem.ThinDivider { }
203 ListItem.ThinDivider { }
188
204
189−
190 AppReviews {
205 AppReviews {
206+ id: appReviews
191 objectName: "appReviews"
207 objectName: "appReviews"
192 // TODO: This should make this visible when the feature for reviews/comments is complete.
208 // TODO: This should make this visible when the feature for reviews/comments is complete.
193− visible: false
209+// visible: false
194 anchors { left: parent.left; right: parent.right }
210 anchors { left: parent.left; right: parent.right }
195
211
196 model: root.previewData.infoMap["comments"] ? root.previewData.infoMap["comments"].value : undefined
212 model: root.previewData.infoMap["comments"] ? root.previewData.infoMap["comments"].value : undefined
197
213
198 onSendReview: root.sendUserReview(review);
214 onSendReview: root.sendUserReview(review);
215+
216+ onEditing: {
217+ root.ensureVisible(appReviews.textArea);
218+ }
199 }
219 }
200 }
220 }
201 }
221 }
Dash/Apps/AppReviews.qml+3
@@ -23,8 +23,10 @@ Column {
23 id: root
23 id: root
24
24
25 property var model
25 property var model
26+ property alias textArea: reviewField
26
27
27 signal sendReview(string review)
28 signal sendReview(string review)
29+ signal editing
28
30
29 spacing: units.gu(2)
31 spacing: units.gu(2)
30 state: ""
32 state: ""
@@ -93,6 +95,7 @@ Column {
93 if(reviewField.focus){
95 if(reviewField.focus){
94 root.state = "editing";
96 root.state = "editing";
95 reviewField.selectAll();
97 reviewField.selectAll();
98+ root.editing();
96 }
99 }
97 }
100 }
98
101
Dash/DashPreview.qml+17
@@ -39,6 +39,23 @@ Rectangle {
39 color: Qt.rgba(0, 0, 0, .3)
39 color: Qt.rgba(0, 0, 0, .3)
40 clip: true
40 clip: true
41
41
42+ function ensureVisible(item) {
43+// console.log("leftFlickable.contentY: " + leftFlickable.mapToItem(null, 0, leftFlickable.contentY).y);
44+ console.log("leftFlickable.height: " + leftFlickable.height);
45+ root.keyboardSize = 200;
46+ var y = leftFlickable.contentHeight - item.mapToItem(leftFlickable, 0, 0).y + item.height;
47+ var visibleArea = leftFlickable.contentY + leftFlickable.height;
48+ console.log("y: " + y);
49+ console.log("visibleArea: " + visibleArea);
50+ if(y > visibleArea) {
51+ leftFlickable.contentY = leftFlickable.contentY + root.keyboardSize;
52+ }
53+
54+ console.log("leftFlickable.contentHeight: " + leftFlickable.contentHeight);
55+ console.log("leftFlickable.contentY: " + leftFlickable.contentY);
56+ console.log("leftFlickable.height: " + leftFlickable.height);
57+ }
58+
42 Connections {
59 Connections {
43 target: shell.applicationManager
60 target: shell.applicationManager
44 onMainStageFocusedApplicationChanged: {
61 onMainStageFocusedApplicationChanged: {