add paired devices
This commit is contained in:
parent
149dae4c2e
commit
622604ad08
2 changed files with 69 additions and 4 deletions
|
|
@ -62,10 +62,12 @@ StyledPopupWindow {
|
|||
text: "Paired Devices"
|
||||
}
|
||||
|
||||
DeviceList {
|
||||
devices: Bluetooth.pairedDevices
|
||||
onDeviceActivated: device => {
|
||||
device.connect();
|
||||
ColumnLayout {
|
||||
Repeater {
|
||||
model: Bluetooth.pairedDevices
|
||||
delegate: PairedDevice {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
63
modules/bar/components/bluetooth/PairedDevice.qml
Normal file
63
modules/bar/components/bluetooth/PairedDevice.qml
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
pragma ComponentBehavior: Bound
|
||||
|
||||
import qs.config
|
||||
import qs.widgets
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Bluetooth
|
||||
import Quickshell.Widgets
|
||||
|
||||
StyledLabel {
|
||||
id: device
|
||||
required property BluetoothDevice modelData
|
||||
|
||||
RowLayout {
|
||||
id: row
|
||||
|
||||
spacing: 8
|
||||
|
||||
Loader {
|
||||
active: modelData.icon != undefined
|
||||
sourceComponent: IconImage {
|
||||
implicitSize: 18
|
||||
source: Quickshell.iconPath(device.modelData.icon)
|
||||
}
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: device.modelData.deviceName
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.alignment: Qt.AlignRight
|
||||
StyledButton {
|
||||
hoverEnabled: device.modelData.state == BluetoothDeviceState.Disconnected
|
||||
color: containsMouse ? Theme.palette.info : Theme.palette.base200
|
||||
content: StyledText {
|
||||
text: 'Connect'
|
||||
}
|
||||
onClicked: {
|
||||
if (!hoverEnabled) {
|
||||
return;
|
||||
}
|
||||
device.modelData.connect();
|
||||
}
|
||||
}
|
||||
|
||||
StyledButton {
|
||||
hoverEnabled: device.modelData.state == BluetoothDeviceState.Disconnected
|
||||
color: containsMouse ? Theme.palette.error : Theme.palette.base200
|
||||
content: StyledText {
|
||||
text: 'Unpair'
|
||||
}
|
||||
onClicked: {
|
||||
if (!hoverEnabled) {
|
||||
return;
|
||||
}
|
||||
device.modelData.forget();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue