add available devices and fix formatting/icons
This commit is contained in:
parent
622604ad08
commit
7625a8109b
6 changed files with 89 additions and 20 deletions
49
modules/bar/components/bluetooth/AvailableDevice.qml
Normal file
49
modules/bar/components/bluetooth/AvailableDevice.qml
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
pragma ComponentBehavior: Bound
|
||||
|
||||
import qs.config
|
||||
import qs.widgets
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Bluetooth
|
||||
import Quickshell.Widgets
|
||||
|
||||
StyledLabel {
|
||||
id: root
|
||||
required property BluetoothDevice modelData
|
||||
|
||||
RowLayout {
|
||||
id: row
|
||||
|
||||
spacing: 8
|
||||
|
||||
Loader {
|
||||
active: root.modelData.icon != undefined
|
||||
sourceComponent: IconImage {
|
||||
implicitSize: 22
|
||||
source: Quickshell.iconPath(root.modelData.icon, "device-support-unknown-symbolic")
|
||||
}
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: root.modelData.deviceName
|
||||
}
|
||||
|
||||
StyledButton {
|
||||
Layout.alignment: Qt.AlignRight
|
||||
hoverEnabled: !root.modelData.pairing
|
||||
color: containsMouse ? Theme.palette.primary : Theme.palette.base200
|
||||
content: StyledText {
|
||||
text: 'Pair'
|
||||
font.pixelSize: 12
|
||||
}
|
||||
onClicked: {
|
||||
if (!hoverEnabled) {
|
||||
return;
|
||||
}
|
||||
root.modelData.trusted = true;
|
||||
root.modelData.pair();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,14 +23,26 @@ StyledPopupWindow {
|
|||
radius: 8
|
||||
Layout.fillWidth: true
|
||||
RowLayout {
|
||||
StyledText {
|
||||
text: "Bluetooth"
|
||||
RowLayout {
|
||||
StyledText {
|
||||
text: "Bluetooth"
|
||||
}
|
||||
|
||||
Switch {
|
||||
checked: Bluetooth.defaultAdapter.enabled
|
||||
onClicked: Bluetooth.defaultAdapter.enabled = checked
|
||||
}
|
||||
}
|
||||
|
||||
Switch {
|
||||
StyledButton {
|
||||
Layout.alignment: Qt.AlignRight
|
||||
checked: Bluetooth.defaultAdapter.enabled
|
||||
onClicked: Bluetooth.defaultAdapter.enabled = checked
|
||||
onClicked: {
|
||||
Bluetooth.defaultAdapter.discovering = true;
|
||||
Bluetooth.defaultAdapter.discoverableTimeout = 10;
|
||||
}
|
||||
content: StyledText {
|
||||
text: "Scan"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -76,10 +88,12 @@ StyledPopupWindow {
|
|||
text: "Available Devices"
|
||||
}
|
||||
|
||||
DeviceList {
|
||||
devices: Bluetooth.availableDevices
|
||||
onDeviceActivated: device => {
|
||||
device.pair();
|
||||
ColumnLayout {
|
||||
Repeater {
|
||||
model: Bluetooth.availableDevices
|
||||
delegate: AvailableDevice {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,10 +19,10 @@ StyledLabel {
|
|||
spacing: 8
|
||||
|
||||
Loader {
|
||||
active: modelData.icon != undefined
|
||||
active: device.modelData.icon != undefined
|
||||
sourceComponent: IconImage {
|
||||
implicitSize: 18
|
||||
source: Quickshell.iconPath(modelData.icon)
|
||||
implicitSize: 22
|
||||
source: Quickshell.iconPath(device.modelData.icon, "device-support-unknown-symbolic")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -82,12 +82,13 @@ StyledLabel {
|
|||
color: containsMouse ? Theme.palette.error : Theme.palette.base200
|
||||
content: StyledText {
|
||||
text: 'Disconnect'
|
||||
font.pixelSize: 12
|
||||
}
|
||||
onClicked: {
|
||||
if (modelData.state != BluetoothDeviceState.Connected) {
|
||||
if (device.modelData.state != BluetoothDeviceState.Connected) {
|
||||
return;
|
||||
}
|
||||
modelData.disconnect();
|
||||
device.modelData.connected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ StyledLabel {
|
|||
Loader {
|
||||
active: modelData.icon != undefined
|
||||
sourceComponent: IconImage {
|
||||
implicitSize: 18
|
||||
source: Quickshell.iconPath(device.modelData.icon)
|
||||
implicitSize: 22
|
||||
source: Quickshell.iconPath(root.modelData.icon, "device-support-unknown-symbolic")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -33,9 +33,10 @@ StyledLabel {
|
|||
Layout.alignment: Qt.AlignRight
|
||||
StyledButton {
|
||||
hoverEnabled: device.modelData.state == BluetoothDeviceState.Disconnected
|
||||
color: containsMouse ? Theme.palette.info : Theme.palette.base200
|
||||
color: containsMouse ? Theme.palette.primary : Theme.palette.base200
|
||||
content: StyledText {
|
||||
text: 'Connect'
|
||||
font.pixelSize: 12
|
||||
}
|
||||
onClicked: {
|
||||
if (!hoverEnabled) {
|
||||
|
|
@ -50,6 +51,7 @@ StyledLabel {
|
|||
color: containsMouse ? Theme.palette.error : Theme.palette.base200
|
||||
content: StyledText {
|
||||
text: 'Unpair'
|
||||
font.pixelSize: 12
|
||||
}
|
||||
onClicked: {
|
||||
if (!hoverEnabled) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
pragma Singleton
|
||||
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Bluetooth
|
||||
|
||||
|
|
@ -7,9 +8,9 @@ Singleton {
|
|||
id: root
|
||||
|
||||
property BluetoothAdapter defaultAdapter: Bluetooth.defaultAdapter
|
||||
property list<BluetoothDevice> connectedDevices: defaultAdapter.devices.values.filter(device => device.connected)
|
||||
property list<BluetoothDevice> pairedDevices: defaultAdapter.devices.values.filter(device => device.paired && !device.connected)
|
||||
property list<BluetoothDevice> availableDevices: defaultAdapter.devices.values.filter(device => !device.paired)
|
||||
property list<BluetoothDevice> connectedDevices: defaultAdapter?.devices.values.filter(device => device.state == BluetoothDeviceState.Connected)
|
||||
property list<BluetoothDevice> pairedDevices: defaultAdapter?.devices.values.filter(device => device.bonded && device.state == BluetoothDeviceState.Disconnected)
|
||||
property list<BluetoothDevice> availableDevices: defaultAdapter?.devices.values.filter(device => !device.bonded && device.deviceName != "")
|
||||
|
||||
function isConnected(BluetoothDevice: device) {
|
||||
return device.state == BluetoothDeviceState.Connected;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//@ pragma IconTheme WhiteSur-dark
|
||||
|
||||
import Quickshell
|
||||
import "modules"
|
||||
import "modules/bar"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue