From 9aef136ab4c6af5590867e49fc46054d968f3043 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sat, 7 Nov 2026 12:14:23 +0100 Subject: sonix: boot logo fixes from review, own HiBy R1 group Co-Authored-By: Claude Opus 5.5 --- desktop/modules/sonix/BootlogoCanvas.qml | 16 +++++++++------- desktop/modules/sonix/BootlogoModule.qml | 8 ++++---- desktop/modules/sonix/BootlogoTab.qml | 32 +++++++++++++++++++------------- 3 files changed, 32 insertions(+), 24 deletions(-) (limited to 'desktop/modules') diff --git a/desktop/modules/sonix/BootlogoCanvas.qml b/desktop/modules/sonix/BootlogoCanvas.qml index 309e9ad..6915dfc 100644 --- a/desktop/modules/sonix/BootlogoCanvas.qml +++ b/desktop/modules/sonix/BootlogoCanvas.qml @@ -74,7 +74,9 @@ Item { x: canvas.cfg.x - width / 2 y: canvas.cfg.y - height / 2 - // The second colour: an offset copy behind, or Bungee Inline on top. + // The second colour: an offset copy behind the fill. For Bungee it is + // the Regular layer underneath, showing through the stripe Bungee + // Inline cuts out of each letter; the Inline layer on top is the fill. Text { visible: !label.layered x: label.off.x @@ -87,13 +89,13 @@ Item { id: fillText text: canvas.text font { family: label.fam; pixelSize: canvas.cfg.size } - color: canvas.colour(canvas.cfg.fill) + color: canvas.colour(label.layered ? canvas.cfg.second : canvas.cfg.fill) } Text { visible: label.layered text: canvas.text font { family: fInline.name; pixelSize: canvas.cfg.size } - color: canvas.colour(canvas.cfg.second) + color: canvas.colour(canvas.cfg.fill) } } @@ -126,14 +128,14 @@ Item { // Writes base + ".png" (the logo) and base + "-mask.png" (the text on // transparency). cb(ok, error). function save(base, cb) { - canvas.grabToImage(r => { + if (!canvas.grabToImage(r => { if (!r.saveToFile(base + ".png")) { cb(false, `Cannot write ${base}.png`); return; } canvas.maskOnly = true; - canvas.grabToImage(m => { + if (!canvas.grabToImage(m => { canvas.maskOnly = false; const ok = m.saveToFile(base + "-mask.png"); cb(ok, ok ? "" : `Cannot write ${base}-mask.png`); - }, Qt.size(480, 800)); - }, Qt.size(480, 800)); + }, Qt.size(480, 800))) { canvas.maskOnly = false; cb(false, "Cannot grab the mask"); } + }, Qt.size(480, 800))) cb(false, "Cannot grab the canvas"); } } diff --git a/desktop/modules/sonix/BootlogoModule.qml b/desktop/modules/sonix/BootlogoModule.qml index 5f744d1..edace29 100644 --- a/desktop/modules/sonix/BootlogoModule.qml +++ b/desktop/modules/sonix/BootlogoModule.qml @@ -12,14 +12,14 @@ import QtQuick import "../.." -// The Sonix boot logo editor, in the settings window under Appearance. +// The Sonix boot logo editor, in the settings window under HiBy R1. // No draft: it edits no file. Save and Upload are in the header. Module { name: "bootlogo" label: "Boot logo" icon: String.fromCodePoint(0xF075A) // md-music settings: true - group: "Appearance" + group: "HiBy R1" keywords: ["boot", "logo", "sonix", "hiby", "splash", "player"] page: Component { @@ -34,10 +34,10 @@ Module { elide: Text.ElideRight text: tab.status font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 } - color: tab.statusError ? Theme.yellow : Theme.green + color: tab.waiting ? Theme.yellow : tab.statusError ? Theme.red : Theme.green } Button { - text: tab.busy && !tab.waiting ? "Saving…" : "Save" + text: tab.busy ? "Busy…" : "Save" enabled: tab.canSave onClicked: tab.save(null) } diff --git a/desktop/modules/sonix/BootlogoTab.qml b/desktop/modules/sonix/BootlogoTab.qml index 613a71d..799f4fe 100644 --- a/desktop/modules/sonix/BootlogoTab.qml +++ b/desktop/modules/sonix/BootlogoTab.qml @@ -13,10 +13,10 @@ import Quickshell import Quickshell.Io import QtQuick import QtQuick.Controls -import QtQuick.Dialogs import "../.." import "../appearance" import "Sonix.js" as S +import Qt.labs.platform as P // The boot logo editor: the canvas on the left, its controls on the right; // Save and Upload live in the page header (BootlogoModule.qml) and call @@ -29,6 +29,8 @@ Row { property var cfg: Object.assign({}, Prefs.bootlogo) function set(ch) { tab.cfg = Object.assign({}, tab.cfg, ch); cfgWrite.restart(); } Timer { id: cfgWrite; interval: 600; onTriggered: Prefs.setBootlogo(tab.cfg) } + // Keeps the last edit when the page closes inside the pause. + Component.onDestruction: if (cfgWrite.running) Prefs.setBootlogo(tab.cfg) readonly property string folder: tab.cfg.folder || Quickshell.env("HOME") + "/Pictures/sonix-bootlogo" readonly property string cardDir: "/data/mnt/sd_0/Bootlogo" @@ -70,20 +72,21 @@ Row { } } - property int tries: 0 - function upload() { tab.save(file => { tab.tries = 0; tab.send(file); }); } + // The wait for Wi-Fi transfer is capped by time, 60s from the click. + property real deadline: 0 + function upload() { tab.save(file => { tab.deadline = Date.now() + 60000; tab.send(file); }); } function send(file) { tab.busy = true; Sonix.upload(file, tab.cardDir, (code, out) => { - tab.busy = false; - if (code === 3 && tab.tries < 30) { + // busy stays true through the wait; only a final answer clears it. + if (code === 3 && Date.now() < tab.deadline) { tab.waiting = true; - tab.tries++; tab.say("Open Wi-Fi transfer on the player (Control centre) and leave it on screen.", true); retry.file = file; retry.restart(); return; } + tab.busy = false; tab.waiting = false; if (code === 0) tab.say("Uploaded. Pick it on the player: Settings > Appearance > Boot logo. You can leave Wi-Fi transfer now."); @@ -206,7 +209,7 @@ Row { width: 260 placeholder: Quickshell.env("USER") Component.onCompleted: value = tab.cfg.text - onEdited: tab.set({ text: value }) + onValueChanged: if (value !== tab.cfg.text) tab.set({ text: value }) } Flow { width: parent.width @@ -321,18 +324,21 @@ Row { // A FileDialog hands back a file:// URL. function pathOf(u) { return decodeURIComponent(u.toString().replace(/^file:\/\//, "")); } - FileDialog { + // Qt.labs.platform, not QtQuick.Dialogs: the Quick dialog opens light on + // this desktop (AGENTS.md); this one takes the widget style. + P.FileDialog { id: pick title: "Choose a picture" - fileMode: FileDialog.OpenFile - currentFolder: "file://" + Quickshell.env("HOME") + "/Pictures" + fileMode: P.FileDialog.OpenFile + folder: "file://" + Quickshell.env("HOME") + "/Pictures" nameFilters: ["Pictures (*.jpg *.jpeg *.png *.JPG *.JPEG *.PNG)"] - onAccepted: canvas.source = selectedFile + onAccepted: canvas.source = pick.file } - FolderDialog { + P.FolderDialog { id: pickFolder title: "Output folder" + folder: "file://" + tab.folder currentFolder: "file://" + tab.folder - onAccepted: tab.set({ folder: tab.pathOf(selectedFolder) }) + onAccepted: tab.set({ folder: tab.pathOf(pickFolder.folder) }) } } -- cgit v1.2.3