Show row close button on every known bluetooth device
Was gated on isConnected; users with paired-but-disconnected devices (or devices Quickshell hasn't flagged as connected yet) saw no button at all. Now shows on every known device. Action follows state: connected -> disconnect, otherwise -> forget. Tooltip label flips to match.
This commit is contained in:
@@ -284,8 +284,8 @@ Item {
|
|||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
// Explicit disconnect/close button on connected rows. Stops the row's
|
// Explicit close button on any known device. Action depends on state:
|
||||||
// own click handler from firing.
|
// connected -> disconnect, otherwise -> forget the pairing entirely.
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: disconnectBtn
|
id: disconnectBtn
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
@@ -293,7 +293,8 @@ Item {
|
|||||||
width: 22
|
width: 22
|
||||||
height: 22
|
height: 22
|
||||||
radius: 4
|
radius: 4
|
||||||
visible: row.isConnected
|
visible: !row.isDiscovered
|
||||||
|
readonly property string action: row.isConnected ? "Disconnect" : "Forget"
|
||||||
color: disconnectMouse.containsMouse
|
color: disconnectMouse.containsMouse
|
||||||
? Qt.rgba(root.bar.urgent.r, root.bar.urgent.g, root.bar.urgent.b, 0.20)
|
? Qt.rgba(root.bar.urgent.r, root.bar.urgent.g, root.bar.urgent.b, 0.20)
|
||||||
: "transparent"
|
: "transparent"
|
||||||
@@ -317,15 +318,19 @@ Item {
|
|||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (!row.dev) return
|
if (!row.dev) return
|
||||||
row.pendingAction = 2
|
if (row.isConnected) {
|
||||||
failureTimer.stop()
|
row.pendingAction = 2
|
||||||
row.dev.disconnect()
|
failureTimer.stop()
|
||||||
|
row.dev.disconnect()
|
||||||
|
} else if (row.dev.forget) {
|
||||||
|
row.dev.forget()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolTip {
|
ToolTip {
|
||||||
visible: disconnectMouse.containsMouse
|
visible: disconnectMouse.containsMouse
|
||||||
text: "Disconnect"
|
text: disconnectBtn.action
|
||||||
delay: 400
|
delay: 400
|
||||||
padding: 0
|
padding: 0
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
@@ -336,7 +341,7 @@ Item {
|
|||||||
opacity: 0.97
|
opacity: 0.97
|
||||||
}
|
}
|
||||||
contentItem: Text {
|
contentItem: Text {
|
||||||
text: "Disconnect"
|
text: disconnectBtn.action
|
||||||
color: root.bar.foreground
|
color: root.bar.foreground
|
||||||
font.family: root.bar.fontFamily
|
font.family: root.bar.fontFamily
|
||||||
font.pixelSize: 11
|
font.pixelSize: 11
|
||||||
@@ -353,8 +358,8 @@ Item {
|
|||||||
spacing: 1
|
spacing: 1
|
||||||
anchors.left: icon.right
|
anchors.left: icon.right
|
||||||
anchors.leftMargin: 10
|
anchors.leftMargin: 10
|
||||||
anchors.right: row.isConnected ? disconnectBtn.left : parent.right
|
anchors.right: disconnectBtn.visible ? disconnectBtn.left : parent.right
|
||||||
anchors.rightMargin: row.isConnected ? 8 : 0
|
anchors.rightMargin: disconnectBtn.visible ? 8 : 0
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
|
|||||||
Reference in New Issue
Block a user