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:
8 files changed
+130
-2
No files matched your search
@@ -346,6 +346,16 @@ int main(int argc, char *argv[]) {
|
||||
js("loadHome()");
|
||||
eq(homeLabels(), "Gmail,Chrome,Phone", "the layout is saved");
|
||||
|
||||
// The WebView build's saved home merges in: new slots go after, unpinned.
|
||||
emit backend.legacyHome(QStringLiteral(
|
||||
"{\"ultra.home.n\":\"3\",\"ultra.home.str.0\":\"com.example.clock/.MainActivity\","
|
||||
"\"ultra.home.cx.0\":\"4\",\"ultra.home.cy.0\":\"4\",\"ultra.home.str.1\":\"com.example.chrome/.MainActivity\","
|
||||
"\"ultra.home.kind.2\":\"1\",\"ultra.home.str.2\":\"Weather\",\"ultra.home.wid.2\":\"7\",\"ultra.home.h.2\":\"200\"}"));
|
||||
settle(50);
|
||||
eq(homeLabels(), "Gmail,Chrome,Phone,Clock,[Weather]", "the old home is brought over");
|
||||
eq(js("home[3].x"), -1, "unpinned when merged");
|
||||
eq(js("home[4].rows"), 3, "widget px become rows");
|
||||
|
||||
// back closes things in order; home closes everything
|
||||
swipe(QPointF(206, 400), QPointF(206, 600));
|
||||
js("back()");
|
||||
|
||||
@@ -3,7 +3,7 @@ import { readFileSync } from "node:fs";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
const src = readFileSync(new URL("../qml/Layout.js", import.meta.url), "utf8").replace(".pragma library", "");
|
||||
const L = new Function(src + "; return {widgetRows, slotW, slotH, pack, box, cellAt, pin, clearCells, move, fit, widgetCols};")();
|
||||
const L = new Function(src + "; return {widgetRows, slotW, slotH, pack, box, cellAt, pin, clearCells, move, fit, widgetCols, legacy};")();
|
||||
|
||||
const app = (x = -1, y = -1) => ({ kind: "app", str: "a", x, y });
|
||||
const widget = (w, rows, x = -1, y = -1) => ({ kind: "widget", str: "W", wid: 1, w, rows, x, y });
|
||||
@@ -61,3 +61,16 @@ assert.equal(L.widgetCols(400, 70, 5), 0);
|
||||
assert.deepEqual(L.box({ col: 1, row: 2, w: 2, h: 1 }, 70), { x: 78, y: 144, w: 148, h: 64 });
|
||||
assert.deepEqual(L.cellAt(80, 150, 70), [1, 2]);
|
||||
console.log("layout ok");
|
||||
|
||||
// The WebView build's saved home converts: apps by component, widgets with px heights to rows.
|
||||
assert.deepEqual(L.legacy({
|
||||
"ultra.home.n": "3",
|
||||
"ultra.home.kind.0": "0", "ultra.home.str.0": "com.a/.Main", "ultra.home.cx.0": "-1", "ultra.home.cy.0": "-1",
|
||||
"ultra.home.kind.1": "1", "ultra.home.str.1": "Clock", "ultra.home.wid.1": "12", "ultra.home.h.1": "136",
|
||||
"ultra.home.w.1": "3", "ultra.home.cx.1": "1", "ultra.home.cy.1": "2",
|
||||
"ultra.home.kind.2": "0",
|
||||
}), [
|
||||
{ kind: "app", str: "com.a/.Main", x: -1, y: -1 },
|
||||
{ kind: "widget", str: "Clock", wid: 12, w: 3, rows: 2, x: 1, y: 2 },
|
||||
]);
|
||||
assert.deepEqual(L.legacy({}), []);
|
||||
Reference in new issue
Block a user