Compare commits

..

No commits in common. "852ba5309290c37cc72dd87c862069a4f6c249ff" and "2027fc92b478b56075a2726761ba8e3c95156ff4" have entirely different histories.

4 changed files with 86 additions and 67 deletions

View file

@ -63,6 +63,14 @@ M.BarSection {
onTriggered: proc.running = true onTriggered: proc.running = true
} }
Process {
id: toggle
property string cmd: ""
command: ["bluetoothctl", "power", cmd]
onRunningChanged: if (!running && cmd !== "")
proc.running = true
}
M.BarIcon { M.BarIcon {
icon: "\uF294" icon: "\uF294"
color: root.state === "off" ? M.Theme.base04 : root.accentColor color: root.state === "off" ? M.Theme.base04 : root.accentColor
@ -76,13 +84,31 @@ M.BarSection {
required property var bar required property var bar
readonly property bool _anyHover: root._hovered || bluetoothMenu.panelHovered TapHandler {
acceptedButtons: Qt.LeftButton
cursorShape: Qt.PointingHandCursor
onTapped: {
menuLoader.active = !menuLoader.active;
M.FlyoutState.visible = false;
}
}
M.BluetoothMenu { TapHandler {
id: bluetoothMenu acceptedButtons: Qt.RightButton
showPanel: root._anyHover onTapped: {
screen: root.bar.screen toggle.cmd = root.state === "off" ? "on" : "off";
anchorItem: root toggle.running = true;
accentColor: root.accentColor }
}
LazyLoader {
id: menuLoader
active: false
M.BluetoothMenu {
accentColor: root.accentColor
screen: root.bar.screen
anchorX: root.mapToGlobal(root.width / 2, 0).x - (QsWindow.window?.screen?.x ?? 0)
onDismissed: menuLoader.active = false
}
} }
} }

View file

@ -6,18 +6,15 @@ import "." as M
M.HoverPanel { M.HoverPanel {
id: menuWindow id: menuWindow
popupMode: true
contentWidth: 250 contentWidth: 250
panelNamespace: "nova-bluetooth"
onVisibleChanged: if (visible)
scanner.running = true
property var _devices: [] property var _devices: []
property bool _btEnabled: true property bool _btEnabled: true
property Process _scanner: Process { property Process _scanner: Process {
id: scanner id: scanner
running: false running: true
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"] 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 { stdout: StdioCollector {
onStreamFinished: { onStreamFinished: {

View file

@ -10,5 +10,6 @@ M.BarLabel {
font.pixelSize: M.Theme.fontSize + 1 font.pixelSize: M.Theme.fontSize + 1
label: Qt.formatDateTime(clock.date, "ddd, dd. MMM HH:mm") label: Qt.formatDateTime(clock.date, "ddd, dd. MMM HH:mm")
minText: "Mi., 00. Sep. 00:00"
tooltip: Qt.formatDateTime(clock.date, "dddd, dd. MMMM yyyy\nHH:mm:ss") tooltip: Qt.formatDateTime(clock.date, "dddd, dd. MMMM yyyy\nHH:mm:ss")
} }

View file

@ -195,70 +195,65 @@ M.BarSection {
id: deviceList id: deviceList
width: parent.width width: parent.width
// Output devices only shown when more than one exists // Output devices
Column { Rectangle {
visible: root._sinkList.length > 1 width: parent.width - 16
height: 1
anchors.horizontalCenter: parent.horizontalCenter
color: M.Theme.base03
}
Text {
width: parent.width width: parent.width
height: 24
verticalAlignment: Text.AlignVCenter
leftPadding: 12
text: "Output Devices"
color: M.Theme.base04
font.pixelSize: M.Theme.fontSize - 1
font.family: M.Theme.fontFamily
}
Rectangle { Repeater {
width: parent.width - 16 model: root._sinkList
height: 1
anchors.horizontalCenter: parent.horizontalCenter
color: M.Theme.base03
}
Text { delegate: Item {
width: parent.width required property var modelData
height: 24
verticalAlignment: Text.AlignVCenter
leftPadding: 12
text: "Output Devices"
color: M.Theme.base04
font.pixelSize: M.Theme.fontSize - 1
font.family: M.Theme.fontFamily
}
Repeater { width: deviceList.width
model: root._sinkList height: 28
delegate: Item { readonly property bool _active: modelData === root.sink
required property var modelData
width: deviceList.width Rectangle {
height: 28 anchors.fill: parent
anchors.leftMargin: 4
anchors.rightMargin: 4
color: deviceHover.hovered ? M.Theme.base02 : "transparent"
radius: M.Theme.radius
}
readonly property bool _active: modelData === root.sink Text {
anchors.left: parent.left
anchors.leftMargin: 12
anchors.right: parent.right
anchors.rightMargin: 12
anchors.verticalCenter: parent.verticalCenter
text: modelData.description || modelData.name || "Unknown"
color: parent._active ? root.accentColor : M.Theme.base05
font.pixelSize: M.Theme.fontSize
font.family: M.Theme.fontFamily
font.bold: parent._active
elide: Text.ElideRight
}
Rectangle { HoverHandler {
anchors.fill: parent id: deviceHover
anchors.leftMargin: 4 cursorShape: Qt.PointingHandCursor
anchors.rightMargin: 4 }
color: deviceHover.hovered ? M.Theme.base02 : "transparent"
radius: M.Theme.radius
}
Text { TapHandler {
anchors.left: parent.left onTapped: Pipewire.preferredDefaultAudioSink = modelData
anchors.leftMargin: 12
anchors.right: parent.right
anchors.rightMargin: 12
anchors.verticalCenter: parent.verticalCenter
text: modelData.description || modelData.name || "Unknown"
color: parent._active ? root.accentColor : M.Theme.base05
font.pixelSize: M.Theme.fontSize
font.family: M.Theme.fontFamily
font.bold: parent._active
elide: Text.ElideRight
}
HoverHandler {
id: deviceHover
cursorShape: Qt.PointingHandCursor
}
TapHandler {
onTapped: Pipewire.preferredDefaultAudioSink = modelData
}
} }
} }
} }