Qt: bring over the WebView build's home screen

The WebView build saved its home in its page's localStorage, which stays in
the app's data now that the Qt build is dev.ultra.launcher. On first start
HomeActivity reads the ultra.home.* keys through a throwaway WebView on the
same origin and hands them to QML: apps by component, widgets with their px
heights turned into rows, pins kept when the Qt home is still empty. The
widget host id goes back to the WebView build's, so its widgets stay bound.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hiQsCq11CwCPnKPp9D
This commit is contained in:
Claude committed 2026-11-02 05:49:32 +00:00
1 parent e89d447b8f
commit 70fb8ee633
8 files changed
+130 -2

No files matched your search

+22
View File
@@ -137,3 +137,25 @@ function widgetCols(px, colW, cols) {
var k = Math.max(1, Math.ceil((px + CGAP - 8) / (colW + CGAP)));
return k >= cols ? 0 : k;
}
// The WebView build's saved home (its ultra.home.* localStorage keys) as Qt slots.
// Widget heights were px; they become whole rows.
function legacy(kv) {
var out = [];
var n = parseInt(kv["ultra.home.n"], 10) || 0;
var num = function (k, i, d) {
var v = parseInt(kv["ultra.home." + k + "." + i], 10);
return isNaN(v) ? d : v;
};
for (var i = 0; i < n; i++) {
var str = kv["ultra.home.str." + i];
if (typeof str !== "string" || !str) continue;
var x = num("cx", i, -1), y = num("cy", i, -1);
if (num("kind", i, 0) === 1)
out.push({kind: "widget", str: str, wid: num("wid", i, 0), w: Math.max(0, num("w", i, 0)),
rows: widgetRows(num("h", i, 120)), x: x, y: y});
else
out.push({kind: "app", str: str, x: x, y: y});
}
return out;
}
+21
View File
@@ -91,6 +91,26 @@ Window {
home = out;
}
// Bring over the WebView build's home screen (once, on Android). An empty Qt home
// takes it as it was; otherwise whatever isn't here yet goes after it, unpinned.
function importLegacy(json) {
let kv;
try { kv = JSON.parse(json); } catch (e) { return; }
const old = L.legacy(kv || {});
if (old.length === 0) return;
const has = {};
for (const s of home) has[s.kind === "widget" ? "w" + s.wid : "a" + s.str] = true;
const fresh = home.length === 0;
for (const s of old) {
if (home.length >= homeCap) break;
if (has[s.kind === "widget" ? "w" + s.wid : "a" + s.str]) continue;
if (!fresh) { s.x = -1; s.y = -1; }
home.push(s);
}
commit();
say("Brought over your home screen");
}
function loadApps() {
const list = Host.apps();
const rows = {};
@@ -391,6 +411,7 @@ Window {
}
function onWidgetDrop(moved) { root.drop(moved) }
function onToast(text) { root.say(text) }
function onLegacyHome(json) { root.importLegacy(json) }
}
Component.onCompleted: {