Start the Qt Quick rewrite of the launcher in qt/

A QML UI with feature parity as the goal: home grid that fills the screen with
dense packing and pinned cells, drag to reorder or into an empty cell, widget
resize handles snapping to the grid, the app drawer with search and long-press
menu, sheets, and the widget picker. HomeActivity (a QtActivity) keeps the
Android parts and hosts native widget views over the QML slots, as the WebView
shell did. A desktop backend serves the demo data, so qt/tests/e2e.cpp drives
the UI end to end offscreen; CI runs it and builds an APK that installs next to
the current launcher as ultra Home (Qt).

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 04:40:25 +00:00
1 parent a880573afb
commit 74ddcfeab6
33 files changed
+3680

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
import QtQuick
// An app's or widget's icon from HomeActivity (image://icon/KEY), or a blank disc
// until it arrives or if it can't be drawn.
Item {
id: root
property string key: "" // "a:COMPONENT" or "w:PROVIDER"
property int generation: 0 // bumped when the app list changes, so icons reload
property real size: 40
width: size
height: size
Rectangle {
anchors.fill: parent
radius: width / 2
color: Qt.rgba(1, 1, 1, .18)
visible: img.status !== Image.Ready
}
Image {
id: img
anchors.fill: parent
asynchronous: true
fillMode: Image.PreserveAspectFit
smooth: true
mipmap: true
sourceSize.width: Math.ceil(root.size * Screen.devicePixelRatio)
sourceSize.height: Math.ceil(root.size * Screen.devicePixelRatio)
source: root.key ? "image://icon/" + encodeURIComponent(root.key) + "?" + root.generation : ""
}
}
+147
View File
@@ -0,0 +1,147 @@
import QtQuick
// Every app, with a search. It slides down over the home screen; swiping up past the
// end of the list (or Close, or back) puts it away. In pick mode a tap adds an app to
// the home screen or takes it off, and the keyboard stays down.
Item {
id: root
property bool open: false
property bool picking: false
property var apps: [] // [{label, component, system}]
property var homeSet: ({}) // component -> true: on the home screen
property bool loading: true
property int generation: 0
property real insetTop: 0
property real insetBottom: 0
property alias query: search.text
readonly property real edge: y + height // the drawer's bottom edge, for covering widgets
readonly property var shown: {
const q = search.text.toLowerCase();
const out = [];
for (let i = 0; i < apps.length; i++)
if (!q || apps[i].label.toLowerCase().indexOf(q) >= 0) out.push(i);
return out;
}
signal openApp(int row)
signal toggleApp(int row)
signal appMenu(int row)
signal closeRequested()
width: parent.width
height: parent.height
y: open ? 0 : -height
visible: y > -height
Behavior on y { NumberAnimation { duration: 220; easing.type: Easing.OutCubic } }
function openFirst() {
if (shown.length > 0 && search.text.length > 0) openApp(shown[0]);
}
onOpenChanged: {
if (open && !picking) search.focusNow();
if (!open) {
search.input.focus = false;
Qt.inputMethod.hide();
search.text = "";
grid.positionViewAtBeginning();
}
}
Rectangle {
anchors.fill: parent
color: Qt.rgba(10 / 255, 10 / 255, 14 / 255, .9)
}
MouseArea { anchors.fill: parent } // nothing under the drawer takes its touches
Column {
id: head
x: Math.max(16, (root.width - 560) / 2 + 16)
width: Math.min(root.width, 560) - 32
y: root.insetTop + 16
spacing: 16
Row {
width: parent.width
spacing: 8
SearchField {
id: search
width: parent.width - close.width - 8
placeholder: "Search apps"
onAccepted: root.openFirst()
onEscaped: text = ""
}
PillButton {
id: close
anchors.verticalCenter: search.verticalCenter
text: root.picking ? "Done" : "Close"
onClicked: root.closeRequested()
}
}
Text {
visible: root.picking
width: parent.width
text: "Tap apps to add them to the home screen or take them off."
color: "white"
opacity: .8
font.pixelSize: 14
wrapMode: Text.Wrap
horizontalAlignment: Text.AlignHCenter
}
}
GridView {
id: grid
objectName: "drawerGrid"
x: head.x
width: head.width
anchors.top: head.bottom
anchors.topMargin: 16
anchors.bottom: parent.bottom
readonly property int cols: root.width >= 480 ? 5 : 4
cellWidth: width / cols
cellHeight: 104
clip: true
bottomMargin: root.insetBottom + 24
boundsBehavior: Flickable.DragOverBounds
model: root.shown
// Swiping up once the list is at its end puts the drawer away.
onDragEnded: if (verticalOvershoot > 48) root.closeRequested()
delegate: Item {
id: cell
required property int index
required property var modelData
readonly property var app: root.apps[modelData] || ({})
width: grid.cellWidth
height: grid.cellHeight
Tile {
width: parent.width
height: 84
key: "a:" + (cell.app.component || "")
label: cell.app.label || ""
generation: root.generation
iconSize: 52
fontSize: 12
spacing: 6
checkable: root.picking
checked: root.picking && root.homeSet[cell.app.component] === true
pressed: area.pressed
}
MouseArea {
id: area
width: parent.width
height: 84
pressAndHoldInterval: 450
onClicked: root.picking ? root.toggleApp(cell.modelData) : root.openApp(cell.modelData)
onPressAndHold: if (!root.picking) root.appMenu(cell.modelData)
}
}
}
Text {
anchors.centerIn: grid
visible: root.loading || root.shown.length === 0
text: root.loading ? "Loading apps…" : "No apps match."
color: "white"
opacity: .85
font.pixelSize: 15
}
}
+139
View File
@@ -0,0 +1,139 @@
.pragma library
// The home grid, as plain functions over the home list so they can be tested on their
// own (tests/layout.test.mjs). A slot is
// {kind: "app", str: COMPONENT, x, y}
// {kind: "widget", str: LABEL, wid: HOST_ID, w: COLUMNS (0: whole row), rows, x, y}
// where x, y is the cell it was dropped into (column, row from 0), or -1, -1: placed in
// order into the first free cells that fit it ("dense" packing, so apps fill the cells
// beside a widget and the grid has no holes).
var CELL = 64; // row height, px
var RGAP = 8; // gap between rows
var CGAP = 8; // gap between columns
// Rows of app tiles nearest to a widget height in px, at least one.
function widgetRows(px) {
return Math.max(1, Math.floor((px + RGAP + (CELL + RGAP) / 2) / (CELL + RGAP)));
}
function slotW(s, cols) {
if (s.kind !== "widget") return 1;
return (s.w <= 0 || s.w > cols) ? cols : s.w;
}
function slotH(s) {
return s.kind === "widget" ? Math.max(1, s.rows | 0) : 1;
}
function pinned(s, cols) {
return s.x >= 0 && s.y >= 0 && s.x + slotW(s, cols) <= cols;
}
// Where each slot goes: [{col, row, w, h}] (null for a hidden slot), and the rows used,
// at least nrows (the rows that fill the screen).
function pack(home, cols, nrows, hidden) {
var occ = [];
function taken(c, r) { return occ[r] !== undefined && occ[r][c] === true; }
function fits(c, r, w, h) {
if (c < 0 || c + w > cols) return false;
for (var y = r; y < r + h; y++)
for (var x = c; x < c + w; x++)
if (taken(x, y)) return false;
return true;
}
function mark(c, r, w, h) {
for (var y = r; y < r + h; y++) {
if (occ[y] === undefined) occ[y] = [];
for (var x = c; x < c + w; x++) occ[y][x] = true;
}
}
var cells = new Array(home.length);
var rows = Math.max(0, nrows | 0);
var i, s, w, h;
// Pinned slots first, where they were put (they may overlap each other).
for (i = 0; i < home.length; i++) {
s = home[i];
cells[i] = null;
if ((hidden && hidden[i]) || !pinned(s, cols)) continue;
w = slotW(s, cols); h = slotH(s);
cells[i] = {col: s.x, row: s.y, w: w, h: h};
mark(s.x, s.y, w, h);
rows = Math.max(rows, s.y + h);
}
// The rest in order, each into the first free cells that fit it.
for (i = 0; i < home.length; i++) {
s = home[i];
if ((hidden && hidden[i]) || cells[i] !== null) continue;
w = slotW(s, cols); h = slotH(s);
for (var r = 0; cells[i] === null; r++) {
for (var c = 0; c + w <= cols; c++) {
if (fits(c, r, w, h)) {
cells[i] = {col: c, row: r, w: w, h: h};
mark(c, r, w, h);
rows = Math.max(rows, r + h);
break;
}
}
}
}
return {cells: cells, rows: rows};
}
// A cell's box in px, given the column width.
function box(cell, colW) {
return {x: cell.col * (colW + CGAP), y: cell.row * (CELL + RGAP),
w: cell.w * colW + (cell.w - 1) * CGAP, h: cell.h * CELL + (cell.h - 1) * RGAP};
}
// The cell nearest to the top left of a box at x, y (px in the grid).
function cellAt(x, y, colW) {
return [Math.max(0, Math.round(x / (colW + CGAP))), Math.max(0, Math.round(y / (CELL + RGAP)))];
}
// Slot i pinned with its top left at col, row (kept on the screen's grid).
function pin(home, i, col, row, cols, nrows) {
var s = home[i];
var x = col, y = row;
if (x + slotW(s, cols) > cols) x = cols - slotW(s, cols);
if (nrows > 0 && y + slotH(s) > nrows) y = nrows - slotH(s);
s.x = Math.max(0, x);
s.y = Math.max(0, y);
}
// Unpin the slots under pinned slot i, so they flow into free cells.
function clearCells(home, i, cols) {
var a = home[i];
for (var j = 0; j < home.length; j++) {
var b = home[j];
if (j === i || b.x < 0) continue;
if (b.x < a.x + slotW(a, cols) && a.x < b.x + slotW(b, cols)
&& b.y < a.y + slotH(a) && a.y < b.y + slotH(b)) {
b.x = -1;
b.y = -1;
}
}
}
// Take slot a out and put it back at b, shifting the slots between.
function move(home, a, b) {
var s = home.splice(a, 1)[0];
home.splice(b, 0, s);
}
// Resize steps: the number of cells (of size px, gap apart) nearest to want px, kept
// within [min, max] px where it can be (max 0: no limit), and within [lo, hi] cells.
function span(k, size, gap) { return k * size + (k - 1) * gap; }
function fit(want, lo, hi, size, gap, min, max) {
var k = Math.round((want + gap) / (size + gap));
while (k < hi && span(k, size, gap) < min - 8) k++;
while (k > lo && max > 0 && span(k, size, gap) > max + 8) k--;
return Math.max(lo, Math.min(hi, k));
}
// Columns a new widget of natural width px starts at (0: the whole row).
function widgetCols(px, colW, cols) {
if (!px) return 0;
var k = Math.max(1, Math.ceil((px + CGAP - 8) / (colW + CGAP)));
return k >= cols ? 0 : k;
}
+908
View File
@@ -0,0 +1,908 @@
import QtQuick
import Launcher.Host
import "Layout.js" as L
// An Android home screen. The home starts blank: you add apps and widgets to it with a
// long press. Swiping down opens the drawer with every app and a search.
//
// The home grid packs apps and widgets in order with no holes (Layout.js), and runs on
// to the bottom of the screen, so the empty cells there take apps too. A long press on
// a home app or widget picks it up: drag it over another to move it there in the order,
// or into an empty cell to leave it in that cell; or let go without moving to get its
// menu. Letting go of a widget that way shows resize handles on its right and bottom
// edges instead: dragging them snaps the widget to whole grid columns and rows, within
// the sizes it allows, and dragging the widget itself moves it, staying in that mode.
//
// Host (backend.cpp, over HomeActivity.java) lists apps and widget providers, launches
// things, and draws real widget views over the slots this file reports (placeWidgets).
Window {
id: root
objectName: "home"
visible: true
width: 412
height: 892
color: "transparent"
title: "ultra Home"
// ---- model
property var apps: [] // [{label, component, system}], by label
property var appRow: ({}) // component -> row in apps
property bool loading: true
property int generation: 0 // bumped when the app list changes
property var home: [] // slots, see Layout.js
property bool drawerOpen: false
property bool picking: false // the drawer adds apps to home / takes them off
property string sheet: "" // "", "menu", "item", "app", "widgets"
property int item: -1 // home slot the item sheet is about
property int appSheetRow: -1 // app row the app sheet is about
property string gone: "" // being uninstalled: its home slot goes once it leaves the list
property int lifted: -1 // home slot picked up by a long press
property int resizing: -1 // widget slot showing resize handles
property bool regrab: false // the lifted slot was grabbed from resizing: drop it back there
property var providers: [] // widget providers, for the picker
property bool wloading: false
property var chosen: null // provider being added
property real scrollY: 0
readonly property int homeCap: 200
// ---- geometry (logical px)
readonly property real insetTop: Math.max(0, Host.insetTop - (Host.android ? root.y : 0))
readonly property real insetBottom: Host.insetBottom
readonly property real contentW: Math.min(width, 560)
readonly property real contentX: (width - contentW) / 2
readonly property real gridX: contentX + 16
readonly property real gridW: contentW - 32
readonly property int cols: width >= 480 ? 6 : 5
readonly property real colW: (gridW - (cols - 1) * L.CGAP) / cols
readonly property real panelY: insetTop + 16
readonly property real panelH: 54
readonly property real gridTop: panelY + panelH + 16 // in home content coordinates
readonly property real gridBottom: height - (insetBottom + 24)
readonly property int nrows: home.length > 0
? Math.max(1, Math.floor((gridBottom - gridTop + L.RGAP) / (L.CELL + L.RGAP))) : 0
readonly property var hidden: home.map(s => s.kind === "app" && appRow[s.str] === undefined)
readonly property var packed: L.pack(home, cols, nrows, hidden)
readonly property real gridH: Math.max(0, packed.rows * (L.CELL + L.RGAP) - L.RGAP)
readonly property real contentH: gridTop + gridH + insetBottom + 24
readonly property real maxScroll: Math.max(0, contentH - height)
onMaxScrollChanged: if (scrollY > maxScroll) scrollY = maxScroll
function boxOf(i) { return packed.cells[i] ? L.box(packed.cells[i], colW) : null }
// ---- updates
function commit() {
home = home.slice();
Host.saveHome(JSON.stringify(home.map(s => s.kind === "widget"
? {kind: "widget", str: s.str, wid: s.wid, w: s.w, rows: s.rows, x: s.x, y: s.y}
: {kind: "app", str: s.str, x: s.x, y: s.y})));
}
function loadHome() {
let saved = [];
try { saved = JSON.parse(Host.loadHome() || "[]"); } catch (e) { saved = []; }
const out = [];
for (const s of saved) {
if (!s || typeof s.str !== "string" || out.length >= homeCap) continue;
out.push(s.kind === "widget"
? {kind: "widget", str: s.str, wid: s.wid | 0, w: s.w | 0, rows: Math.max(1, s.rows | 0),
x: s.x ?? -1, y: s.y ?? -1}
: {kind: "app", str: s.str, x: s.x ?? -1, y: s.y ?? -1});
}
home = out;
}
function loadApps() {
const list = Host.apps();
const rows = {};
for (let i = 0; i < list.length; i++) rows[list[i].component] = i;
apps = list;
appRow = rows;
loading = false;
dropGone();
}
function reload() {
generation++;
loadApps();
if (sheet === "app") { sheet = ""; appSheetRow = -1; }
}
// Once an app uninstalled from the drawer is out of the list, take it off home.
function dropGone() {
if (!gone || appRow[gone] !== undefined) return;
for (let i = 0; i < home.length; i++) {
if (home[i].kind === "app" && home[i].str === gone) { removeSlot(i); break; }
}
gone = "";
}
property string notice: ""
function say(msg) { notice = msg; noticeTimer.restart(); }
Timer { id: noticeTimer; interval: 1800; onTriggered: root.notice = "" }
function homeOf(component) {
for (let i = 0; i < home.length; i++)
if (home[i].kind === "app" && home[i].str === component) return i;
return -1;
}
readonly property var homeSet: {
const m = {};
for (const s of home) if (s.kind === "app") m[s.str] = true;
return m;
}
function addApp(row) {
const c = apps[row].component;
if (homeOf(c) >= 0) say("Already on the home screen");
else if (home.length >= homeCap) say("The home screen is full");
else { home.push({kind: "app", str: c, x: -1, y: -1}); commit(); say("Added to home"); }
}
function toggleApp(row) {
const c = apps[row].component, i = homeOf(c);
if (i >= 0) removeSlot(i);
else if (home.length < homeCap) { home.push({kind: "app", str: c, x: -1, y: -1}); commit(); }
}
function removeSlot(i) {
if (i < 0 || i >= home.length) return;
if (home[i].kind === "widget") Host.removeWidget(home[i].wid);
home.splice(i, 1);
commit();
}
function swapSlots(a, b) {
if (a < 0 || b < 0 || a >= home.length || b >= home.length) return;
const t = home[a]; home[a] = home[b]; home[b] = t;
commit();
}
function slotOfWidget(wid) {
for (let i = 0; i < home.length; i++)
if (home[i].kind === "widget" && home[i].wid === wid) return i;
return -1;
}
function closeAll() {
drawerOpen = false; picking = false; sheet = ""; item = -1; appSheetRow = -1;
lifted = -1; resizing = -1; regrab = false;
}
function openDrawer() { if (sheet === "") drawerOpen = true; }
function closeDrawer() { if (drawerOpen && sheet === "") { drawerOpen = false; picking = false; } }
function closeSheet() { sheet = ""; item = -1; appSheetRow = -1; }
function launchApp(row) { Host.launch(apps[row].component); closeAll(); }
function back() {
if (lifted >= 0) { lifted = -1; regrab = false; }
else if (resizing >= 0) resizing = -1;
else if (sheet !== "") closeSheet();
else if (drawerOpen) { drawerOpen = false; picking = false; }
}
function goHome() { closeAll(); scrollY = 0; }
// ---- picking up and moving home slots
function lift(i) {
if (drawerOpen || sheet !== "" || i === lifted) return;
Host.haptic();
resizing = -1; regrab = false; lifted = i;
}
function grab(i) {
if (i < 0 || i !== resizing || drawerOpen || sheet !== "") return;
resizing = -1; regrab = true; lifted = i;
}
property var carry: null // {dx, dy, cell}: where the lifted slot was held, the cell sent last
function toGrid(x, y) { return {x: x - gridX, y: y + scrollY - gridTop} }
function inside(b, x, y) { return b && x >= b.x && x <= b.x + b.w && y >= b.y && y <= b.y + b.h }
// The slot under grid point x, y (not the lifted one if skipLifted).
function slotAtGrid(x, y, skipLifted) {
for (let i = 0; i < home.length; i++) {
if (skipLifted && i === lifted) continue;
if (inside(boxOf(i), x, y)) return i;
}
return -1;
}
// The finger is at x, y (window px; x0, y0 where it went down). Over another app the
// lifted app takes its place in the order (the grid stays packed); over an empty cell
// the slot is left in that cell, top left by where it was held. A widget always goes
// to the cell under it, so it can sit on any row, and apps flow around it.
function dragTo(x, y, x0, y0) {
if (lifted < 0) return;
const p = toGrid(x, y), b = boxOf(lifted);
if (!b) return;
if (!carry) {
const p0 = toGrid(x0, y0);
carry = {dx: p0.x - b.x, dy: p0.y - b.y, cell: -1};
}
const widget = home[lifted].kind === "widget";
if (!widget && inside(b, p.x, p.y)) return;
const fc = L.cellAt(p.x - colW / 2, p.y - L.CELL / 2, colW);
let to = slotAtGrid(p.x, p.y, true);
if (to < 0) to = slotAtGrid(fc[0] * (colW + L.CGAP) + colW / 2, fc[1] * (L.CELL + L.RGAP) + L.CELL / 2, true);
if (to >= 0 && !widget) {
carry.cell = -1;
home[lifted].x = -1; home[lifted].y = -1; // back into the flow, at that place
L.move(home, lifted, to);
lifted = to;
commit();
return;
}
if (p.y > packed.rows * (L.CELL + L.RGAP)) return; // below the grid
const c = L.cellAt(p.x - carry.dx, p.y - carry.dy, colW);
const cell = c[1] * 64 + Math.min(c[0], 63);
if (cell !== carry.cell) {
carry.cell = cell;
L.pin(home, lifted, c[0], c[1], cols, nrows);
commit();
}
}
// Letting go: whatever a pinned slot now covers moves on to free cells. Let go
// without moving, an app gets its menu and a widget its resize handles.
function drop(moved) {
carry = null;
if (lifted < 0) return;
if (home[lifted].x >= 0) { L.clearCells(home, lifted, cols); commit(); }
if (!moved || regrab) {
if (home[lifted].kind === "widget") resizing = lifted;
else { item = lifted; sheet = "item"; }
}
lifted = -1;
regrab = false;
}
// ---- widgets
function pickWidget() {
sheet = "widgets";
widgetSearch.text = "";
wloading = true;
Qt.callLater(() => { providers = Host.widgetProviders(); wloading = false; });
}
readonly property var shownProviders: {
const q = widgetSearch.text.toLowerCase(), out = [];
for (let i = 0; i < providers.length; i++) {
const p = providers[i];
if (!q || p.label.toLowerCase().indexOf(q) >= 0 || p.app.toLowerCase().indexOf(q) >= 0) out.push(i);
}
return out;
}
function chooseWidget(i) {
if (i < 0) return;
if (home.length < homeCap) { chosen = providers[i]; Host.addWidget(chosen.provider); }
else say("The home screen is full");
closeSheet();
}
function widgetAdded(id) {
if (!chosen || home.length >= homeCap) return;
const lim = Host.widgetLimits(id);
home.push({kind: "widget", str: chosen.label, wid: id, w: L.widgetCols(lim.w || 0, colW, cols),
rows: L.widgetRows(chosen.h), x: -1, y: -1});
chosen = null;
commit();
}
// Resize the widget being edited to cols columns and rows rows.
function resizeTo(c, r) {
if (resizing < 0) return;
const s = home[resizing];
s.w = c >= cols ? 0 : c;
s.rows = r;
if (s.x >= 0) { L.pin(home, resizing, s.x, s.y, cols, nrows); L.clearCells(home, resizing, cols); }
commit();
}
// ---- telling Host where the live widget slots are
// A slot is live (its native view is shown over it) while nothing covers the home
// screen. While one is resized the others step aside, so nothing covers its handles.
// Under the open drawer the widgets stay put and the drawer's edge covers them.
readonly property var liveSlots: {
const out = [];
if (drawerOpen || sheet !== "") return out;
for (let i = 0; i < home.length; i++) {
const s = home[i], b = boxOf(i);
if (s.kind !== "widget" || !b || (resizing >= 0 && i !== resizing)) continue;
const g = homeContent.mapToGlobal(gridX + b.x, gridTop + b.y - scrollY);
out.push({id: s.wid, x: g.x, y: g.y, w: b.w, h: b.h, editing: i === resizing});
}
return out;
}
property string placed: ""
function place() {
const j = JSON.stringify(liveSlots);
if (j === placed || (drawerOpen && sheet === "")) return;
placed = j;
Host.placeWidgets(liveSlots);
}
onLiveSlotsChanged: Qt.callLater(place)
// Keep the system's back swipe off the resize handles.
readonly property var handleRects: {
if (resizing < 0 || !handles.visible || handles.width + handles.x + handles.y + handles.height < 0) return [];
return [rHandle, bHandle, rbHandle].map(h => {
const g = h.mapToGlobal(0, 0);
return {x: g.x, y: g.y, w: h.width, h: h.height};
});
}
onHandleRectsChanged: Host.excludeGestures(handleRects)
// Native widgets sit above Qt's surface, so the drawer can't cover them by itself.
// While it slides the backend hides them above its bottom edge (a little ahead, by
// its speed, since the native side trails a frame), and once it is gone shows them
// again after a frame without it.
property real coverSent: 0
property real coverLast: 0
property bool uncoverPending: false
function cover() {
let y = 0;
if (drawer.visible) {
const b = drawer.edge;
y = b >= height - 1 ? -1 : Math.max(0, Math.ceil(b + 2 * Math.max(0, b - coverLast)));
coverLast = b;
if (y >= height) y = height - 1;
} else coverLast = 0;
if (y === 0) { if (coverSent !== 0) uncoverPending = true; return; }
uncoverPending = false;
const gy = y < 0 ? -1 : homeContent.mapToGlobal(0, y).y;
if (gy !== coverSent) { coverSent = gy; Host.coverWidgets(gy); }
}
onFrameSwapped: if (uncoverPending) { uncoverPending = false; coverSent = 0; Host.coverWidgets(0); }
// ---- Host
Connections {
target: Host
function onAppsChanged() { root.reload() }
function onHomePressed() { root.goHome() }
function onBackPressed() { root.back() }
function onWidgetAdded(id) { root.widgetAdded(id) }
function onWidgetMenu(id) {
const i = root.slotOfWidget(id);
if (i >= 0 && !root.drawerOpen && root.sheet === "") { root.resizing = -1; root.regrab = false; root.lifted = i; }
}
function onWidgetGrab(id) { root.grab(root.slotOfWidget(id)) }
function onWidgetDrag(x, y) {
const p = homeContent.mapFromGlobal(x, y);
touch.dragged = true;
root.dragTo(p.x, p.y, p.x, p.y);
}
function onWidgetDrop(moved) { root.drop(moved) }
function onToast(text) { root.say(text) }
}
Component.onCompleted: {
loadHome();
Host.ready();
Qt.callLater(loadApps);
}
// ---- view
Item {
id: homeContent
anchors.fill: parent
// The desktop stand-in for a wallpaper.
Rectangle {
anchors.fill: parent
visible: !Host.android
gradient: Gradient {
orientation: Gradient.Vertical
GradientStop { position: 0; color: "#1e293b" }
GradientStop { position: .55; color: "#4c1d95" }
GradientStop { position: 1; color: "#0f172a" }
}
}
Item {
id: scroller
width: parent.width
height: root.contentH
y: -root.scrollY
// The panel at the top of home: shortcuts to system surfaces.
Rectangle {
id: panel
width: Math.min(352, root.contentW - 32)
height: root.panelH
x: (root.width - width) / 2
y: root.panelY
radius: 20
color: Qt.rgba(1, 1, 1, .12)
border.color: Qt.rgba(1, 1, 1, .16)
border.width: 1
Rectangle {
id: windowsBtn
property bool pressed: false
anchors.fill: parent
anchors.margins: 7
radius: 14
color: pressed ? Qt.rgba(1, 1, 1, .22) : Qt.rgba(1, 1, 1, .1)
Row {
anchors.centerIn: parent
spacing: 10
Item { // the Windows glyph: two overlapping windows
width: 18; height: 18
anchors.verticalCenter: parent.verticalCenter
Rectangle { x: 0; y: 0; width: 13; height: 13; radius: 4; color: "transparent"
border.color: "white"; border.width: 2; opacity: .6 }
Rectangle { x: 5; y: 5; width: 13; height: 13; radius: 4; color: Qt.rgba(1, 1, 1, .15)
border.color: "white"; border.width: 2 }
}
Text {
text: "Windows"
color: "white"
font.pixelSize: 15
font.weight: Font.Medium
style: Text.Raised
styleColor: Qt.rgba(0, 0, 0, .35)
anchors.verticalCenter: parent.verticalCenter
}
}
}
}
// The home grid.
Item {
id: grid
objectName: "homeGrid"
x: root.gridX
y: root.gridTop
width: root.gridW
height: root.gridH
Repeater {
model: root.home.length
delegate: Item {
id: slot
required property int index
readonly property var s: root.home[index] || ({})
readonly property var b: root.boxOf(index)
readonly property bool isWidget: s.kind === "widget"
readonly property bool isLifted: index === root.lifted
readonly property bool isResizing: index === root.resizing
readonly property bool live: Host.android && isWidget && !root.drawerOpen
&& root.sheet === "" && (root.resizing < 0 || isResizing)
readonly property int row: isWidget ? -1 : (root.appRow[s.str] ?? -1)
objectName: "slot" + index
visible: b !== null
x: b ? b.x : 0
y: b ? b.y : 0
width: b ? b.w : 0
height: b ? b.h : 0
z: isLifted || isResizing ? 2 : 0
scale: isLifted ? 1.12 : 1
opacity: root.lifted >= 0 && !isLifted ? .8 : 1
Behavior on scale { NumberAnimation { duration: 150; easing.type: Easing.OutCubic } }
Rectangle { // the frame: a picked-up slot, or a widget with no live view
anchors.fill: parent
radius: slot.isWidget ? 20 : 16
visible: slot.isLifted || (slot.isWidget && (!slot.live || slot.isResizing))
color: slot.isLifted ? Qt.rgba(1, 1, 1, .16) : Qt.rgba(1, 1, 1, .1)
border.color: slot.isWidget && !slot.isLifted ? Qt.rgba(1, 1, 1, .3) : "transparent"
border.width: 1
}
Rectangle { // the outline around a widget being resized
visible: slot.isResizing
anchors.fill: parent
anchors.margins: -5
radius: 24
color: "transparent"
border.color: Qt.rgba(1, 1, 1, .85)
border.width: 2
}
Text {
visible: slot.isWidget && !slot.live
anchors.centerIn: parent
width: parent.width - 16
text: slot.s.str || ""
color: "white"
opacity: .75
font.pixelSize: 14
horizontalAlignment: Text.AlignHCenter
elide: Text.ElideRight
style: Text.Raised
styleColor: Qt.rgba(0, 0, 0, .55)
}
Tile {
visible: !slot.isWidget
anchors.fill: parent
key: "a:" + (slot.s.str || "")
label: slot.row >= 0 ? root.apps[slot.row].label : ""
generation: root.generation
iconSize: 40
fontSize: 11
spacing: 4
pressed: touch.pressedSlot === slot.index && !slot.isLifted && touch.pressed && root.lifted < 0
}
}
}
}
Text {
visible: root.home.length === 0
x: root.contentX + 32
width: root.contentW - 64
y: root.height * .3 + root.insetTop
text: "Swipe down for all apps. Long-press to add apps and widgets."
color: "white"
opacity: .85
font.pixelSize: 15
lineHeight: 1.5
wrapMode: Text.Wrap
horizontalAlignment: Text.AlignHCenter
style: Text.Raised
styleColor: Qt.rgba(0, 0, 0, .55)
}
}
// Every touch on the home screen: taps, long presses, dragging a lifted slot,
// scrolling a grid taller than the screen, and the swipe down to the drawer.
MouseArea {
id: touch
objectName: "homeTouch"
anchors.fill: parent
enabled: !root.drawerOpen && root.sheet === ""
property var start: null // {x, y, t, scroll, moved}
property int pressedSlot: -1
property bool longFired: false
property bool dragged: false
function onPanel(x, y) {
const p = windowsBtn.mapFromItem(touch, x, y);
return p.x >= 0 && p.y >= 0 && p.x <= windowsBtn.width && p.y <= windowsBtn.height;
}
onPressed: (m) => {
const g = root.toGrid(m.x, m.y);
start = {x: m.x, y: m.y, t: Date.now(), scroll: root.scrollY, moved: false};
pressedSlot = root.slotAtGrid(g.x, g.y, false);
longFired = false;
dragged = false;
windowsBtn.pressed = onPanel(m.x, m.y);
if (root.resizing >= 0 && pressedSlot === root.resizing) {
// A widget showing handles is moved by its body, no long press needed.
root.grab(pressedSlot);
longFired = true;
return;
}
hold.restart();
}
onPositionChanged: (m) => {
if (!start) return;
if (!start.moved && Math.hypot(m.x - start.x, m.y - start.y) < 10) return;
if (!start.moved) { start.moved = true; hold.stop(); windowsBtn.pressed = false; }
if (root.lifted >= 0) { dragged = true; root.dragTo(m.x, m.y, start.x, start.y); return; }
if (!longFired) root.scrollY = Math.max(0, Math.min(root.maxScroll, start.scroll - (m.y - start.y)));
}
onReleased: (m) => {
hold.stop();
windowsBtn.pressed = false;
const s = start;
start = null;
if (!s) return;
if (root.lifted >= 0) { root.drop(s.moved); return; }
if (longFired) return;
if (!s.moved) {
const i = pressedSlot;
if (onPanel(m.x, m.y)) { Host.openRecents(); root.resizing = -1; }
else if (i >= 0 && root.home[i].kind === "app") { root.resizing = -1; Host.launch(root.home[i].str); }
else if (root.resizing >= 0) root.resizing = -1; // a tap beside the widget finishes
return;
}
const dx = m.x - s.x, dy = m.y - s.y;
if (Date.now() - s.t < 700 && Math.abs(dy) >= 60 && Math.abs(dx) <= Math.abs(dy)
&& dy > 0 && s.scroll <= 0)
root.openDrawer();
}
onCanceled: {
hold.stop();
windowsBtn.pressed = false;
if (root.lifted >= 0) root.drop(start ? start.moved : false);
start = null;
}
Timer {
id: hold
interval: 450
onTriggered: {
if (!touch.start || touch.start.moved) return;
touch.longFired = true;
windowsBtn.pressed = false;
if (touch.pressedSlot >= 0) root.lift(touch.pressedSlot);
else { root.resizing = -1; Host.haptic(); root.sheet = "menu"; }
}
}
}
// Resize handles just outside the widget's right and bottom edges, where its
// native view doesn't cover them.
Item {
id: handles
readonly property var b: root.resizing >= 0 ? root.boxOf(root.resizing) : null
visible: b !== null && root.lifted < 0 && root.sheet === ""
x: root.gridX + (b ? b.x : 0)
y: root.gridTop - root.scrollY + (b ? b.y : 0)
width: b ? b.w : 0
height: b ? b.h : 0
property var rs: null
function begin(edge) {
const i = root.resizing, c = root.packed.cells[i];
// Sizes are measured from where its top left was when the drag began,
// though the widget may move as it resizes and the grid repacks.
rs = {edge: edge, lim: Host.widgetLimits(root.home[i].wid), cols: c.w, rows: c.h,
at: handles.mapToItem(homeContent, 0, 0)};
}
function track(area, m) {
if (!rs) return;
const g = area.mapToItem(homeContent, m.x, m.y), lim = rs.lim;
const p = {x: g.x - rs.at.x, y: g.y - rs.at.y};
let c = rs.cols, r = rs.rows;
if (rs.edge !== "b" && lim.h !== false)
c = L.fit(p.x, 1, root.cols, root.colW, L.CGAP, lim.minW || 0, lim.maxW || 0);
if (rs.edge !== "r" && lim.v !== false)
r = L.fit(p.y, 1, 20, L.CELL, L.RGAP, lim.minH || 0, lim.maxH || 0);
if (c === rs.cols && r === rs.rows) return;
rs.cols = c; rs.rows = r;
Host.haptic();
root.resizeTo(c, r);
}
component Handle: MouseArea {
id: h
property string edge
preventStealing: true
onPressed: handles.begin(edge)
onPositionChanged: (m) => handles.track(h, m)
onReleased: handles.rs = null
onCanceled: handles.rs = null
}
Handle {
id: rHandle
objectName: "handleR"
edge: "r"
x: parent.width; y: 0; width: 16; height: parent.height
Rectangle { x: 6; anchors.verticalCenter: parent.verticalCenter; width: 6; height: 40; radius: 3; color: "white" }
}
Handle {
id: bHandle
objectName: "handleB"
edge: "b"
x: 0; y: parent.height; width: parent.width; height: 16
Rectangle { y: 5; anchors.horizontalCenter: parent.horizontalCenter; width: 40; height: 6; radius: 3; color: "white" }
}
Handle {
id: rbHandle
objectName: "handleRB"
edge: "rb"
x: parent.width - 28; y: parent.height; width: 44; height: 16
Rectangle { x: 26; y: 1; width: 14; height: 14; radius: 4; color: "white" }
}
}
// While a widget is resized: what to do, and Remove / Done.
Rectangle {
id: resizeBar
visible: root.resizing >= 0 && root.sheet === "" && !root.drawerOpen
anchors.horizontalCenter: parent.horizontalCenter
y: root.height - root.insetBottom - 16 - height
width: Math.min(root.width - 32, barRow.implicitWidth + 24)
height: Math.max(48, barRow.implicitHeight + 12)
radius: height / 2
color: Qt.rgba(0, 0, 0, .8)
MouseArea { anchors.fill: parent }
Row {
id: barRow
anchors.verticalCenter: parent.verticalCenter
x: 16
spacing: 6
Text {
width: Math.min(implicitWidth, root.width - 32 - 24 - 16 - removeBtn.width - doneBtn.width - 12)
anchors.verticalCenter: parent.verticalCenter
text: "Drag to move, or drag the handles to resize"
color: "white"
font.pixelSize: 13
wrapMode: Text.Wrap
}
PillButton {
id: removeBtn
text: "Remove"
fontSize: 13
anchors.verticalCenter: parent.verticalCenter
onClicked: { const i = root.resizing; root.resizing = -1; root.removeSlot(i); }
}
PillButton {
id: doneBtn
text: "Done"
primary: true
fontSize: 13
anchors.verticalCenter: parent.verticalCenter
onClicked: root.resizing = -1
}
}
}
Drawer {
id: drawer
objectName: "drawer"
open: root.drawerOpen
picking: root.picking
apps: root.apps
homeSet: root.homeSet
loading: root.loading
generation: root.generation
insetTop: root.insetTop
insetBottom: root.insetBottom
onEdgeChanged: root.cover()
onVisibleChanged: root.cover()
onOpenApp: (row) => root.launchApp(row)
onToggleApp: (row) => root.toggleApp(row)
onAppMenu: (row) => {
if (root.sheet !== "") return;
Host.haptic();
root.appSheetRow = row;
root.sheet = "app";
}
onCloseRequested: root.closeDrawer()
}
// ---- sheets
Sheet {
id: menuSheet
open: root.sheet === "menu"
title: "Home screen"
bottomInset: root.insetBottom
onCloseRequested: root.closeSheet()
SheetButton { text: "Add apps"; onClicked: { root.sheet = ""; root.picking = true; root.drawerOpen = true; } }
SheetButton { text: "Add widget"; onClicked: root.pickWidget() }
SheetButton { text: "Wallpaper"; onClicked: { Host.pickWallpaper(); root.closeSheet(); } }
SheetButton { text: "Settings"; onClicked: { Host.openSettings(); root.closeSheet(); } }
SheetButton { text: "Check for updates"; onClicked: { Host.checkUpdates(); root.closeSheet(); } }
}
Sheet {
id: itemSheet
readonly property var s: root.item >= 0 && root.item < root.home.length ? root.home[root.item] : null
open: root.sheet === "item" && s !== null
title: !s ? "" : s.kind === "widget" ? s.str
: (root.appRow[s.str] !== undefined ? root.apps[root.appRow[s.str]].label : "")
bottomInset: root.insetBottom
onCloseRequested: root.closeSheet()
SheetButton {
visible: root.item > 0
text: "Move earlier"
onClicked: { root.swapSlots(root.item, root.item - 1); root.closeSheet(); }
}
SheetButton {
visible: root.item >= 0 && root.item < root.home.length - 1
text: "Move later"
onClicked: { root.swapSlots(root.item + 1, root.item); root.closeSheet(); }
}
SheetButton {
visible: itemSheet.s !== null && itemSheet.s.kind === "app"
text: "App info"
onClicked: { Host.appInfo(itemSheet.s.str); root.closeSheet(); }
}
SheetButton {
text: itemSheet.s !== null && itemSheet.s.kind === "widget" ? "Remove widget" : "Remove from home"
onClicked: { const i = root.item; root.resizing = -1; root.closeSheet(); root.removeSlot(i); }
}
}
Sheet {
id: appSheet
readonly property var app: root.appSheetRow >= 0 && root.appSheetRow < root.apps.length
? root.apps[root.appSheetRow] : null
open: root.sheet === "app" && app !== null
title: app ? app.label : ""
bottomInset: root.insetBottom
onCloseRequested: root.closeSheet()
SheetButton {
text: appSheet.app && root.homeSet[appSheet.app.component] ? "Remove from home" : "Add to home"
onClicked: {
const c = appSheet.app.component, i = root.homeOf(c);
if (i >= 0) root.removeSlot(i); else root.addApp(root.appSheetRow);
root.closeSheet();
}
}
SheetButton {
text: "App info"
onClicked: { Host.appInfo(appSheet.app.component); root.closeSheet(); }
}
SheetButton {
visible: appSheet.app !== null && !appSheet.app.system
text: "Uninstall"
onClicked: { root.gone = appSheet.app.component; Host.uninstall(root.gone); root.closeSheet(); }
}
}
Sheet {
id: widgetSheet
open: root.sheet === "widgets"
title: "Add a widget"
bottomInset: root.insetBottom
onCloseRequested: root.closeSheet()
onOpenChanged: if (!open) { widgetSearch.input.focus = false; Qt.inputMethod.hide(); }
Text {
visible: root.wloading || root.providers.length === 0 || root.shownProviders.length === 0
width: parent.width
topPadding: 12
bottomPadding: 12
horizontalAlignment: Text.AlignHCenter
color: "#a1a1aa"
font.pixelSize: 15
text: root.wloading ? "Loading widgets…"
: root.providers.length === 0 ? "No widgets installed." : "No widgets match."
}
SearchField {
id: widgetSearch
visible: !root.wloading && root.providers.length > 0
width: parent.width
height: visible ? 44 : 0
placeholder: "Search widgets"
fontSize: 15
color: "#27272a"
onAccepted: root.chooseWidget(root.shownProviders.length ? root.shownProviders[0] : -1)
onEscaped: text = ""
}
Item { width: 1; height: 8 }
Repeater {
model: root.wloading ? [] : root.shownProviders
delegate: Rectangle {
id: wrow
required property var modelData
readonly property var p: root.providers[modelData]
width: parent ? parent.width : 0
height: 56
radius: 8
color: wArea.pressed ? "#2e2e36" : "transparent"
AppIcon {
x: 8
anchors.verticalCenter: parent.verticalCenter
size: 40
key: "w:" + wrow.p.provider
generation: root.generation
}
Column {
x: 60
width: parent.width - 68
anchors.verticalCenter: parent.verticalCenter
Text { width: parent.width; text: wrow.p.label; color: "#fafafa"; font.pixelSize: 15; elide: Text.ElideRight }
Text {
width: parent.width
visible: wrow.p.app.length > 0 && wrow.p.app !== wrow.p.label
text: wrow.p.app
color: "#a1a1aa"
font.pixelSize: 13
elide: Text.ElideRight
}
}
MouseArea { id: wArea; anchors.fill: parent; onClicked: root.chooseWidget(wrow.modelData) }
}
}
}
// A short notice at the bottom (e.g. "Added to home").
Rectangle {
visible: root.notice.length > 0
anchors.horizontalCenter: parent.horizontalCenter
y: (resizeBar.visible ? resizeBar.y - 8 : root.height - root.insetBottom - 32) - height
width: Math.min(root.width - 32, noticeText.implicitWidth + 32)
height: 36
radius: 18
color: Qt.rgba(0, 0, 0, .8)
Text {
id: noticeText
anchors.centerIn: parent
width: Math.min(implicitWidth, root.width - 64)
elide: Text.ElideMiddle
text: root.notice
color: "white"
font.pixelSize: 14
}
}
}
}
+27
View File
@@ -0,0 +1,27 @@
import QtQuick
// A rounded text button: "ghost" (clear until pressed) or "primary" (filled).
Rectangle {
id: root
property alias text: label.text
property bool primary: false
property real fontSize: 14
signal clicked()
implicitWidth: label.implicitWidth + 28
implicitHeight: 36
radius: height / 2
color: primary ? (area.pressed ? "#d4d4d8" : "white")
: (area.pressed ? Qt.rgba(1, 1, 1, .18) : "transparent")
Text {
id: label
anchors.centerIn: parent
color: root.primary ? "#111" : "white"
font.pixelSize: root.fontSize
font.weight: Font.Medium
}
MouseArea {
id: area
anchors.fill: parent
onClicked: root.clicked()
}
}
+60
View File
@@ -0,0 +1,60 @@
import QtQuick
// A rounded search box. Enter is "accepted"; the text is "text".
Rectangle {
id: root
property alias text: input.text
property alias placeholder: hint.text
property alias input: input
property real fontSize: 16
signal accepted()
signal escaped()
implicitHeight: 44
radius: height / 2
color: Qt.rgba(1, 1, 1, .1)
border.color: Qt.rgba(1, 1, 1, .15)
border.width: 1
function focusNow() { input.forceActiveFocus(); Qt.inputMethod.show() }
TextInput {
id: input
anchors.left: parent.left
anchors.right: clear.left
anchors.leftMargin: 20
anchors.rightMargin: 8
anchors.verticalCenter: parent.verticalCenter
color: "white"
selectionColor: Qt.rgba(1, 1, 1, .35)
font.pixelSize: root.fontSize
clip: true
inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase
onAccepted: root.accepted()
Keys.onEscapePressed: root.escaped()
Text {
id: hint
anchors.fill: parent
verticalAlignment: Text.AlignVCenter
color: Qt.rgba(1, 1, 1, .6)
font.pixelSize: root.fontSize
visible: input.text.length === 0 && !input.preeditText
}
}
Text {
id: clear
anchors.right: parent.right
anchors.rightMargin: 14
anchors.verticalCenter: parent.verticalCenter
width: visible ? 20 : 0
visible: input.text.length > 0
text: "✕"
color: Qt.rgba(1, 1, 1, .7)
font.pixelSize: 14
horizontalAlignment: Text.AlignHCenter
MouseArea {
anchors.fill: parent
anchors.margins: -10
onClicked: { input.text = ""; root.escaped() }
}
}
}
+69
View File
@@ -0,0 +1,69 @@
import QtQuick
// A panel that rises from the bottom over a dimmed screen (long-press menus, the
// widget picker). Its children go in a column; tapping outside closes it.
Item {
id: root
property bool open: false
property string title: ""
property real bottomInset: 0
property real maxWidth: 560
default property alias content: column.data
signal closeRequested()
anchors.fill: parent
visible: open || panel.y < height
enabled: open
Rectangle {
anchors.fill: parent
color: "black"
opacity: root.open ? .45 : 0
Behavior on opacity { NumberAnimation { duration: 150 } }
MouseArea { anchors.fill: parent; onClicked: root.closeRequested() }
}
Rectangle {
id: panel
width: Math.min(root.width, root.maxWidth)
anchors.horizontalCenter: parent.horizontalCenter
height: Math.min(root.height * .7, column.implicitHeight + 36 + root.bottomInset + 16)
y: root.open ? root.height - height : root.height
Behavior on y { NumberAnimation { duration: 200; easing.type: Easing.OutCubic } }
radius: 20
color: "#18181b"
MouseArea { anchors.fill: parent } // keep taps on the sheet off the overlay
// square off the bottom corners
Rectangle { anchors.bottom: parent.bottom; width: parent.width; height: 20; color: parent.color }
Rectangle {
width: 36; height: 5; radius: 3
anchors.horizontalCenter: parent.horizontalCenter
y: 12
color: "#3f3f46"
}
Flickable {
id: flick
anchors.fill: parent
anchors.topMargin: 28
anchors.leftMargin: 16
anchors.rightMargin: 16
anchors.bottomMargin: root.bottomInset + 16
contentHeight: column.implicitHeight
clip: true
boundsBehavior: Flickable.StopAtBounds
Column {
id: column
width: flick.width
Text {
visible: root.title.length > 0
text: root.title
color: "#fafafa"
font.pixelSize: 16
font.weight: Font.DemiBold
leftPadding: 8
bottomPadding: 8
width: parent.width
elide: Text.ElideRight
}
}
}
}
}
+25
View File
@@ -0,0 +1,25 @@
import QtQuick
// A row in a sheet's menu.
Rectangle {
id: root
property alias text: label.text
signal clicked()
width: parent ? parent.width : 0
height: 48
radius: 8
color: area.pressed ? "#2e2e36" : "transparent"
Text {
id: label
anchors.left: parent.left
anchors.leftMargin: 8
anchors.verticalCenter: parent.verticalCenter
color: "#fafafa"
font.pixelSize: 16
}
MouseArea {
id: area
anchors.fill: parent
onClicked: root.clicked()
}
}
+61
View File
@@ -0,0 +1,61 @@
import QtQuick
// An app: its icon over its name.
Item {
id: root
property string key: ""
property string label: ""
property int generation: 0
property real iconSize: 40
property real fontSize: 11
property real spacing: 4
property bool checkable: false // the drawer's pick mode: a check circle in the corner
property bool checked: false
property bool pressed: false
Rectangle {
anchors.fill: parent
radius: 12
color: Qt.rgba(1, 1, 1, .12)
visible: root.pressed
}
Column {
anchors.centerIn: parent
width: parent.width
spacing: root.spacing
AppIcon {
anchors.horizontalCenter: parent.horizontalCenter
key: root.key
generation: root.generation
size: root.iconSize
}
Text {
width: parent.width - 4
anchors.horizontalCenter: parent.horizontalCenter
text: root.label
color: "white"
font.pixelSize: root.fontSize
horizontalAlignment: Text.AlignHCenter
elide: Text.ElideRight
style: Text.Raised
styleColor: Qt.rgba(0, 0, 0, .55)
}
}
Rectangle {
visible: root.checkable
width: 20; height: 20; radius: 10
x: parent.width / 2 + root.iconSize / 2 - 12
y: 2
color: root.checked ? "white" : Qt.rgba(0, 0, 0, .35)
border.color: "white"
border.width: 2
Text {
anchors.centerIn: parent
visible: root.checked
text: "✓"
color: "#111"
font.pixelSize: 12
font.bold: true
}
}
}