Share demand counting and jump easing; split Settings sidebar

Add services/Demand.qml, which holds one count on a service's demand
counter while active. It replaces 13 hand-written consumer counters
across the bar, Control Center, dashboard, media and desktop widgets.
The desktop Cava widget now releases Cava while its desktop is covered.

Add components/JumpValue.qml for the "animate only visible jumps" rule
shared by the dashboard gauge and resource bars.

Move the Settings sidebar (search and navigation) into
settings/SettingsSidebar.qml and the drag handle into
settings/controls/SettingsDragArea.qml, halving Settings.qml.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mxandClaude Opus 5.5 committed 2026-10-07 22:42:56 +02:00
1 parent 99e64a7713
commit bf0ef09cec
18 files changed
+595 -570

No files matched your search

+4 -2
View File
@@ -35,8 +35,10 @@ GlassPill {
duration: Theme.duration duration: Theme.duration
} }
} }
Component.onCompleted: CavaService.widgetConsumers++ Demand {
Component.onDestruction: CavaService.widgetConsumers-- service: CavaService
counter: "widgetConsumers"
}
// Cava emits 24 bands; each pill bar averages its share of them. // Cava emits 24 bands; each pill bar averages its share of them.
function level(index) { function level(index) {
const all = CavaService.bars, n = options.bars, from = Math.floor(index * all.length / n), to = Math.max(from + 1, Math.floor((index + 1) * all.length / n)); const all = CavaService.bars, n = options.bars, from = Math.floor(index * all.length / n), to = Math.max(from + 1, Math.floor((index + 1) * all.length / n));
+3 -2
View File
@@ -6,8 +6,9 @@ import "../../core"
GlassButton { GlassButton {
property string metric: "cpu" property string metric: "cpu"
implicitHeight: ModuleRegistry.pillHeight implicitHeight: ModuleRegistry.pillHeight
Component.onCompleted: MetricsService.consumers++ Demand {
Component.onDestruction: MetricsService.consumers-- service: MetricsService
}
text: { text: {
switch (metric) { switch (metric) {
case "cpu": case "cpu":
+26
View File
@@ -0,0 +1,26 @@
import QtQuick
import "../theme"
// Follows `target`, easing only visible jumps (at least `threshold`); smaller
// changes snap. Easing every small sample change kept windows rendering at the
// display's refresh rate.
QtObject {
id: root
property real target
property real threshold: 2
property int duration: Theme.duration * 2
property real value
property bool animate: false
onTargetChanged: {
animate = Math.abs(target - value) >= threshold;
value = target;
}
Component.onCompleted: value = target
Behavior on value {
enabled: root.animate
NumberAnimation {
duration: root.duration
easing.type: Easing.OutCubic
}
}
}
@@ -9,8 +9,9 @@ import "../../theme"
// Wi-Fi, Bluetooth and live throughput; labels open the matching Settings page. // Wi-Fi, Bluetooth and live throughput; labels open the matching Settings page.
ControlCard { ControlCard {
id: root id: root
Component.onCompleted: MetricsService.consumers++ Demand {
Component.onDestruction: MetricsService.consumers-- service: MetricsService
}
component Entry: RowLayout { component Entry: RowLayout {
id: entry id: entry
property alias toggle: toggle property alias toggle: toggle
+5 -16
View File
@@ -1,4 +1,5 @@
import QtQuick import QtQuick
import "../components"
import "../theme" import "../theme"
// Ring gauge (0–100) with a centred label; null values draw an empty ring. // Ring gauge (0–100) with a centred label; null values draw an empty ring.
@@ -12,23 +13,11 @@ Item {
property string caption: "" property string caption: ""
implicitWidth: size implicitWidth: size
implicitHeight: size implicitHeight: size
readonly property real target: Number.isFinite(value) ? Math.max(0, Math.min(100, value)) : 0 JumpValue {
// Only visible jumps animate: easing every small sample change kept the id: level
// window rendering at the display's refresh rate. target: Number.isFinite(root.value) ? Math.max(0, Math.min(100, root.value)) : 0
property real shown
property bool easeJump: false
Component.onCompleted: shown = target
onTargetChanged: {
easeJump = Math.abs(target - shown) >= 2;
shown = target;
}
Behavior on shown {
enabled: root.easeJump
NumberAnimation {
duration: Theme.duration * 2
easing.type: Easing.OutCubic
}
} }
readonly property real shown: level.value
onShownChanged: canvas.requestPaint() onShownChanged: canvas.requestPaint()
onColorChanged: canvas.requestPaint() onColorChanged: canvas.requestPaint()
Canvas { Canvas {
+12 -14
View File
@@ -18,21 +18,19 @@ Item {
readonly property var player: MediaService.player readonly property var player: MediaService.player
// Streams report no length or absurd ones; show them as live. // Streams report no length or absurd ones; show them as live.
readonly property bool live: MediaService.length <= 0 || MediaService.length > 7 * 86400 readonly property bool live: MediaService.length <= 0 || MediaService.length > 7 * 86400
property bool subscribed: false onCurrentChanged: if (current)
onCurrentChanged: sync() EasyEffectsService.refresh()
Component.onCompleted: sync() Component.onCompleted: if (current)
Component.onDestruction: if (subscribed) { EasyEffectsService.refresh()
MediaService.progressConsumers--; Demand {
CavaService.widgetConsumers--; service: MediaService
counter: "progressConsumers"
active: root.current
} }
function sync() { Demand {
if (current === subscribed) service: CavaService
return; counter: "widgetConsumers"
MediaService.progressConsumers += current ? 1 : -1; active: root.current
CavaService.widgetConsumers += current ? 1 : -1;
subscribed = current;
if (current)
EasyEffectsService.refresh();
} }
RowLayout { RowLayout {
+13 -29
View File
@@ -5,6 +5,7 @@ import Quickshell
import Quickshell.Widgets import Quickshell.Widgets
import ".." import ".."
import "../../widgets/faces" as Faces import "../../widgets/faces" as Faces
import "../../components"
import "../../services" import "../../services"
import "../../theme" import "../../theme"
@@ -16,19 +17,14 @@ Item {
implicitHeight: row.implicitHeight implicitHeight: row.implicitHeight
// Collectors only run while this tab is on screen. // Collectors only run while this tab is on screen.
readonly property bool live: current readonly property bool live: current
property bool subscribed: false Demand {
onLiveChanged: sync() service: MetricsService
Component.onCompleted: sync() active: root.live
Component.onDestruction: if (subscribed) {
MetricsService.consumers--;
MediaService.progressConsumers--;
} }
function sync() { Demand {
if (live === subscribed) service: MediaService
return; counter: "progressConsumers"
MetricsService.consumers += live ? 1 : -1; active: root.live
MediaService.progressConsumers += live ? 1 : -1;
subscribed = live;
} }
readonly property var disk: (MetricsService.snapshot.storage || []).find(s => s.available) || ({}) readonly property var disk: (MetricsService.snapshot.storage || []).find(s => s.available) || ({})
@@ -215,14 +211,9 @@ Item {
property string fallback property string fallback
property string label property string label
spacing: 8 spacing: 8
readonly property real target: Number.isFinite(value) ? Math.max(0, Math.min(100, value)) : 0 JumpValue {
// Only visible jumps animate (see Gauge). id: level
property real shown target: Number.isFinite(bar.value) ? Math.max(0, Math.min(100, bar.value)) : 0
property bool easeJump: false
Component.onCompleted: shown = target
onTargetChanged: {
easeJump = Math.abs(target - shown) >= 2;
shown = target;
} }
Text { Text {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
@@ -242,16 +233,9 @@ Item {
Rectangle { Rectangle {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
width: parent.width width: parent.width
height: Math.max(parent.width, parent.height * bar.shown / 100) height: Math.max(parent.width, parent.height * level.value / 100)
radius: 5 radius: 5
color: bar.shown > 85 ? Theme.urgent : Theme.accentVivid color: level.target > 85 ? Theme.urgent : Theme.accentVivid
Behavior on height {
enabled: bar.easeJump
NumberAnimation {
duration: Theme.duration * 2
easing.type: Easing.OutCubic
}
}
} }
} }
Text { Text {
+3 -10
View File
@@ -11,16 +11,9 @@ Item {
property bool current: false property bool current: false
implicitWidth: grid.implicitWidth implicitWidth: grid.implicitWidth
implicitHeight: grid.implicitHeight implicitHeight: grid.implicitHeight
property bool subscribed: false Demand {
onCurrentChanged: sync() service: MetricsService
Component.onCompleted: sync() active: root.current
Component.onDestruction: if (subscribed)
MetricsService.consumers--
function sync() {
if (current === subscribed)
return;
MetricsService.consumers += current ? 1 : -1;
subscribed = current;
} }
readonly property var gpu: MetricsService.gpu readonly property var gpu: MetricsService.gpu
readonly property bool hasGpu: gpu.percent !== undefined && gpu.percent !== null readonly property bool hasGpu: gpu.percent !== undefined && gpu.percent !== null
+3 -17
View File
@@ -6,24 +6,10 @@ import "../theme"
Item { Item {
id: root id: root
implicitHeight: 28 implicitHeight: 28
property bool mounted: false Demand {
property bool subscribed: false service: CavaService
function sync() { active: root.visible
const next = mounted && visible;
if (next !== subscribed) {
CavaService.consumers += next ? 1 : -1;
subscribed = next;
}
} }
Component.onCompleted: {
mounted = true;
sync();
}
Component.onDestruction: {
if (subscribed)
CavaService.consumers--;
}
onVisibleChanged: sync()
Row { Row {
anchors.fill: parent anchors.fill: parent
spacing: 3 spacing: 3
+4 -18
View File
@@ -9,28 +9,14 @@ GlassPanel {
id: root id: root
objectName: "mediaCard" objectName: "mediaCard"
property bool compact: false property bool compact: false
property bool mounted: false
property bool subscribed: false
readonly property bool showProgress: ConfigService.ready && ConfigService.data.media.showProgress readonly property bool showProgress: ConfigService.ready && ConfigService.data.media.showProgress
implicitWidth: compact ? 340 : 480 implicitWidth: compact ? 340 : 480
implicitHeight: body.implicitHeight + 36 implicitHeight: body.implicitHeight + 36
function sync() { Demand {
const next = mounted && visible && showProgress; service: MediaService
if (next !== subscribed) { counter: "progressConsumers"
MediaService.progressConsumers += next ? 1 : -1; active: root.visible && root.showProgress
subscribed = next;
}
} }
Component.onCompleted: {
mounted = true;
sync();
}
Component.onDestruction: {
if (subscribed)
MediaService.progressConsumers--;
}
onVisibleChanged: sync()
onShowProgressChanged: sync()
Connections { Connections {
target: MediaService target: MediaService
function onTitleChanged() { function onTitleChanged() {
+3 -2
View File
@@ -12,8 +12,9 @@ GlassPanel {
property bool compact: false property bool compact: false
implicitWidth: 390 implicitWidth: 390
implicitHeight: body.implicitHeight + 32 implicitHeight: body.implicitHeight + 32
Component.onCompleted: MetricsService.consumers++ Demand {
Component.onDestruction: MetricsService.consumers-- service: MetricsService
}
ColumnLayout { ColumnLayout {
id: body id: body
anchors { anchors {
+23
View File
@@ -0,0 +1,23 @@
import QtQuick
// Holds one count on a service's demand counter while `active`, released when
// inactive or destroyed. Services run their samplers and processes only while
// counted, so idle views cost nothing.
QtObject {
id: root
required property var service
property string counter: "consumers"
property bool active: true
property bool held: false
function sync() {
const next = active && !!service;
if (next === held)
return;
service[counter] += next ? 1 : -1;
held = next;
}
onActiveChanged: sync()
Component.onCompleted: sync()
Component.onDestruction: if (held)
service[counter]--
}
+1
View File
@@ -3,6 +3,7 @@ singleton TrayService 1.0 TrayService.qml
singleton ApplicationsService 1.0 ApplicationsService.qml singleton ApplicationsService 1.0 ApplicationsService.qml
singleton HyprlandService 1.0 HyprlandService.qml singleton HyprlandService 1.0 HyprlandService.qml
ProviderJob 1.0 ProviderJob.qml ProviderJob 1.0 ProviderJob.qml
Demand 1.0 Demand.qml
singleton WallpaperService 1.0 WallpaperService.qml singleton WallpaperService 1.0 WallpaperService.qml
singleton MediaService 1.0 MediaService.qml singleton MediaService 1.0 MediaService.qml
singleton CavaService 1.0 CavaService.qml singleton CavaService 1.0 CavaService.qml
+17 -446
View File
@@ -87,40 +87,14 @@ PanelWindow {
readonly property var currentPage: SettingsRegistry.page(ShellState.settingsPage) || SettingsRegistry.page("about") readonly property var currentPage: SettingsRegistry.page(ShellState.settingsPage) || SettingsRegistry.page("about")
readonly property var currentGroup: SettingsRegistry.groups.find(g => g.id === currentPage.group) || null readonly property var currentGroup: SettingsRegistry.groups.find(g => g.id === currentPage.group) || null
// Sidebar entries: group captions followed by their pages. // Search lives in the sidebar; these forward to it for shortcuts and tests.
readonly property int captionHeight: 30 readonly property bool searchActive: sidebar.searchActive
readonly property int gapHeight: 12 readonly property var searchResults: sidebar.searchResults
readonly property int itemHeight: 40 function openSearch() {
readonly property int itemSpacing: 2 sidebar.openSearch();
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) { function chooseResult(result) {
return entry.kind === "page" ? itemHeight : entry.kind === "caption" ? captionHeight : gapHeight; sidebar.chooseResult(result);
}
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;
} }
function step(direction) { function step(direction) {
const ids = SettingsRegistry.pages.map(p => p.id); const ids = SettingsRegistry.pages.map(p => p.id);
@@ -128,43 +102,13 @@ PanelWindow {
ShellState.openSettings(ids[(index + direction + ids.length) % ids.length]); ShellState.openSettings(ids[(index + direction + ids.length) % ids.length]);
} }
// 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();
panel.forceActiveFocus();
}
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);
}
Connections { Connections {
target: ShellState target: ShellState
function onSettingsOpenChanged() { function onSettingsOpenChanged() {
if (!ShellState.settingsOpen && root.searchActive) if (!ShellState.settingsOpen && root.searchActive)
root.closeSearch(); sidebar.closeSearch();
if (ShellState.settingsOpen) if (ShellState.settingsOpen)
Qt.callLater(root.revealNavEntry); Qt.callLater(sidebar.revealNavEntry);
} }
} }
Timer { Timer {
@@ -174,18 +118,6 @@ PanelWindow {
onTriggered: ShellState.settingsHighlight = "" onTriggered: ShellState.settingsHighlight = ""
} }
// Drag handle for moving the panel; double-click recentres it.
component DragArea: MouseArea {
id: handle
anchors.fill: parent
cursorShape: pressed ? Qt.ClosedHandCursor : Qt.OpenHandCursor
onPressed: mouse => root.beginDrag(handle, mouse.x, mouse.y)
onPositionChanged: mouse => root.moveDrag(handle, mouse.x, mouse.y)
onReleased: root.endDrag()
onCanceled: root.endDrag()
onDoubleClicked: root.recenter()
}
// Hyprland routes every pointer event to a layer with exclusive keyboard // Hyprland routes every pointer event to a layer with exclusive keyboard
// focus, so clicks outside the panel arrive here with out-of-bounds // focus, so clicks outside the panel arrive here with out-of-bounds
// coordinates. Qt Quick still delivers them to items extending past the // coordinates. Qt Quick still delivers them to items extending past the
@@ -231,377 +163,14 @@ PanelWindow {
anchors.fill: parent anchors.fill: parent
spacing: 0 spacing: 0
// Sidebar SettingsSidebar {
Rectangle {
id: sidebar id: sidebar
window: root
cornerRadius: panel.radius
visible: root.wide visible: root.wide
Layout.fillHeight: true Layout.fillHeight: true
Layout.preferredWidth: 252 Layout.preferredWidth: 252
topLeftRadius: panel.radius onSearchClosed: panel.forceActiveFocus()
bottomLeftRadius: panel.radius
color: Qt.alpha(Theme.tint, 0.15)
ColumnLayout {
anchors.fill: parent
anchors.margins: 14
spacing: 12
Item {
Layout.fillWidth: true
Layout.preferredHeight: 36
DragArea {
objectName: "settingsDragHandle"
}
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
}
}
} }
Rectangle { Rectangle {
visible: root.wide visible: root.wide
@@ -621,7 +190,9 @@ PanelWindow {
Item { Item {
Layout.fillWidth: true Layout.fillWidth: true
implicitHeight: pageHeader.implicitHeight implicitHeight: pageHeader.implicitHeight
DragArea {} SettingsDragArea {
window: root
}
RowLayout { RowLayout {
id: pageHeader id: pageHeader
anchors.fill: parent anchors.fill: parent
@@ -698,7 +269,7 @@ PanelWindow {
target: ShellState target: ShellState
function onSettingsPageChanged() { function onSettingsPageChanged() {
enterAnimation.restart(); enterAnimation.restart();
Qt.callLater(root.revealNavEntry); Qt.callLater(sidebar.revealNavEntry);
} }
} }
Loader { Loader {
+452
View File
@@ -0,0 +1,452 @@
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
}
}
}
@@ -0,0 +1,14 @@
import QtQuick
// Drag handle for moving the Settings panel; double-click recentres it.
MouseArea {
id: handle
required property var window
anchors.fill: parent
cursorShape: pressed ? Qt.ClosedHandCursor : Qt.OpenHandCursor
onPressed: mouse => window.beginDrag(handle, mouse.x, mouse.y)
onPositionChanged: mouse => window.moveDrag(handle, mouse.x, mouse.y)
onReleased: window.endDrag()
onCanceled: window.endDrag()
onDoubleClicked: window.recenter()
}
+3 -10
View File
@@ -12,17 +12,10 @@ Item {
property bool desktopVisible: true property bool desktopVisible: true
// Faces showing live metrics keep the shared collector running only while shown. // Faces showing live metrics keep the shared collector running only while shown.
property bool usesMetrics: false property bool usesMetrics: false
readonly property bool sampling: usesMetrics && desktopVisible Demand {
property bool counted: false service: MetricsService
function count(next) { active: face.usesMetrics && face.desktopVisible
if (next !== counted) {
MetricsService.consumers += next ? 1 : -1;
counted = next;
}
} }
onSamplingChanged: count(sampling)
Component.onCompleted: count(sampling)
Component.onDestruction: count(false)
// Reference size for typography that scales with the widget. // Reference size for typography that scales with the widget.
readonly property real unit: Math.min(width, height * 2) readonly property real unit: Math.min(width, height * 2)
} }
+6 -2
View File
@@ -6,8 +6,12 @@ import "../../theme"
// Cava bars for system audio: rising bars, or mirrored around the centre line. // Cava bars for system audio: rising bars, or mirrored around the centre line.
Face { Face {
id: root id: root
Component.onCompleted: CavaService.widgetConsumers++ // Cava runs only while this widget's desktop is visible.
Component.onDestruction: CavaService.widgetConsumers-- Demand {
service: CavaService
counter: "widgetConsumers"
active: root.desktopVisible
}
readonly property bool mirror: variant === "mirror" readonly property bool mirror: variant === "mirror"
Row { Row {
id: bars id: bars