Speed up widget updates: tray background pill + instant volume changes
Tray icons now sit in a background pill matching the other stat pills. Volume no longer waits on a 3s poll - a pactl subscribe watcher triggers an immediate refresh on change, with a slower poll left as a fallback. Stats refresh interval reduced 2s -> 1s. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Dujsk9jYfxUVLtb5B8eC94
This commit is contained in:
@@ -166,7 +166,7 @@ Variants {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Timer { interval: 100; running: true; repeat: false; onTriggered: statsProc.running = true }
|
Timer { interval: 100; running: true; repeat: false; onTriggered: statsProc.running = true }
|
||||||
Timer { interval: 2000; running: true; repeat: true; onTriggered: statsProc.running = true }
|
Timer { interval: 1000; running: true; repeat: true; onTriggered: statsProc.running = true }
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: netProc
|
id: netProc
|
||||||
@@ -206,7 +206,18 @@ Variants {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Timer { interval: 500; running: true; repeat: false; onTriggered: volumeProc.running = true }
|
Timer { interval: 500; running: true; repeat: false; onTriggered: volumeProc.running = true }
|
||||||
Timer { interval: 3000; running: true; repeat: true; onTriggered: volumeProc.running = true }
|
Timer { interval: 5000; running: true; repeat: true; onTriggered: volumeProc.running = true }
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: volumeWatchProc
|
||||||
|
command: ["pactl", "subscribe"]
|
||||||
|
running: true
|
||||||
|
stdout: SplitParser {
|
||||||
|
onRead: data => {
|
||||||
|
if (data.indexOf("sink") !== -1) volumeProc.running = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Process { id: pavucontrolProc; command: ["pavucontrol"] }
|
Process { id: pavucontrolProc; command: ["pavucontrol"] }
|
||||||
Process { id: volUpProc; command: ["wpctl", "set-volume", "@DEFAULT_AUDIO_SINK@", "5%+"] }
|
Process { id: volUpProc; command: ["wpctl", "set-volume", "@DEFAULT_AUDIO_SINK@", "5%+"] }
|
||||||
@@ -353,37 +364,46 @@ Variants {
|
|||||||
anchors { right: parent.right; rightMargin: 8; verticalCenter: parent.verticalCenter }
|
anchors { right: parent.right; rightMargin: 8; verticalCenter: parent.verticalCenter }
|
||||||
spacing: 10
|
spacing: 10
|
||||||
|
|
||||||
RowLayout {
|
Rectangle {
|
||||||
id: trayRow
|
id: trayPill
|
||||||
spacing: 8
|
|
||||||
visible: count > 0
|
|
||||||
readonly property int count: SystemTray.items.values.length
|
readonly property int count: SystemTray.items.values.length
|
||||||
|
visible: count > 0
|
||||||
|
Layout.preferredWidth: count > 0 ? trayRow.implicitWidth + 16 : 0
|
||||||
|
Layout.preferredHeight: 26
|
||||||
|
radius: 10
|
||||||
|
color: Qt.rgba(0.102, 0.106, 0.149, 0.85)
|
||||||
|
|
||||||
Repeater {
|
RowLayout {
|
||||||
model: SystemTray.items
|
id: trayRow
|
||||||
|
anchors.centerIn: parent
|
||||||
|
spacing: 8
|
||||||
|
|
||||||
Item {
|
Repeater {
|
||||||
required property var modelData
|
model: SystemTray.items
|
||||||
Layout.preferredWidth: 18
|
|
||||||
Layout.preferredHeight: 18
|
|
||||||
|
|
||||||
Image {
|
Item {
|
||||||
anchors.fill: parent
|
required property var modelData
|
||||||
source: modelData.icon
|
Layout.preferredWidth: 18
|
||||||
sourceSize: Qt.size(18, 18)
|
Layout.preferredHeight: 18
|
||||||
smooth: true
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
Image {
|
||||||
id: trayItemArea
|
anchors.fill: parent
|
||||||
anchors.fill: parent
|
source: modelData.icon
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
sourceSize: Qt.size(18, 18)
|
||||||
onClicked: mouse => {
|
smooth: true
|
||||||
if (mouse.button === Qt.RightButton && modelData.hasMenu) {
|
}
|
||||||
var pos = trayItemArea.mapToItem(bar.contentItem, mouse.x, mouse.y)
|
|
||||||
modelData.display(bar, pos.x, pos.y)
|
MouseArea {
|
||||||
} else {
|
id: trayItemArea
|
||||||
modelData.activate()
|
anchors.fill: parent
|
||||||
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
|
onClicked: mouse => {
|
||||||
|
if (mouse.button === Qt.RightButton && modelData.hasMenu) {
|
||||||
|
var pos = trayItemArea.mapToItem(bar.contentItem, mouse.x, mouse.y)
|
||||||
|
modelData.display(bar, pos.x, pos.y)
|
||||||
|
} else {
|
||||||
|
modelData.activate()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user