on xenial help sign in
working with ensureVisible
commita0a970a9917924938c572e45bffe9a9602e79328 authorDiego Sarmentero <diego.sarmentero@gmail.com> dateFri 20 Sep 2013, 08:23 (13 years ago) parentab88cc4
3 files changed+42−2
Dash/Apps/AppPreview.qml+22−2 Dash/Apps/AppReviews.qml+3 Dash/DashPreview.qml+17
Dash/Apps/AppPreview.qml+22−2
@@ -142,6 +142,22 @@ DashPreview {
142142 rated: root.previewData.infoMap["rated"] ? root.previewData.infoMap["rated"].value : 0
143143 }
144144
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+
145161 Label {
146162 anchors { left: parent.left; right: parent.right }
147163 text: root.previewData.description
@@ -186,16 +202,20 @@ DashPreview {
186202
187203 ListItem.ThinDivider { }
188204
189−
190205 AppReviews {
206+ id: appReviews
191207 objectName: "appReviews"
192208 // TODO: This should make this visible when the feature for reviews/comments is complete.
193− visible: false
209+// visible: false
194210 anchors { left: parent.left; right: parent.right }
195211
196212 model: root.previewData.infoMap["comments"] ? root.previewData.infoMap["comments"].value : undefined
197213
198214 onSendReview: root.sendUserReview(review);
215+
216+ onEditing: {
217+ root.ensureVisible(appReviews.textArea);
218+ }
199219 }
200220 }
201221 }
Dash/Apps/AppReviews.qml+3
@@ -23,8 +23,10 @@ Column {
2323 id: root
2424
2525 property var model
26+ property alias textArea: reviewField
2627
2728 signal sendReview(string review)
29+ signal editing
2830
2931 spacing: units.gu(2)
3032 state: ""
@@ -93,6 +95,7 @@ Column {
9395 if(reviewField.focus){
9496 root.state = "editing";
9597 reviewField.selectAll();
98+ root.editing();
9699 }
97100 }
98101
Dash/DashPreview.qml+17
@@ -39,6 +39,23 @@ Rectangle {
3939 color: Qt.rgba(0, 0, 0, .3)
4040 clip: true
4141
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+
4259 Connections {
4360 target: shell.applicationManager
4461 onMainStageFocusedApplicationChanged: {