Drop row tooltip; add explicit disconnect button on connected devices

Bluetooth rows no longer hover-show a tooltip — clicking to connect
or pair is self-evident from the layout. Connected rows now ignore
their own click and surface a small × button on the right that
disconnects (with its own tooltip + urgent-color hover affordance).
Right-click still forgets the device.
This commit is contained in:
Ryan Hughes
2026-05-14 02:21:48 -04:00
parent 84e8a42813
commit 6c84bc93da
@@ -265,17 +265,69 @@ Item {
Behavior on color { ColorAnimation { duration: 120 } } Behavior on color { ColorAnimation { duration: 120 } }
readonly property string tooltipBody: Item {
isDiscovered ? "Click to pair and connect" id: rowContent
: isConnected ? "Click to disconnect · right-click to forget" anchors.left: parent.left
: "Click to connect · right-click to forget" anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: 10
anchors.rightMargin: 10
implicitHeight: Math.max(icon.implicitHeight, info.implicitHeight, disconnectBtn.implicitHeight)
Text {
id: icon
text: row.isConnected ? "󰂱" : "󰂯"
color: row.statusColor
font.family: root.bar.fontFamily
font.pixelSize: 16
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
}
// Explicit disconnect/close button on connected rows. Stops the row's
// own click handler from firing.
Rectangle {
id: disconnectBtn
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
width: 22
height: 22
radius: 4
visible: row.isConnected
color: disconnectMouse.containsMouse
? Qt.rgba(root.bar.urgent.r, root.bar.urgent.g, root.bar.urgent.b, 0.20)
: "transparent"
Behavior on color { ColorAnimation { duration: 120 } }
Text {
anchors.centerIn: parent
text: "󰅙"
color: disconnectMouse.containsMouse ? root.bar.urgent : Qt.darker(root.bar.foreground, 1.3)
font.family: root.bar.fontFamily
font.pixelSize: 14
}
MouseArea {
id: disconnectMouse
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
acceptedButtons: Qt.LeftButton
onClicked: {
if (!row.dev) return
row.pendingAction = 2
failureTimer.stop()
row.dev.disconnect()
}
}
ToolTip { ToolTip {
visible: rowMouse.containsMouse && row.tooltipBody !== "" visible: disconnectMouse.containsMouse
text: row.tooltipBody text: "Disconnect"
delay: 400 delay: 400
padding: 0 padding: 0
background: Rectangle { background: Rectangle {
color: root.bar.background color: root.bar.background
border.color: root.bar.foreground border.color: root.bar.foreground
@@ -283,9 +335,8 @@ Item {
radius: 0 radius: 0
opacity: 0.97 opacity: 0.97
} }
contentItem: Text { contentItem: Text {
text: row.tooltipBody text: "Disconnect"
color: root.bar.foreground color: root.bar.foreground
font.family: root.bar.fontFamily font.family: root.bar.fontFamily
font.pixelSize: 11 font.pixelSize: 11
@@ -295,28 +346,16 @@ Item {
bottomPadding: 6 bottomPadding: 6
} }
} }
Row {
id: rowContent
anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: 10
anchors.rightMargin: 10
spacing: 10
Text {
text: row.isConnected ? "󰂱" : "󰂯"
color: row.statusColor
font.family: root.bar.fontFamily
font.pixelSize: 16
anchors.verticalCenter: parent.verticalCenter
} }
Column { Column {
id: info
spacing: 1 spacing: 1
anchors.left: icon.right
anchors.leftMargin: 10
anchors.right: row.isConnected ? disconnectBtn.left : parent.right
anchors.rightMargin: row.isConnected ? 8 : 0
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: parent.width - parent.children[0].width - parent.spacing
Text { Text {
text: row.dev ? (row.dev.deviceName || row.dev.name || row.dev.address || "Device") : "" text: row.dev ? (row.dev.deviceName || row.dev.name || row.dev.address || "Device") : ""
@@ -358,11 +397,7 @@ Item {
row.dev.pair() row.dev.pair()
return return
} }
if (row.isConnected) { if (row.isConnected) return // use the X button to disconnect
row.pendingAction = 2
failureTimer.stop()
row.dev.disconnect()
} else {
row.pendingAction = 1 row.pendingAction = 1
row.failureReason = "" row.failureReason = ""
failureTimer.restart() failureTimer.restart()
@@ -370,5 +405,4 @@ Item {
} }
} }
} }
}
} }