wactioncenter: bluetooth menu

This commit is contained in:
end-4
2025-11-22 21:55:47 +01:00
parent 7613bba393
commit 55961ae079
22 changed files with 451 additions and 69 deletions
@@ -0,0 +1,129 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Qt5Compat.GraphicalEffects
import Quickshell
import Quickshell.Bluetooth
import qs
import qs.services
import qs.services.network
import qs.modules.common
import qs.modules.common.functions
import qs.modules.common.widgets
import qs.modules.waffle.looks
import qs.modules.waffle.actionCenter
Item {
id: root
Component.onCompleted: {
if (Bluetooth.defaultAdapter.enabled) Bluetooth.defaultAdapter.discovering = true;
}
Component.onDestruction: {
Bluetooth.defaultAdapter.discovering = false;
}
PageColumn {
anchors.fill: parent
BodyRectangle {
implicitHeight: 400
implicitWidth: 50
ColumnLayout {
anchors.fill: parent
anchors.margins: 4
spacing: 4
ColumnLayout {
implicitHeight: headerRow.implicitHeight
Layout.fillWidth: true
spacing: 0
RowLayout {
Layout.fillWidth: true
spacing: 0
HeaderRow {
id: headerRow
Layout.fillWidth: true
title: qsTr("Bluetooth")
}
WSwitch {
id: toggleSwitch
Layout.rightMargin: 12
checked: Bluetooth.defaultAdapter?.enabled ?? false
onCheckedChanged: {
if (Bluetooth.defaultAdapter) {
Bluetooth.defaultAdapter.enabled = checked;
if (checked) {
Bluetooth.defaultAdapter.discovering = true;
} else {
Bluetooth.defaultAdapter.discovering = false;
}
}
}
}
}
FadeLoader {
Layout.leftMargin: -4
Layout.rightMargin: -4
Layout.fillWidth: true
shown: Bluetooth.defaultAdapter?.discovering ?? false
visible: true
sourceComponent: WIndeterminateProgressBar {}
}
}
StyledListView {
id: listView
Layout.fillHeight: true
Layout.fillWidth: true
animateAppearance: false
contentHeight: contentLayout.implicitHeight
contentWidth: width
clip: true
spacing: 4
model: ScriptModel {
values: BluetoothStatus.friendlyDeviceList
}
delegate: BluetoothDeviceItem {
required property BluetoothDevice modelData
device: modelData
width: ListView.view.width
}
}
}
}
Separator {}
FooterRectangle {
FooterMoreButton {
anchors {
verticalCenter: parent.verticalCenter
left: parent.left
}
text: qsTr("More Bluetooth settings")
onClicked: {
Quickshell.execDetached(["qs", "-p", Quickshell.shellPath(""), "ipc", "call", "sidebarLeft", "toggle"]);
Quickshell.execDetached(["bash", "-c", Config.options.apps.bluetooth]);
}
}
WPanelFooterButton {
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: 12
enabled: !Bluetooth.defaultAdapter?.discovering && Bluetooth.defaultAdapter?.enabled
onClicked: {
Bluetooth.defaultAdapter.discovering = true;
}
contentItem: FluentIcon {
icon: "arrow-counterclockwise"
}
}
}
}
}