Skip to content

Commit ee3340e

Browse files
committed
Another fix for Tips & Tricks positioning issues
1 parent da60af3 commit ee3340e

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

‎ui.qml.in‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,9 +1042,12 @@ Item {
10421042

10431043
component UIHint : Item {
10441044
id: hint
1045-
// Workaround: Dynamically added SwipeView items are all visible at x=0
1045+
// Workaround: Dynamically added SwipeView items may be visible at x=0
10461046
// until SwipeView preloads them. Only show when properly positioned.
10471047
visible: SwipeView.view ? (SwipeView.isCurrentItem || SwipeView.isPreviousItem || SwipeView.isNextItem) : false
1048+
// Workaround 2: SwipeView may fail to position items added during
1049+
// Component.onCompleted. Use a binding to set x as a fallback.
1050+
x: SwipeView.view ? SwipeView.index * SwipeView.view.width : 0
10481051

10491052
property var target
10501053
property real targetX
@@ -1058,7 +1061,12 @@ Item {
10581061

10591062
function updateTarget() {
10601063
if (target !== null) {
1061-
var p = mapFromItem(target, 0, 0);
1064+
// Map relative to the SwipeView rather than this item, so that
1065+
// the result doesn't depend on our x offset within the content
1066+
// area. Falls back to mapping relative to ourselves when the
1067+
// SwipeView isn't available yet (x is 0 then, so equivalent).
1068+
var ref = SwipeView.view || hint;
1069+
var p = ref.mapFromItem(target, 0, 0);
10621070
targetX = p.x;
10631071
targetY = p.y;
10641072
}
@@ -1184,6 +1192,12 @@ Item {
11841192
}
11851193

11861194
Component.onCompleted: {
1195+
// Need to show the plot if any of the hints use it to get
1196+
// it initialized, otherwise the layout randomly breaks
1197+
if (hintId !== "statusText") {
1198+
bottomStackTabs.currentIndex = 2;
1199+
}
1200+
11871201
pd.init(["current"], 1);
11881202
subject.init(1);
11891203
pd.addSample([0, 0,0,0,0, 10], 0);

0 commit comments

Comments
 (0)