aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/island/StatusPill.qml
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/island/StatusPill.qml')
-rw-r--r--desktop/island/StatusPill.qml41
1 files changed, 38 insertions, 3 deletions
diff --git a/desktop/island/StatusPill.qml b/desktop/island/StatusPill.qml
index 2202747..915807b 100644
--- a/desktop/island/StatusPill.qml
+++ b/desktop/island/StatusPill.qml
@@ -12,11 +12,13 @@
import Quickshell
import Quickshell.Widgets
import Quickshell.Services.SystemTray
+import Quickshell.Bluetooth
import QtQuick
import ".."
import "Logic.js" as Logic
-// Volume icon, tray, layout flag. The volume icon opens its panel in this
+// Headphones icon (while Sony headphones are connected), volume icon, tray,
+// layout flag. The headphones and volume icons open their panels in this
// capsule; the tray is a plain tray; the flag switches layout on scroll and
// ignores clicks.
Capsule {
@@ -27,15 +29,22 @@ Capsule {
required property QtObject window
property string panel: ""
+ // ponytail: Sony headphones are recognised by their model prefix; sonyctl
+ // speaks only the v2 protocol, measured on a WH-CH720N.
+ readonly property var phones: (Bluetooth.devices?.values ?? [])
+ .find(d => d.connected && /^(WH|WF)-|^LinkBuds/.test(d.deviceName)) ?? null
+
signal openSound()
+ signal openHeadphones()
+ signal closePanel()
signal openDrawer()
// Emitted just before a tray menu opens; the menu cannot report its close.
signal menuShown()
- expanded: panel === "sound"
+ expanded: panel === "sound" || panel === "headphones"
restWidth: restRow.implicitWidth + 24
panelWidth: 320
- panelHeight: soundPanel.implicitHeight + 28
+ panelHeight: (panel === "headphones" ? phonesPanel.implicitHeight : soundPanel.implicitHeight) + 28
Row {
@@ -47,6 +56,19 @@ Capsule {
Behavior on opacity { NumberAnimation { duration: 120 } }
IconImage {
+ visible: pill.phones !== null
+ anchors.verticalCenter: parent.verticalCenter
+ implicitSize: 18
+ source: Quickshell.iconPath("audio-headphones", true)
+
+ MouseArea {
+ anchors.fill: parent
+ cursorShape: Qt.PointingHandCursor
+ onClicked: pill.openHeadphones()
+ }
+ }
+
+ IconImage {
anchors.verticalCenter: parent.verticalCenter
implicitSize: 18
source: Quickshell.iconPath(Logic.volumeIcon(pill.sound.volume, pill.sound.muted), true)
@@ -122,4 +144,17 @@ Capsule {
Behavior on opacity { NumberAnimation { duration: 160 } }
onOpenDrawer: pill.openDrawer()
}
+
+ HeadphonesPanel {
+ id: phonesPanel
+ x: 14
+ y: 14
+ width: pill.panelWidth - 28
+ device: pill.phones
+ open: pill.panel === "headphones"
+ onClose: pill.closePanel()
+ opacity: open ? 1 : 0
+ visible: opacity > 0
+ Behavior on opacity { NumberAnimation { duration: 160 } }
+ }
}