bluetooth: switch to hover panel, matching network behavior
This commit is contained in:
parent
2027fc92b4
commit
6d3ec188e8
2 changed files with 12 additions and 35 deletions
|
|
@ -63,14 +63,6 @@ M.BarSection {
|
|||
onTriggered: proc.running = true
|
||||
}
|
||||
|
||||
Process {
|
||||
id: toggle
|
||||
property string cmd: ""
|
||||
command: ["bluetoothctl", "power", cmd]
|
||||
onRunningChanged: if (!running && cmd !== "")
|
||||
proc.running = true
|
||||
}
|
||||
|
||||
M.BarIcon {
|
||||
icon: "\uF294"
|
||||
color: root.state === "off" ? M.Theme.base04 : root.accentColor
|
||||
|
|
@ -84,31 +76,13 @@ M.BarSection {
|
|||
|
||||
required property var bar
|
||||
|
||||
TapHandler {
|
||||
acceptedButtons: Qt.LeftButton
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onTapped: {
|
||||
menuLoader.active = !menuLoader.active;
|
||||
M.FlyoutState.visible = false;
|
||||
}
|
||||
}
|
||||
readonly property bool _anyHover: root._hovered || bluetoothMenu.panelHovered
|
||||
|
||||
TapHandler {
|
||||
acceptedButtons: Qt.RightButton
|
||||
onTapped: {
|
||||
toggle.cmd = root.state === "off" ? "on" : "off";
|
||||
toggle.running = true;
|
||||
}
|
||||
}
|
||||
|
||||
LazyLoader {
|
||||
id: menuLoader
|
||||
active: false
|
||||
M.BluetoothMenu {
|
||||
accentColor: root.accentColor
|
||||
id: bluetoothMenu
|
||||
showPanel: root._anyHover
|
||||
screen: root.bar.screen
|
||||
anchorX: root.mapToGlobal(root.width / 2, 0).x - (QsWindow.window?.screen?.x ?? 0)
|
||||
onDismissed: menuLoader.active = false
|
||||
}
|
||||
anchorItem: root
|
||||
accentColor: root.accentColor
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,15 +6,18 @@ import "." as M
|
|||
M.HoverPanel {
|
||||
id: menuWindow
|
||||
|
||||
popupMode: true
|
||||
contentWidth: 250
|
||||
panelNamespace: "nova-bluetooth"
|
||||
|
||||
onVisibleChanged: if (visible)
|
||||
scanner.running = true
|
||||
|
||||
property var _devices: []
|
||||
property bool _btEnabled: true
|
||||
|
||||
property Process _scanner: Process {
|
||||
id: scanner
|
||||
running: true
|
||||
running: false
|
||||
command: ["sh", "-c", "bluetoothctl show 2>/dev/null | awk '/Powered:/{print $2; exit}';" + "echo '---DEVICES---';" + "bluetoothctl devices Paired 2>/dev/null | while read -r _ mac name; do " + "info=$(bluetoothctl info \"$mac\" 2>/dev/null); " + "conn=$(echo \"$info\" | grep -c 'Connected: yes'); " + "bat=$(echo \"$info\" | awk -F'[(): ]' '/Battery Percentage/{for(i=1;i<=NF;i++) if($i+0==$i && $i!=\"\") print $i}'); " + "echo \"$mac:$conn:${bat:-}:$name\"; " + "done"]
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue