aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/sonix/BootlogoTab.qml
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/modules/sonix/BootlogoTab.qml')
-rw-r--r--desktop/modules/sonix/BootlogoTab.qml32
1 files changed, 19 insertions, 13 deletions
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) })
}
}