125 lines
3.8 KiB
QML
125 lines
3.8 KiB
QML
import QtQuick
|
|
import Quickshell
|
|
import "." as M
|
|
import "../services" as S
|
|
|
|
M.HoverPanel {
|
|
id: menuWindow
|
|
|
|
contentWidth: 250
|
|
panelNamespace: "nova-bluetooth"
|
|
popupMode: true
|
|
panelTitle: "Bluetooth"
|
|
titleActionsComponent: Component {
|
|
Item {
|
|
width: 20
|
|
height: 20
|
|
|
|
Text {
|
|
anchors.centerIn: parent
|
|
text: "\uF011"
|
|
color: S.BluetoothService.enabled ? menuWindow.accentColor : S.Theme.base04
|
|
font.pixelSize: S.Theme.fontSize
|
|
font.family: S.Theme.iconFontFamily
|
|
|
|
Behavior on color {
|
|
ColorAnimation {
|
|
duration: 100
|
|
}
|
|
}
|
|
}
|
|
|
|
HoverHandler {
|
|
cursorShape: Qt.PointingHandCursor
|
|
}
|
|
|
|
TapHandler {
|
|
onTapped: S.BluetoothService.setPower(!S.BluetoothService.enabled)
|
|
}
|
|
}
|
|
}
|
|
|
|
onVisibleChanged: if (visible)
|
|
S.BluetoothService.refresh()
|
|
|
|
Repeater {
|
|
model: S.BluetoothService.devices
|
|
|
|
delegate: Item {
|
|
id: entry
|
|
required property var modelData
|
|
required property int index
|
|
|
|
width: menuWindow.contentWidth
|
|
height: 32
|
|
|
|
Rectangle {
|
|
anchors.fill: parent
|
|
anchors.leftMargin: 4
|
|
anchors.rightMargin: 4
|
|
color: entryHover.hovered ? S.Theme.base02 : "transparent"
|
|
radius: S.Theme.radius
|
|
}
|
|
|
|
Text {
|
|
id: btIcon
|
|
anchors.left: parent.left
|
|
anchors.leftMargin: 12
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
text: "\uF294"
|
|
color: entry.modelData.connected ? menuWindow.accentColor : S.Theme.base04
|
|
font.pixelSize: S.Theme.fontSize + 1
|
|
font.family: S.Theme.iconFontFamily
|
|
}
|
|
|
|
Text {
|
|
anchors.left: btIcon.right
|
|
anchors.leftMargin: 8
|
|
anchors.right: batLabel.left
|
|
anchors.rightMargin: 4
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
text: entry.modelData.name
|
|
color: entry.modelData.connected ? menuWindow.accentColor : S.Theme.base05
|
|
font.pixelSize: S.Theme.fontSize
|
|
font.family: S.Theme.fontFamily
|
|
font.bold: entry.modelData.connected
|
|
elide: Text.ElideRight
|
|
}
|
|
|
|
Text {
|
|
id: batLabel
|
|
anchors.right: parent.right
|
|
anchors.rightMargin: 12
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
text: entry.modelData.battery >= 0 ? entry.modelData.battery + "%" : ""
|
|
color: S.Theme.base04
|
|
font.pixelSize: S.Theme.fontSize - 1
|
|
font.family: S.Theme.fontFamily
|
|
width: entry.modelData.battery >= 0 ? implicitWidth : 0
|
|
}
|
|
|
|
HoverHandler {
|
|
id: entryHover
|
|
cursorShape: Qt.PointingHandCursor
|
|
}
|
|
TapHandler {
|
|
onTapped: {
|
|
S.BluetoothService.toggleDevice(entry.modelData.mac, !entry.modelData.connected);
|
|
menuWindow.keepOpen(500);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Text {
|
|
visible: S.BluetoothService.devices.length === 0
|
|
width: menuWindow.contentWidth
|
|
height: 32
|
|
horizontalAlignment: Text.AlignHCenter
|
|
verticalAlignment: Text.AlignVCenter
|
|
text: S.BluetoothService.enabled ? "No paired devices" : "Bluetooth is off"
|
|
color: S.Theme.base04
|
|
font.pixelSize: S.Theme.fontSize
|
|
font.family: S.Theme.fontFamily
|
|
}
|
|
}
|