diff --git a/packages/omamobile-shell/plugins/omamobile.update/Update.qml b/packages/omamobile-shell/plugins/omamobile.update/Update.qml index ee213d129..fecb9c8c8 100644 --- a/packages/omamobile-shell/plugins/omamobile.update/Update.qml +++ b/packages/omamobile-shell/plugins/omamobile.update/Update.qml @@ -42,6 +42,7 @@ Item { property var lastResult: null property string stepText: "" property string progressText: "" + property string liveLine: "" // the transient progress line (pacman \r bar), shown at the end of Details property var detailLines: [] property bool detailsOpen: false property string authError: "" @@ -139,6 +140,10 @@ Item { detailLines = [] stepText = "Starting" progressText = "" + liveLine = "" + // Details opens for a new run; following the same run again (a status + // refresh, reopening the sheet) keeps what the user chose. + if (page !== "progress") detailsOpen = true page = "progress" tailProc.running = false Qt.callLater(function() { tailProc.running = true }) @@ -150,14 +155,20 @@ Item { if (ev.kind === "step") { stepText = ev.text progressText = "" + liveLine = "" detailLines = UpdateModel.appendDetail(detailLines, "== " + ev.text) } else if (ev.kind === "line") { progressText = ev.text + liveLine = "" detailLines = UpdateModel.appendDetail(detailLines, ev.text) } else if (ev.kind === "progress") { - progressText = ev.text + // pacman pads its bar line with runs of spaces; squeeze them so the line fits a phone + progressText = ev.text.replace(/\s{2,}/g, " ") + liveLine = progressText } else if (ev.kind === "result") { lastResult = ev.result + liveLine = "" + detailsOpen = false // the result page keeps Details collapsed, as before page = "result" tailProc.running = false updateAvailable = false @@ -199,6 +210,8 @@ Item { recent = Date.now() - Date.parse(st.last.finished) < 30 * 60 * 1000 if (recent || statusProc.openAfter) { root.lastResult = st.last + root.liveLine = "" + root.detailsOpen = false root.page = "result" if (!root.opened && root.shell && typeof root.shell.summon === "function") root.shell.summon((root.manifest && root.manifest.id) || "omamobile.update", "{}") @@ -634,11 +647,18 @@ Item { Text { width: parent.width textFormat: Text.PlainText + // three lines are kept for it, so Details under it doesn't move + // when the line wraps to two or three + height: Math.ceil(progressMetrics.lineSpacing * 3) text: root.progressText color: root.foreground opacity: 0.75 font.family: Style.font.family font.pixelSize: Readable.px(Style.font.caption) + FontMetrics { id: progressMetrics; font.family: Style.font.family; font.pixelSize: Readable.px(Style.font.caption) } + verticalAlignment: Text.AlignTop + wrapMode: Text.WrapAnywhere + maximumLineCount: 3 elide: Text.ElideRight } @@ -814,7 +834,14 @@ Item { contentHeight: detailsText.implicitHeight clip: true boundsBehavior: Flickable.StopAtBounds - onContentHeightChanged: if (contentHeight > height) contentY = contentHeight - height + // Follow the newest line unless the user scrolled up; opening shows the newest lines + property bool stick: true + function toEnd() { contentY = Math.max(0, contentHeight - height) } + onMovementStarted: stick = false + onMovementEnded: stick = atYEnd + onVisibleChanged: if (visible) { stick = true; toEnd() } + onHeightChanged: if (stick && !moving) toEnd() + onContentHeightChanged: if (stick && !moving) toEnd() Rectangle { width: detailsFlick.width @@ -828,7 +855,7 @@ Item { width: detailsFlick.width padding: Style.spacing.lg textFormat: Text.PlainText - text: root.detailLines.join("\n") + text: root.detailLines.concat(root.liveLine ? [root.liveLine] : []).join("\n") color: root.foreground font.family: "monospace" font.pixelSize: Readable.px(Style.font.caption - 1) diff --git a/packages/omamobile-shell/test/update-render b/packages/omamobile-shell/test/update-render index af08ab1f2..efdb9f2d2 100755 --- a/packages/omamobile-shell/test/update-render +++ b/packages/omamobile-shell/test/update-render @@ -59,6 +59,7 @@ print(json.dumps({"info": info, "result": result, "shots": [ shot("portrait", 480, 1040, "overview"), shot("landscape", 1040, 480, "overview"), shot("landscape-auth", 1040, 480, "auth"), + shot("portrait-progress", 480, 1040, "progress"), shot("landscape-progress", 1040, 480, "progress"), shot("landscape-result", 1040, 480, "result"), ]})) @@ -74,8 +75,8 @@ geo = {} for n, w, h, g in re.findall(r"geometry (\S+) (\d+)x(\d+) (\{.*\})", text): geo[n] = dict(json.loads(g), screen={"x": 0, "y": 0, "w": int(w), "h": int(h)}) def inside(a, b, tol=0): return a["x"] >= b["x"] - tol and a["y"] >= b["y"] - tol and a["x"] + a["w"] <= b["x"] + b["w"] + tol and a["y"] + a["h"] <= b["y"] + b["h"] + tol -ok = not bad and len(geo) == 5 -if len(geo) != 5: print("not ok - %s: %d of 5 shots taken" % (theme, len(geo))) +ok = not bad and len(geo) == 6 +if len(geo) != 6: print("not ok - %s: %d of 6 shots taken" % (theme, len(geo))) for l in bad: print(" " + l[:200]) def check(name, good, why=""): global ok diff --git a/packages/omamobile-shell/test/update-render.qml b/packages/omamobile-shell/test/update-render.qml index a752afffe..6b963e502 100644 --- a/packages/omamobile-shell/test/update-render.qml +++ b/packages/omamobile-shell/test/update-render.qml @@ -72,6 +72,19 @@ ShellRoot { update.stepText = "Installing 23 packages" update.progressText = "(14/23) upgrading mesa" update.page = s.page + if (s.page === "progress") { + // A long download: Details opens on the newest lines with pacman's live bar line at the end + var lines = [] + for (var i = 1; i <= 120; i++) lines.push("(" + i + "/120) upgrading package-" + i) + update.detailLines = lines + update.liveLine = "chromium-157.0.8... 74.3 MiB 124 KiB/s 06:46 [#####-------------] 41%" + update.progressText = update.liveLine + update.detailsOpen = true + } else { + update.detailLines = s.page === "result" ? ["== Update system packages", "(1/1) upgrading mesa"] : [] + update.liveLine = "" + update.detailsOpen = false + } settle.restart() } diff --git a/packages/omamobile-shell/version b/packages/omamobile-shell/version index 9221c8c4f..b99740362 100644 --- a/packages/omamobile-shell/version +++ b/packages/omamobile-shell/version @@ -1 +1 @@ -0.2.135 +0.2.136