diff options
| -rw-r--r-- | desktop/README.md | 4 | ||||
| -rw-r--r-- | desktop/Settings.qml | 55 |
2 files changed, 51 insertions, 8 deletions
diff --git a/desktop/README.md b/desktop/README.md index 39a0275..187def6 100644 --- a/desktop/README.md +++ b/desktop/README.md @@ -35,7 +35,9 @@ gear tile opens it, and so does IPC: qs -p ./desktop ipc call settings open autostart qs -p ./desktop ipc call settings toggle -`open` takes a page name; an unknown or empty one opens the first page. +`open` takes a page name; an unknown or empty one opens the landing page, +a tile per settings page. A page's back arrow and Escape return there; +Escape on the landing page closes the window. ## The modules diff --git a/desktop/Settings.qml b/desktop/Settings.qml index a397105..af41fe4 100644 --- a/desktop/Settings.qml +++ b/desktop/Settings.qml @@ -30,11 +30,17 @@ Scope { if (root.modules[i].settings) out.push(root.modules[i]); return out; } - readonly property QtObject current: root.pages.find(m => m.name === root.page) ?? root.pages[0] ?? null + // Null is the landing page. + readonly property QtObject current: root.pages.find(m => m.name === root.page) ?? null - // An unknown or empty name opens the first page. + // An unknown or empty name opens the landing page. function show(name) { root.page = name; root.open = true; } - function close() { root.open = false; } + // One step out: a page to the landing page, the landing page closes. + function back() { + if (root.current) root.page = ""; + else root.close(); + } + function close() { root.open = false; root.page = ""; } LazyLoader { active: root.open @@ -49,7 +55,7 @@ Scope { Item { anchors.fill: parent focus: true - Keys.onEscapePressed: root.close() + Keys.onEscapePressed: root.back() ListView { id: side @@ -100,15 +106,50 @@ Scope { color: Qt.alpha(Theme.text, 0.12) } + // The landing page: every settings page as a tile, as the + // drawer's grid shows its modules. Where back returns to. + Item { + anchors { top: parent.top; right: parent.right; bottom: parent.bottom; left: rule.right; margins: 16 } + visible: root.current === null + + Text { + id: landingTitle + height: 44 + verticalAlignment: Text.AlignVCenter + text: "Settings" + font { family: Theme.fontFamily; pixelSize: Theme.fontSize + 2; bold: true } + color: Theme.text + } + + Flow { + id: landing + anchors { top: landingTitle.bottom; topMargin: 12; left: parent.left; right: parent.right } + spacing: 10 + + Repeater { + model: root.pages + + Tile { + required property QtObject modelData + width: (landing.width - 2 * landing.spacing) / 3 + icon: modelData.icon + label: modelData.label + onClicked: root.page = modelData.name + } + } + } + } + Loader { id: pageLoader anchors { top: parent.top; right: parent.right; bottom: parent.bottom; left: rule.right; margins: 16 } sourceComponent: root.current?.page ?? null - // The Page's back arrow and dismiss close the window; - // go() moves to another settings page by name. + // The Page's back arrow steps out to the landing page, + // dismiss closes the window, and go() moves to another + // settings page by name. onLoaded: { - if (item && item.back) item.back.connect(root.close); + if (item && item.back) item.back.connect(root.back); if (item && item.dismiss) item.dismiss.connect(root.close); if (item && item.go) item.go.connect(name => root.page = name); } |
