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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -22,17 +22,29 @@ StyledPopupWindow {
|
||||||
color: Theme.palette.base200
|
color: Theme.palette.base200
|
||||||
radius: 8
|
radius: 8
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
RowLayout {
|
||||||
RowLayout {
|
RowLayout {
|
||||||
StyledText {
|
StyledText {
|
||||||
text: "Bluetooth"
|
text: "Bluetooth"
|
||||||
}
|
}
|
||||||
|
|
||||||
Switch {
|
Switch {
|
||||||
Layout.alignment: Qt.AlignRight
|
|
||||||
checked: Bluetooth.defaultAdapter.enabled
|
checked: Bluetooth.defaultAdapter.enabled
|
||||||
onClicked: Bluetooth.defaultAdapter.enabled = checked
|
onClicked: Bluetooth.defaultAdapter.enabled = checked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StyledButton {
|
||||||
|
Layout.alignment: Qt.AlignRight
|
||||||
|
onClicked: {
|
||||||
|
Bluetooth.defaultAdapter.discovering = true;
|
||||||
|
Bluetooth.defaultAdapter.discoverableTimeout = 10;
|
||||||
|
}
|
||||||
|
content: StyledText {
|
||||||
|
text: "Scan"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WrapperRectangle {
|
WrapperRectangle {
|
||||||
|
|
@ -76,10 +88,12 @@ StyledPopupWindow {
|
||||||
text: "Available Devices"
|
text: "Available Devices"
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceList {
|
ColumnLayout {
|
||||||
devices: Bluetooth.availableDevices
|
Repeater {
|
||||||
onDeviceActivated: device => {
|
model: Bluetooth.availableDevices
|
||||||
device.pair();
|
delegate: AvailableDevice {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,10 @@ StyledLabel {
|
||||||
spacing: 8
|
spacing: 8
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
active: modelData.icon != undefined
|
active: device.modelData.icon != undefined
|
||||||
sourceComponent: IconImage {
|
sourceComponent: IconImage {
|
||||||
implicitSize: 18
|
implicitSize: 22
|
||||||
source: Quickshell.iconPath(modelData.icon)
|
source: Quickshell.iconPath(device.modelData.icon, "device-support-unknown-symbolic")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -82,12 +82,13 @@ StyledLabel {
|
||||||
color: containsMouse ? Theme.palette.error : Theme.palette.base200
|
color: containsMouse ? Theme.palette.error : Theme.palette.base200
|
||||||
content: StyledText {
|
content: StyledText {
|
||||||
text: 'Disconnect'
|
text: 'Disconnect'
|
||||||
|
font.pixelSize: 12
|
||||||
}
|
}
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (modelData.state != BluetoothDeviceState.Connected) {
|
if (device.modelData.state != BluetoothDeviceState.Connected) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
modelData.disconnect();
|
device.modelData.connected = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ StyledLabel {
|
||||||
Loader {
|
Loader {
|
||||||
active: modelData.icon != undefined
|
active: modelData.icon != undefined
|
||||||
sourceComponent: IconImage {
|
sourceComponent: IconImage {
|
||||||
implicitSize: 18
|
implicitSize: 22
|
||||||
source: Quickshell.iconPath(device.modelData.icon)
|
source: Quickshell.iconPath(root.modelData.icon, "device-support-unknown-symbolic")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -33,9 +33,10 @@ StyledLabel {
|
||||||
Layout.alignment: Qt.AlignRight
|
Layout.alignment: Qt.AlignRight
|
||||||
StyledButton {
|
StyledButton {
|
||||||
hoverEnabled: device.modelData.state == BluetoothDeviceState.Disconnected
|
hoverEnabled: device.modelData.state == BluetoothDeviceState.Disconnected
|
||||||
color: containsMouse ? Theme.palette.info : Theme.palette.base200
|
color: containsMouse ? Theme.palette.primary : Theme.palette.base200
|
||||||
content: StyledText {
|
content: StyledText {
|
||||||
text: 'Connect'
|
text: 'Connect'
|
||||||
|
font.pixelSize: 12
|
||||||
}
|
}
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (!hoverEnabled) {
|
if (!hoverEnabled) {
|
||||||
|
|
@ -50,6 +51,7 @@ StyledLabel {
|
||||||
color: containsMouse ? Theme.palette.error : Theme.palette.base200
|
color: containsMouse ? Theme.palette.error : Theme.palette.base200
|
||||||
content: StyledText {
|
content: StyledText {
|
||||||
text: 'Unpair'
|
text: 'Unpair'
|
||||||
|
font.pixelSize: 12
|
||||||
}
|
}
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (!hoverEnabled) {
|
if (!hoverEnabled) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
pragma Singleton
|
pragma Singleton
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Bluetooth
|
import Quickshell.Bluetooth
|
||||||
|
|
||||||
|
|
@ -7,9 +8,9 @@ Singleton {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property BluetoothAdapter defaultAdapter: Bluetooth.defaultAdapter
|
property BluetoothAdapter defaultAdapter: Bluetooth.defaultAdapter
|
||||||
property list<BluetoothDevice> connectedDevices: defaultAdapter.devices.values.filter(device => device.connected)
|
property list<BluetoothDevice> connectedDevices: defaultAdapter?.devices.values.filter(device => device.state == BluetoothDeviceState.Connected)
|
||||||
property list<BluetoothDevice> pairedDevices: defaultAdapter.devices.values.filter(device => device.paired && !device.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.paired)
|
property list<BluetoothDevice> availableDevices: defaultAdapter?.devices.values.filter(device => !device.bonded && device.deviceName != "")
|
||||||
|
|
||||||
function isConnected(BluetoothDevice: device) {
|
function isConnected(BluetoothDevice: device) {
|
||||||
return device.state == BluetoothDeviceState.Connected;
|
return device.state == BluetoothDeviceState.Connected;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
//@ pragma IconTheme WhiteSur-dark
|
||||||
|
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import "modules"
|
import "modules"
|
||||||
import "modules/bar"
|
import "modules/bar"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue