Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions packages/omamobile-shell/plugins/omamobile.update/Update.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""
Expand Down Expand Up @@ -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 })
Expand All @@ -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
Expand Down Expand Up @@ -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", "{}")
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions packages/omamobile-shell/test/update-render
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
]}))
Expand All @@ -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
Expand Down
13 changes: 13 additions & 0 deletions packages/omamobile-shell/test/update-render.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
2 changes: 1 addition & 1 deletion packages/omamobile-shell/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.135
0.2.136