pragma ComponentBehavior: Bound import QtQuick import QtQuick.Controls import QtQuick.Layouts import "../components" import "../core" import "../theme" import "controls" // Settings sidebar: title, the search field that morphs from its button, page // navigation grouped by section, and search results. Rectangle { id: root // The Settings window: drag handles move it. required property var window property real cornerRadius: 0 topLeftRadius: cornerRadius bottomLeftRadius: cornerRadius color: Qt.alpha(Theme.tint, 0.15) signal searchClosed // Sidebar entries: group captions followed by their pages. readonly property int captionHeight: 30 readonly property int gapHeight: 12 readonly property int itemHeight: 40 readonly property int itemSpacing: 2 readonly property var navEntries: { const entries = []; for (const group of SettingsRegistry.groups) { const pages = SettingsRegistry.pages.filter(p => p.group === group.id); if (pages.length === 0) continue; entries.push({ kind: group.title ? "caption" : "gap", title: group.title }); for (const p of pages) entries.push({ kind: "page", page: p }); } return entries; } function entryHeight(entry) { return entry.kind === "page" ? itemHeight : entry.kind === "caption" ? captionHeight : gapHeight; } function entryY(pageId) { let y = 0; for (const entry of navEntries) { if (entry.kind === "page" && entry.page.id === pageId) return y; y += entryHeight(entry) + itemSpacing; } return -1; } // Search property bool searchActive: false property int searchIndex: 0 readonly property var searchResults: SettingsRegistry.search(searchField.text) function openSearch() { searchActive = true; searchField.forceActiveFocus(); } function closeSearch() { searchActive = false; searchField.clear(); root.searchClosed(); } function chooseResult(result) { if (!result) return; closeSearch(); ShellState.revealSetting(result.page, result.setting); } onSearchResultsChanged: searchIndex = 0 // Keep the selected sidebar entry in view. function revealNavEntry() { const y = entryY(ShellState.settingsPage); if (y < 0 || nav.height <= 0) return; if (y < nav.contentY) nav.contentY = y; else if (y + itemHeight > nav.contentY + nav.height) nav.contentY = Math.min(nav.contentHeight - nav.height, y + itemHeight - nav.height); } ColumnLayout { anchors.fill: parent anchors.margins: 14 spacing: 12 Item { Layout.fillWidth: true Layout.preferredHeight: 36 SettingsDragArea { objectName: "settingsDragHandle" window: root.window } Text { anchors.left: parent.left anchors.leftMargin: 6 anchors.verticalCenter: parent.verticalCenter text: "Settings" color: Theme.text font.pixelSize: 17 font.weight: Font.DemiBold opacity: root.searchActive ? 0 : 1 scale: root.searchActive ? 0.92 : 1 visible: opacity > 0.01 Behavior on opacity { NumberAnimation { duration: Theme.duration easing.type: Easing.OutCubic } } Behavior on scale { NumberAnimation { duration: Theme.duration easing.type: Easing.OutCubic } } } // The search button widens into the search field. Item { id: searchMorph property real progress: root.searchActive ? 1 : 0 Behavior on progress { NumberAnimation { duration: Theme.duration easing.type: Easing.OutCubic } } anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter width: 36 + (parent.width - 36) * progress height: 36 clip: true GlassTextField { id: searchField objectName: "settingsSearch" anchors.fill: parent leftPadding: 36 rightPadding: 36 placeholderText: "Search settings…" opacity: searchMorph.progress enabled: root.searchActive background: Rectangle { radius: height / 2 color: Theme.surfaceVariant border.color: searchField.activeFocus ? Theme.accent : Theme.border } Keys.onEscapePressed: root.closeSearch() Keys.onDownPressed: root.searchIndex = Math.min(root.searchResults.length - 1, root.searchIndex + 1) Keys.onUpPressed: root.searchIndex = Math.max(0, root.searchIndex - 1) Keys.onReturnPressed: root.chooseResult(root.searchResults[root.searchIndex]) Keys.onEnterPressed: root.chooseResult(root.searchResults[root.searchIndex]) } Rectangle { width: 36 height: 36 radius: 18 color: !root.searchActive && searchButton.containsMouse ? Qt.alpha(Theme.text, 0.1) : Theme.transparent GlassIcon { anchors.centerIn: parent glyph: "󰍉" fallback: "⌕" size: 28 glyphSize: 16 color: Theme.transparent border.width: 0 glyphColor: root.searchActive ? Theme.textSecondary : Theme.text } MouseArea { id: searchButton objectName: "settingsSearchButton" anchors.fill: parent hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: root.searchActive ? searchField.forceActiveFocus() : root.openSearch() } } Rectangle { anchors.right: parent.right width: 36 height: 36 radius: 18 visible: searchMorph.progress > 0.5 opacity: searchMorph.progress color: closeSearchArea.containsMouse ? Qt.alpha(Theme.text, 0.1) : Theme.transparent Text { anchors.centerIn: parent text: "×" color: Theme.textSecondary font.pixelSize: 18 } MouseArea { id: closeSearchArea anchors.fill: parent hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: root.closeSearch() } } } } Item { Layout.fillWidth: true Layout.fillHeight: true // Navigation Flickable { id: nav anchors.fill: parent clip: true contentHeight: navColumn.implicitHeight boundsBehavior: Flickable.StopAtBounds opacity: root.searchActive ? 0 : 1 visible: opacity > 0.01 Behavior on opacity { NumberAnimation { duration: Theme.duration } } ScrollBar.vertical: ScrollBar { policy: ScrollBar.AsNeeded opacity: active ? 1 : 0 Behavior on opacity { NumberAnimation { duration: Theme.duration } } contentItem: Rectangle { implicitWidth: 3 radius: 2 color: Qt.alpha(Theme.text, 0.2) } } Rectangle { id: activeHighlight readonly property real target: root.entryY(ShellState.settingsPage) visible: target >= 0 width: nav.width height: root.itemHeight y: target radius: Math.max(10, Theme.radius * 0.55) color: Theme.accent Behavior on y { NumberAnimation { duration: Theme.duration * 1.3 easing.type: Easing.OutQuint } } } Column { id: navColumn width: nav.width spacing: root.itemSpacing Repeater { model: root.navEntries Item { id: entry required property var modelData readonly property bool isPage: modelData.kind === "page" readonly property bool selected: isPage && modelData.page.id === ShellState.settingsPage width: navColumn.width height: root.entryHeight(modelData) Text { visible: entry.modelData.kind === "caption" anchors.left: parent.left anchors.leftMargin: 8 anchors.bottom: parent.bottom anchors.bottomMargin: 6 text: String(entry.modelData.title || "").toUpperCase() color: Theme.textSecondary font.pixelSize: 10 font.weight: Font.DemiBold font.letterSpacing: 1.2 } Rectangle { visible: entry.isPage anchors.fill: parent radius: activeHighlight.radius color: !entry.selected && itemArea.containsMouse ? Qt.alpha(Theme.text, 0.07) : Theme.transparent scale: itemArea.pressed ? 0.98 : 1 Behavior on color { ColorAnimation { duration: Theme.duration / 2 } } Behavior on scale { NumberAnimation { duration: Theme.duration easing.type: Easing.OutQuint } } RowLayout { anchors.fill: parent // Selected items shift right as the highlight lands. anchors.leftMargin: 6 + (entry.selected ? 3 * Theme.intensity : 0) anchors.rightMargin: 10 spacing: 10 Behavior on anchors.leftMargin { NumberAnimation { duration: Theme.duration * 1.3 easing.type: Easing.OutQuint } } GlassIcon { glyph: entry.isPage ? entry.modelData.page.icon : "" image: entry.isPage ? entry.modelData.page.image || "" : "" fallback: entry.isPage ? entry.modelData.page.title.charAt(0) : "" size: 28 glyphSize: 15 color: entry.selected ? Qt.alpha(Theme.accentText, 0.14) : Theme.surfaceVariant glyphColor: entry.selected ? Theme.accentText : Theme.text } Text { text: entry.isPage ? entry.modelData.page.title : "" color: entry.selected ? Theme.accentText : itemArea.containsMouse ? Theme.text : Qt.alpha(Theme.text, 0.82) font.pixelSize: 13 font.weight: entry.selected ? Font.DemiBold : Font.Medium elide: Text.ElideRight Layout.fillWidth: true Behavior on color { ColorAnimation { duration: Theme.duration / 2 } } } } MouseArea { id: itemArea objectName: entry.isPage ? "settingsNav-" + entry.modelData.page.id : "" anchors.fill: parent hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: ShellState.openSettings(entry.modelData.page.id) } } } } } } // Search results ListView { id: results objectName: "settingsSearchResults" anchors.fill: parent clip: true spacing: 4 model: root.searchResults currentIndex: root.searchIndex opacity: root.searchActive ? 1 : 0 visible: opacity > 0.01 boundsBehavior: Flickable.StopAtBounds highlightFollowsCurrentItem: false onCurrentIndexChanged: positionViewAtIndex(currentIndex, ListView.Contain) Behavior on opacity { NumberAnimation { duration: Theme.duration } } delegate: Rectangle { id: result required property var modelData required property int index readonly property bool selected: index === root.searchIndex width: results.width height: 50 radius: Math.max(10, Theme.radius * 0.55) color: selected ? Theme.accent : resultArea.containsMouse ? Qt.alpha(Theme.text, 0.08) : Theme.fill Behavior on color { ColorAnimation { duration: Theme.duration / 2 } } RowLayout { anchors.fill: parent anchors.leftMargin: 8 + (result.selected ? 3 : 0) anchors.rightMargin: 10 spacing: 10 Behavior on anchors.leftMargin { NumberAnimation { duration: Theme.duration easing.type: Easing.OutQuint } } GlassIcon { glyph: result.modelData.icon image: result.modelData.image || "" fallback: result.modelData.detail.charAt(0) size: 28 glyphSize: 14 color: result.selected ? Qt.alpha(Theme.accentText, 0.14) : Theme.surfaceVariant glyphColor: result.selected ? Theme.accentText : Theme.text } ColumnLayout { Layout.fillWidth: true spacing: 1 Text { text: result.modelData.title color: result.selected ? Theme.accentText : Theme.text font.pixelSize: 12 font.weight: Font.DemiBold elide: Text.ElideRight Layout.fillWidth: true } Text { text: result.modelData.setting ? "in " + result.modelData.detail : result.modelData.detail color: result.selected ? Qt.alpha(Theme.accentText, 0.75) : Theme.textSecondary font.pixelSize: 10 elide: Text.ElideRight Layout.fillWidth: true } } } MouseArea { id: resultArea anchors.fill: parent hoverEnabled: true cursorShape: Qt.PointingHandCursor onEntered: root.searchIndex = result.index onClicked: root.chooseResult(result.modelData) } } Text { anchors.centerIn: parent visible: root.searchActive && results.count === 0 width: parent.width - 20 horizontalAlignment: Text.AlignHCenter wrapMode: Text.Wrap text: searchField.text.trim() ? "No settings match “" + searchField.text.trim() + "”" : "Type to search pages and settings" color: Theme.textSecondary font.pixelSize: 12 } } } Text { Layout.fillWidth: true Layout.leftMargin: 6 text: root.searchActive ? "↑↓ select · Enter open · Esc back" : "Ctrl+F search · Ctrl+Tab next page" color: Qt.alpha(Theme.textSecondary, 0.8) font.pixelSize: 10 elide: Text.ElideRight } } }