summaryrefslogtreecommitdiff
path: root/modules/controlcenter/bluetooth
diff options
context:
space:
mode:
Diffstat (limited to 'modules/controlcenter/bluetooth')
-rw-r--r--modules/controlcenter/bluetooth/BtPane.qml73
-rw-r--r--modules/controlcenter/bluetooth/Details.qml671
-rw-r--r--modules/controlcenter/bluetooth/DeviceList.qml264
-rw-r--r--modules/controlcenter/bluetooth/Settings.qml532
4 files changed, 0 insertions, 1540 deletions
diff --git a/modules/controlcenter/bluetooth/BtPane.qml b/modules/controlcenter/bluetooth/BtPane.qml
deleted file mode 100644
index 7d3b9ca..0000000
--- a/modules/controlcenter/bluetooth/BtPane.qml
+++ /dev/null
@@ -1,73 +0,0 @@
-pragma ComponentBehavior: Bound
-
-import ".."
-import "../components"
-import "."
-import qs.components
-import qs.components.controls
-import qs.components.containers
-import qs.config
-import Quickshell.Widgets
-import Quickshell.Bluetooth
-import QtQuick
-
-SplitPaneWithDetails {
- id: root
-
- required property Session session
-
- anchors.fill: parent
-
- activeItem: session.bt.active
- paneIdGenerator: function (item) {
- return item ? (item.address || "") : "";
- }
-
- leftContent: Component {
- StyledFlickable {
- id: leftFlickable
-
- flickableDirection: Flickable.VerticalFlick
- contentHeight: deviceList.height
-
- StyledScrollBar.vertical: StyledScrollBar {
- flickable: leftFlickable
- }
-
- DeviceList {
- id: deviceList
-
- anchors.left: parent.left
- anchors.right: parent.right
- session: root.session
- }
- }
- }
-
- rightDetailsComponent: Component {
- Details {
- session: root.session
- }
- }
-
- rightSettingsComponent: Component {
- StyledFlickable {
- id: settingsFlickable
- flickableDirection: Flickable.VerticalFlick
- contentHeight: settingsInner.height
-
- StyledScrollBar.vertical: StyledScrollBar {
- flickable: settingsFlickable
- }
-
- Settings {
- id: settingsInner
-
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.top: parent.top
- session: root.session
- }
- }
- }
-}
diff --git a/modules/controlcenter/bluetooth/Details.qml b/modules/controlcenter/bluetooth/Details.qml
deleted file mode 100644
index bc276e0..0000000
--- a/modules/controlcenter/bluetooth/Details.qml
+++ /dev/null
@@ -1,671 +0,0 @@
-pragma ComponentBehavior: Bound
-
-import ".."
-import "../components"
-import qs.components
-import qs.components.controls
-import qs.components.effects
-import qs.components.containers
-import qs.services
-import qs.config
-import qs.utils
-import Quickshell.Bluetooth
-import QtQuick
-import QtQuick.Layouts
-
-StyledFlickable {
- id: root
-
- required property Session session
- readonly property BluetoothDevice device: session.bt.active
-
- flickableDirection: Flickable.VerticalFlick
- contentHeight: detailsWrapper.height
-
- StyledScrollBar.vertical: StyledScrollBar {
- flickable: root
- }
-
- Item {
- id: detailsWrapper
-
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.top: parent.top
- implicitHeight: details.implicitHeight
-
- DeviceDetails {
- id: details
-
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.top: parent.top
-
- session: root.session
- device: root.device
-
- headerComponent: Component {
- SettingsHeader {
- icon: Icons.getBluetoothIcon(root.device?.icon ?? "")
- title: root.device?.name ?? ""
- }
- }
-
- sections: [
- Component {
- ColumnLayout {
- spacing: Appearance.spacing.normal
-
- StyledText {
- Layout.topMargin: Appearance.spacing.large
- text: qsTr("Connection status")
- font.pointSize: Appearance.font.size.larger
- font.weight: 500
- }
-
- StyledText {
- text: qsTr("Connection settings for this device")
- color: Colours.palette.m3outline
- }
-
- StyledRect {
- Layout.fillWidth: true
- implicitHeight: deviceStatus.implicitHeight + Appearance.padding.large * 2
-
- radius: Appearance.rounding.normal
- color: Colours.tPalette.m3surfaceContainer
-
- ColumnLayout {
- id: deviceStatus
-
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.verticalCenter: parent.verticalCenter
- anchors.margins: Appearance.padding.large
-
- spacing: Appearance.spacing.larger
-
- Toggle {
- label: qsTr("Connected")
- checked: root.device?.connected ?? false
- toggle.onToggled: root.device.connected = checked
- }
-
- Toggle {
- label: qsTr("Paired")
- checked: root.device?.paired ?? false
- toggle.onToggled: {
- if (root.device.paired)
- root.device.forget();
- else
- root.device.pair();
- }
- }
-
- Toggle {
- label: qsTr("Blocked")
- checked: root.device?.blocked ?? false
- toggle.onToggled: root.device.blocked = checked
- }
- }
- }
- }
- },
- Component {
- ColumnLayout {
- spacing: Appearance.spacing.normal
-
- StyledText {
- Layout.topMargin: Appearance.spacing.large
- text: qsTr("Device properties")
- font.pointSize: Appearance.font.size.larger
- font.weight: 500
- }
-
- StyledText {
- text: qsTr("Additional settings")
- color: Colours.palette.m3outline
- }
-
- StyledRect {
- Layout.fillWidth: true
- implicitHeight: deviceProps.implicitHeight + Appearance.padding.large * 2
-
- radius: Appearance.rounding.normal
- color: Colours.tPalette.m3surfaceContainer
-
- ColumnLayout {
- id: deviceProps
-
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.verticalCenter: parent.verticalCenter
- anchors.margins: Appearance.padding.large
-
- spacing: Appearance.spacing.larger
-
- RowLayout {
- Layout.fillWidth: true
- spacing: Appearance.spacing.small
-
- Item {
- id: renameDevice
-
- Layout.fillWidth: true
- Layout.rightMargin: Appearance.spacing.small
-
- implicitHeight: renameLabel.implicitHeight + deviceNameEdit.implicitHeight
-
- states: State {
- name: "editingDeviceName"
- when: root.session.bt.editingDeviceName
-
- AnchorChanges {
- target: deviceNameEdit
- anchors.top: renameDevice.top
- }
- PropertyChanges {
- renameDevice.implicitHeight: deviceNameEdit.implicitHeight
- renameLabel.opacity: 0
- deviceNameEdit.padding: Appearance.padding.normal
- }
- }
-
- transitions: Transition {
- AnchorAnimation {
- duration: Appearance.anim.durations.normal
- easing.type: Easing.BezierSpline
- easing.bezierCurve: Appearance.anim.curves.standard
- }
- Anim {
- properties: "implicitHeight,opacity,padding"
- }
- }
-
- StyledText {
- id: renameLabel
-
- anchors.left: parent.left
-
- text: qsTr("Device name")
- color: Colours.palette.m3outline
- font.pointSize: Appearance.font.size.small
- }
-
- StyledTextField {
- id: deviceNameEdit
-
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.top: renameLabel.bottom
- anchors.leftMargin: root.session.bt.editingDeviceName ? 0 : -Appearance.padding.normal
-
- text: root.device?.name ?? ""
- readOnly: !root.session.bt.editingDeviceName
- onAccepted: {
- root.session.bt.editingDeviceName = false;
- root.device.name = text;
- }
-
- leftPadding: Appearance.padding.normal
- rightPadding: Appearance.padding.normal
-
- background: StyledRect {
- radius: Appearance.rounding.small
- border.width: 2
- border.color: Colours.palette.m3primary
- opacity: root.session.bt.editingDeviceName ? 1 : 0
-
- Behavior on border.color {
- CAnim {}
- }
-
- Behavior on opacity {
- Anim {}
- }
- }
-
- Behavior on anchors.leftMargin {
- Anim {}
- }
- }
- }
-
- StyledRect {
- implicitWidth: implicitHeight
- implicitHeight: cancelEditIcon.implicitHeight + Appearance.padding.smaller * 2
-
- radius: Appearance.rounding.small
- color: Colours.palette.m3secondaryContainer
- opacity: root.session.bt.editingDeviceName ? 1 : 0
- scale: root.session.bt.editingDeviceName ? 1 : 0.5
-
- StateLayer {
- color: Colours.palette.m3onSecondaryContainer
- disabled: !root.session.bt.editingDeviceName
-
- function onClicked(): void {
- root.session.bt.editingDeviceName = false;
- deviceNameEdit.text = Qt.binding(() => root.device?.name ?? "");
- }
- }
-
- MaterialIcon {
- id: cancelEditIcon
-
- anchors.centerIn: parent
- animate: true
- text: "cancel"
- color: Colours.palette.m3onSecondaryContainer
- }
-
- Behavior on opacity {
- Anim {}
- }
-
- Behavior on scale {
- Anim {
- duration: Appearance.anim.durations.expressiveFastSpatial
- easing.bezierCurve: Appearance.anim.curves.expressiveFastSpatial
- }
- }
- }
-
- StyledRect {
- implicitWidth: implicitHeight
- implicitHeight: editIcon.implicitHeight + Appearance.padding.smaller * 2
-
- radius: root.session.bt.editingDeviceName ? Appearance.rounding.small : implicitHeight / 2 * Math.min(1, Appearance.rounding.scale)
- color: Qt.alpha(Colours.palette.m3primary, root.session.bt.editingDeviceName ? 1 : 0)
-
- StateLayer {
- color: root.session.bt.editingDeviceName ? Colours.palette.m3onPrimary : Colours.palette.m3onSurface
-
- function onClicked(): void {
- root.session.bt.editingDeviceName = !root.session.bt.editingDeviceName;
- if (root.session.bt.editingDeviceName)
- deviceNameEdit.forceActiveFocus();
- else
- deviceNameEdit.accepted();
- }
- }
-
- MaterialIcon {
- id: editIcon
-
- anchors.centerIn: parent
- animate: true
- text: root.session.bt.editingDeviceName ? "check_circle" : "edit"
- color: root.session.bt.editingDeviceName ? Colours.palette.m3onPrimary : Colours.palette.m3onSurface
- }
-
- Behavior on radius {
- Anim {}
- }
- }
- }
-
- Toggle {
- label: qsTr("Trusted")
- checked: root.device?.trusted ?? false
- toggle.onToggled: root.device.trusted = checked
- }
-
- Toggle {
- label: qsTr("Wake allowed")
- checked: root.device?.wakeAllowed ?? false
- toggle.onToggled: root.device.wakeAllowed = checked
- }
- }
- }
- }
- },
- Component {
- ColumnLayout {
- spacing: Appearance.spacing.normal
-
- StyledText {
- Layout.topMargin: Appearance.spacing.large
- text: qsTr("Device information")
- font.pointSize: Appearance.font.size.larger
- font.weight: 500
- }
-
- StyledText {
- text: qsTr("Information about this device")
- color: Colours.palette.m3outline
- }
-
- StyledRect {
- Layout.fillWidth: true
- implicitHeight: deviceInfo.implicitHeight + Appearance.padding.large * 2
-
- radius: Appearance.rounding.normal
- color: Colours.tPalette.m3surfaceContainer
-
- ColumnLayout {
- id: deviceInfo
-
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.verticalCenter: parent.verticalCenter
- anchors.margins: Appearance.padding.large
-
- spacing: Appearance.spacing.small / 2
-
- StyledText {
- text: root.device?.batteryAvailable ? qsTr("Device battery (%1%)").arg(root.device.battery * 100) : qsTr("Battery unavailable")
- }
-
- RowLayout {
- id: batteryPercent
- Layout.topMargin: Appearance.spacing.small / 2
- Layout.fillWidth: true
- Layout.preferredHeight: Appearance.padding.smaller
- spacing: Appearance.spacing.small / 2
-
- StyledRect {
- Layout.fillWidth: true
- Layout.fillHeight: true
- radius: Appearance.rounding.full
- color: Colours.palette.m3secondaryContainer
-
- StyledRect {
- anchors.left: parent.left
- anchors.top: parent.top
- anchors.bottom: parent.bottom
- anchors.margins: parent.height * 0.25
-
- implicitWidth: root.device?.batteryAvailable ? batteryPercent.width * root.device.battery : 0
- radius: Appearance.rounding.full
- color: Colours.palette.m3primary
- }
- }
- }
-
- StyledText {
- Layout.topMargin: Appearance.spacing.normal
- text: qsTr("Dbus path")
- }
-
- StyledText {
- text: root.device?.dbusPath ?? ""
- color: Colours.palette.m3outline
- font.pointSize: Appearance.font.size.small
- }
-
- StyledText {
- Layout.topMargin: Appearance.spacing.normal
- text: qsTr("MAC address")
- }
-
- StyledText {
- text: root.device?.address ?? ""
- color: Colours.palette.m3outline
- font.pointSize: Appearance.font.size.small
- }
-
- StyledText {
- Layout.topMargin: Appearance.spacing.normal
- text: qsTr("Bonded")
- }
-
- StyledText {
- text: root.device?.bonded ? qsTr("Yes") : qsTr("No")
- color: Colours.palette.m3outline
- font.pointSize: Appearance.font.size.small
- }
-
- StyledText {
- Layout.topMargin: Appearance.spacing.normal
- text: qsTr("System name")
- }
-
- StyledText {
- text: root.device?.deviceName ?? ""
- color: Colours.palette.m3outline
- font.pointSize: Appearance.font.size.small
- }
- }
- }
- }
- }
- ]
- }
- }
-
- ColumnLayout {
- anchors.right: fabRoot.right
- anchors.bottom: fabRoot.top
- anchors.bottomMargin: Appearance.padding.normal
-
- Repeater {
- id: fabMenu
-
- model: ListModel {
- ListElement {
- name: "trust"
- icon: "handshake"
- }
- ListElement {
- name: "block"
- icon: "block"
- }
- ListElement {
- name: "pair"
- icon: "missing_controller"
- }
- ListElement {
- name: "connect"
- icon: "bluetooth_connected"
- }
- }
-
- StyledClippingRect {
- id: fabMenuItem
-
- required property var modelData
- required property int index
-
- Layout.alignment: Qt.AlignRight
-
- implicitHeight: fabMenuItemInner.implicitHeight + Appearance.padding.larger * 2
-
- radius: Appearance.rounding.full
- color: Colours.palette.m3primaryContainer
-
- opacity: 0
-
- states: State {
- name: "visible"
- when: root.session.bt.fabMenuOpen
-
- PropertyChanges {
- fabMenuItem.implicitWidth: fabMenuItemInner.implicitWidth + Appearance.padding.large * 2
- fabMenuItem.opacity: 1
- fabMenuItemInner.opacity: 1
- }
- }
-
- transitions: [
- Transition {
- to: "visible"
-
- SequentialAnimation {
- PauseAnimation {
- duration: (fabMenu.count - 1 - fabMenuItem.index) * Appearance.anim.durations.small / 8
- }
- ParallelAnimation {
- Anim {
- property: "implicitWidth"
- duration: Appearance.anim.durations.expressiveFastSpatial
- easing.bezierCurve: Appearance.anim.curves.expressiveFastSpatial
- }
- Anim {
- property: "opacity"
- duration: Appearance.anim.durations.small
- }
- }
- }
- },
- Transition {
- from: "visible"
-
- SequentialAnimation {
- PauseAnimation {
- duration: fabMenuItem.index * Appearance.anim.durations.small / 8
- }
- ParallelAnimation {
- Anim {
- property: "implicitWidth"
- duration: Appearance.anim.durations.expressiveFastSpatial
- easing.bezierCurve: Appearance.anim.curves.expressiveFastSpatial
- }
- Anim {
- property: "opacity"
- duration: Appearance.anim.durations.small
- }
- }
- }
- }
- ]
-
- StateLayer {
- function onClicked(): void {
- root.session.bt.fabMenuOpen = false;
-
- const name = fabMenuItem.modelData.name;
- if (fabMenuItem.modelData.name !== "pair")
- root.device[`${name}ed`] = !root.device[`${name}ed`];
- else if (root.device.paired)
- root.device.forget();
- else
- root.device.pair();
- }
- }
-
- RowLayout {
- id: fabMenuItemInner
-
- anchors.centerIn: parent
- spacing: Appearance.spacing.normal
- opacity: 0
-
- MaterialIcon {
- text: fabMenuItem.modelData.icon
- color: Colours.palette.m3onPrimaryContainer
- fill: 1
- }
-
- StyledText {
- animate: true
- text: (root.device && root.device[`${fabMenuItem.modelData.name}ed`] ? fabMenuItem.modelData.name === "connect" ? "dis" : "un" : "") + fabMenuItem.modelData.name
- color: Colours.palette.m3onPrimaryContainer
- font.capitalization: Font.Capitalize
- Layout.preferredWidth: implicitWidth
-
- Behavior on Layout.preferredWidth {
- Anim {
- duration: Appearance.anim.durations.small
- }
- }
- }
- }
- }
- }
- }
-
- Item {
- id: fabRoot
-
- x: root.contentX + root.width - width
- y: root.contentY + root.height - height
- width: 64
- height: 64
- z: 10000
-
- StyledRect {
- id: fabBg
-
- anchors.right: parent.right
- anchors.top: parent.top
-
- implicitWidth: 64
- implicitHeight: 64
-
- radius: Appearance.rounding.normal
- color: root.session.bt.fabMenuOpen ? Colours.palette.m3primary : Colours.palette.m3primaryContainer
-
- states: State {
- name: "expanded"
- when: root.session.bt.fabMenuOpen
-
- PropertyChanges {
- fabBg.implicitWidth: 48
- fabBg.implicitHeight: 48
- fabBg.radius: 48 / 2
- fab.font.pointSize: Appearance.font.size.larger
- }
- }
-
- transitions: Transition {
- Anim {
- properties: "implicitWidth,implicitHeight"
- duration: Appearance.anim.durations.expressiveFastSpatial
- easing.bezierCurve: Appearance.anim.curves.expressiveFastSpatial
- }
- Anim {
- properties: "radius,font.pointSize"
- }
- }
-
- Elevation {
- anchors.fill: parent
- radius: parent.radius
- z: -1
- level: fabState.containsMouse && !fabState.pressed ? 4 : 3
- }
-
- StateLayer {
- id: fabState
-
- color: root.session.bt.fabMenuOpen ? Colours.palette.m3onPrimary : Colours.palette.m3onPrimaryContainer
-
- function onClicked(): void {
- root.session.bt.fabMenuOpen = !root.session.bt.fabMenuOpen;
- }
- }
-
- MaterialIcon {
- id: fab
-
- anchors.centerIn: parent
- animate: true
- text: root.session.bt.fabMenuOpen ? "close" : "settings"
- color: root.session.bt.fabMenuOpen ? Colours.palette.m3onPrimary : Colours.palette.m3onPrimaryContainer
- font.pointSize: Appearance.font.size.large
- fill: 1
- }
- }
- }
-
- component Toggle: RowLayout {
- required property string label
- property alias checked: toggle.checked
- property alias toggle: toggle
-
- Layout.fillWidth: true
- spacing: Appearance.spacing.normal
-
- StyledText {
- Layout.fillWidth: true
- text: parent.label
- }
-
- StyledSwitch {
- id: toggle
-
- cLayer: 2
- }
- }
-}
diff --git a/modules/controlcenter/bluetooth/DeviceList.qml b/modules/controlcenter/bluetooth/DeviceList.qml
deleted file mode 100644
index 2a2bde9..0000000
--- a/modules/controlcenter/bluetooth/DeviceList.qml
+++ /dev/null
@@ -1,264 +0,0 @@
-pragma ComponentBehavior: Bound
-
-import ".."
-import "../components"
-import qs.components
-import qs.components.controls
-import qs.components.containers
-import qs.services
-import qs.config
-import qs.utils
-import Quickshell
-import Quickshell.Bluetooth
-import QtQuick
-import QtQuick.Layouts
-
-DeviceList {
- id: root
-
- required property Session session
- readonly property bool smallDiscoverable: width <= 540
- readonly property bool smallPairable: width <= 480
-
- title: qsTr("Devices (%1)").arg(Bluetooth.devices.values.length)
- description: qsTr("All available bluetooth devices")
- activeItem: session.bt.active
-
- model: ScriptModel {
- id: deviceModel
-
- values: [...Bluetooth.devices.values].sort((a, b) => (b.connected - a.connected) || (b.paired - a.paired) || a.name.localeCompare(b.name))
- }
-
- headerComponent: Component {
- RowLayout {
- spacing: Appearance.spacing.smaller
-
- StyledText {
- text: qsTr("Bluetooth")
- font.pointSize: Appearance.font.size.large
- font.weight: 500
- }
-
- Item {
- Layout.fillWidth: true
- }
-
- ToggleButton {
- toggled: Bluetooth.defaultAdapter?.enabled ?? false
- icon: "power"
- accent: "Tertiary"
- iconSize: Appearance.font.size.normal
- horizontalPadding: Appearance.padding.normal
- verticalPadding: Appearance.padding.smaller
- tooltip: qsTr("Toggle Bluetooth")
-
- onClicked: {
- const adapter = Bluetooth.defaultAdapter;
- if (adapter)
- adapter.enabled = !adapter.enabled;
- }
- }
-
- ToggleButton {
- toggled: Bluetooth.defaultAdapter?.discoverable ?? false
- icon: root.smallDiscoverable ? "group_search" : ""
- label: root.smallDiscoverable ? "" : qsTr("Discoverable")
- iconSize: Appearance.font.size.normal
- horizontalPadding: Appearance.padding.normal
- verticalPadding: Appearance.padding.smaller
- tooltip: qsTr("Make discoverable")
-
- onClicked: {
- const adapter = Bluetooth.defaultAdapter;
- if (adapter)
- adapter.discoverable = !adapter.discoverable;
- }
- }
-
- ToggleButton {
- toggled: Bluetooth.defaultAdapter?.pairable ?? false
- icon: "missing_controller"
- label: root.smallPairable ? "" : qsTr("Pairable")
- iconSize: Appearance.font.size.normal
- horizontalPadding: Appearance.padding.normal
- verticalPadding: Appearance.padding.smaller
- tooltip: qsTr("Make pairable")
-
- onClicked: {
- const adapter = Bluetooth.defaultAdapter;
- if (adapter)
- adapter.pairable = !adapter.pairable;
- }
- }
-
- ToggleButton {
- toggled: Bluetooth.defaultAdapter?.discovering ?? false
- icon: "bluetooth_searching"
- accent: "Secondary"
- iconSize: Appearance.font.size.normal
- horizontalPadding: Appearance.padding.normal
- verticalPadding: Appearance.padding.smaller
- tooltip: qsTr("Scan for devices")
-
- onClicked: {
- const adapter = Bluetooth.defaultAdapter;
- if (adapter)
- adapter.discovering = !adapter.discovering;
- }
- }
-
- ToggleButton {
- toggled: !root.session.bt.active
- icon: "settings"
- accent: "Primary"
- iconSize: Appearance.font.size.normal
- horizontalPadding: Appearance.padding.normal
- verticalPadding: Appearance.padding.smaller
- tooltip: qsTr("Bluetooth settings")
-
- onClicked: {
- if (root.session.bt.active)
- root.session.bt.active = null;
- else {
- root.session.bt.active = root.model.values[0] ?? null;
- }
- }
- }
- }
- }
-
- delegate: Component {
- StyledRect {
- id: device
-
- required property BluetoothDevice modelData
- readonly property bool loading: modelData && (modelData.state === BluetoothDeviceState.Connecting || modelData.state === BluetoothDeviceState.Disconnecting)
- readonly property bool connected: modelData && modelData.state === BluetoothDeviceState.Connected
-
- width: ListView.view ? ListView.view.width : undefined
- implicitHeight: deviceInner.implicitHeight + Appearance.padding.normal * 2
-
- color: Qt.alpha(Colours.tPalette.m3surfaceContainer, root.activeItem === modelData ? Colours.tPalette.m3surfaceContainer.a : 0)
- radius: Appearance.rounding.normal
-
- StateLayer {
- id: stateLayer
-
- function onClicked(): void {
- if (device.modelData)
- root.session.bt.active = device.modelData;
- }
- }
-
- RowLayout {
- id: deviceInner
-
- anchors.fill: parent
- anchors.margins: Appearance.padding.normal
-
- spacing: Appearance.spacing.normal
-
- StyledRect {
- implicitWidth: implicitHeight
- implicitHeight: icon.implicitHeight + Appearance.padding.normal * 2
-
- radius: Appearance.rounding.normal
- color: device.connected ? Colours.palette.m3primaryContainer : (device.modelData && device.modelData.bonded) ? Colours.palette.m3secondaryContainer : Colours.tPalette.m3surfaceContainerHigh
-
- StyledRect {
- anchors.fill: parent
- radius: parent.radius
- color: Qt.alpha(device.connected ? Colours.palette.m3onPrimaryContainer : (device.modelData && device.modelData.bonded) ? Colours.palette.m3onSecondaryContainer : Colours.palette.m3onSurface, stateLayer.pressed ? 0.1 : stateLayer.containsMouse ? 0.08 : 0)
- }
-
- MaterialIcon {
- id: icon
-
- anchors.centerIn: parent
- text: Icons.getBluetoothIcon(device.modelData ? device.modelData.icon : "")
- color: device.connected ? Colours.palette.m3onPrimaryContainer : (device.modelData && device.modelData.bonded) ? Colours.palette.m3onSecondaryContainer : Colours.palette.m3onSurface
- font.pointSize: Appearance.font.size.large
- fill: device.connected ? 1 : 0
-
- Behavior on fill {
- Anim {}
- }
- }
- }
-
- ColumnLayout {
- Layout.fillWidth: true
-
- spacing: 0
-
- StyledText {
- Layout.fillWidth: true
- text: device.modelData ? device.modelData.name : qsTr("Unknown")
- elide: Text.ElideRight
- }
-
- StyledText {
- Layout.fillWidth: true
- text: (device.modelData ? device.modelData.address : "") + (device.connected ? qsTr(" (Connected)") : (device.modelData && device.modelData.bonded) ? qsTr(" (Paired)") : "")
- color: Colours.palette.m3outline
- font.pointSize: Appearance.font.size.small
- elide: Text.ElideRight
- }
- }
-
- StyledRect {
- id: connectBtn
-
- implicitWidth: implicitHeight
- implicitHeight: connectIcon.implicitHeight + Appearance.padding.smaller * 2
-
- radius: Appearance.rounding.full
- color: Qt.alpha(Colours.palette.m3primaryContainer, device.connected ? 1 : 0)
-
- CircularIndicator {
- anchors.fill: parent
- running: device.loading
- }
-
- StateLayer {
- color: device.connected ? Colours.palette.m3onPrimaryContainer : Colours.palette.m3onSurface
- disabled: device.loading
-
- function onClicked(): void {
- if (device.loading)
- return;
-
- if (device.connected) {
- device.modelData.connected = false;
- } else {
- if (device.modelData.bonded) {
- device.modelData.connected = true;
- } else {
- device.modelData.pair();
- }
- }
- }
- }
-
- MaterialIcon {
- id: connectIcon
-
- anchors.centerIn: parent
- animate: true
- text: device.connected ? "link_off" : "link"
- color: device.connected ? Colours.palette.m3onPrimaryContainer : Colours.palette.m3onSurface
-
- opacity: device.loading ? 0 : 1
-
- Behavior on opacity {
- Anim {}
- }
- }
- }
- }
- }
- }
-
- onItemSelected: item => session.bt.active = item
-}
diff --git a/modules/controlcenter/bluetooth/Settings.qml b/modules/controlcenter/bluetooth/Settings.qml
deleted file mode 100644
index c547240..0000000
--- a/modules/controlcenter/bluetooth/Settings.qml
+++ /dev/null
@@ -1,532 +0,0 @@
-pragma ComponentBehavior: Bound
-
-import ".."
-import "../components"
-import qs.components
-import qs.components.controls
-import qs.components.effects
-import qs.services
-import qs.config
-import Quickshell.Bluetooth
-import QtQuick
-import QtQuick.Layouts
-
-ColumnLayout {
- id: root
-
- required property Session session
-
- spacing: Appearance.spacing.normal
-
- SettingsHeader {
- icon: "bluetooth"
- title: qsTr("Bluetooth Settings")
- }
-
- StyledText {
- Layout.topMargin: Appearance.spacing.large
- text: qsTr("Adapter status")
- font.pointSize: Appearance.font.size.larger
- font.weight: 500
- }
-
- StyledText {
- text: qsTr("General adapter settings")
- color: Colours.palette.m3outline
- }
-
- StyledRect {
- Layout.fillWidth: true
- implicitHeight: adapterStatus.implicitHeight + Appearance.padding.large * 2
-
- radius: Appearance.rounding.normal
- color: Colours.tPalette.m3surfaceContainer
-
- ColumnLayout {
- id: adapterStatus
-
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.verticalCenter: parent.verticalCenter
- anchors.margins: Appearance.padding.large
-
- spacing: Appearance.spacing.larger
-
- Toggle {
- label: qsTr("Powered")
- checked: Bluetooth.defaultAdapter?.enabled ?? false
- toggle.onToggled: {
- const adapter = Bluetooth.defaultAdapter;
- if (adapter)
- adapter.enabled = checked;
- }
- }
-
- Toggle {
- label: qsTr("Discoverable")
- checked: Bluetooth.defaultAdapter?.discoverable ?? false
- toggle.onToggled: {
- const adapter = Bluetooth.defaultAdapter;
- if (adapter)
- adapter.discoverable = checked;
- }
- }
-
- Toggle {
- label: qsTr("Pairable")
- checked: Bluetooth.defaultAdapter?.pairable ?? false
- toggle.onToggled: {
- const adapter = Bluetooth.defaultAdapter;
- if (adapter)
- adapter.pairable = checked;
- }
- }
- }
- }
-
- StyledText {
- Layout.topMargin: Appearance.spacing.large
- text: qsTr("Adapter properties")
- font.pointSize: Appearance.font.size.larger
- font.weight: 500
- }
-
- StyledText {
- text: qsTr("Per-adapter settings")
- color: Colours.palette.m3outline
- }
-
- StyledRect {
- Layout.fillWidth: true
- implicitHeight: adapterSettings.implicitHeight + Appearance.padding.large * 2
-
- radius: Appearance.rounding.normal
- color: Colours.tPalette.m3surfaceContainer
-
- ColumnLayout {
- id: adapterSettings
-
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.verticalCenter: parent.verticalCenter
- anchors.margins: Appearance.padding.large
-
- spacing: Appearance.spacing.larger
-
- RowLayout {
- Layout.fillWidth: true
- spacing: Appearance.spacing.normal
-
- StyledText {
- Layout.fillWidth: true
- text: qsTr("Current adapter")
- }
-
- Item {
- id: adapterPickerButton
-
- property bool expanded
-
- implicitWidth: adapterPicker.implicitWidth + Appearance.padding.normal * 2
- implicitHeight: adapterPicker.implicitHeight + Appearance.padding.smaller * 2
-
- StateLayer {
- radius: Appearance.rounding.small
-
- function onClicked(): void {
- adapterPickerButton.expanded = !adapterPickerButton.expanded;
- }
- }
-
- RowLayout {
- id: adapterPicker
-
- anchors.fill: parent
- anchors.margins: Appearance.padding.normal
- anchors.topMargin: Appearance.padding.smaller
- anchors.bottomMargin: Appearance.padding.smaller
- spacing: Appearance.spacing.normal
-
- StyledText {
- Layout.leftMargin: Appearance.padding.small
- text: Bluetooth.defaultAdapter?.name ?? qsTr("None")
- }
-
- MaterialIcon {
- text: "expand_more"
- }
- }
-
- Elevation {
- anchors.fill: adapterListBg
- radius: adapterListBg.radius
- opacity: adapterPickerButton.expanded ? 1 : 0
- scale: adapterPickerButton.expanded ? 1 : 0.7
- level: 2
-
- Behavior on opacity {
- Anim {}
- }
-
- Behavior on scale {
- Anim {
- duration: Appearance.anim.durations.expressiveFastSpatial
- easing.bezierCurve: Appearance.anim.curves.expressiveFastSpatial
- }
- }
- }
-
- StyledClippingRect {
- id: adapterListBg
-
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.bottom: parent.bottom
- implicitHeight: adapterPickerButton.expanded ? adapterList.implicitHeight : adapterPickerButton.implicitHeight
-
- color: Colours.palette.m3secondaryContainer
- radius: Appearance.rounding.small
- opacity: adapterPickerButton.expanded ? 1 : 0
- scale: adapterPickerButton.expanded ? 1 : 0.7
-
- ColumnLayout {
- id: adapterList
-
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.verticalCenter: parent.verticalCenter
-
- spacing: 0
-
- Repeater {
- model: Bluetooth.adapters
-
- Item {
- id: adapter
-
- required property BluetoothAdapter modelData
-
- Layout.fillWidth: true
- implicitHeight: adapterInner.implicitHeight + Appearance.padding.normal * 2
-
- StateLayer {
- disabled: !adapterPickerButton.expanded
-
- function onClicked(): void {
- adapterPickerButton.expanded = false;
- root.session.bt.currentAdapter = adapter.modelData;
- }
- }
-
- RowLayout {
- id: adapterInner
-
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.verticalCenter: parent.verticalCenter
- anchors.margins: Appearance.padding.normal
- spacing: Appearance.spacing.normal
-
- StyledText {
- Layout.fillWidth: true
- Layout.leftMargin: Appearance.padding.small
- text: adapter.modelData.name
- color: Colours.palette.m3onSecondaryContainer
- }
-
- MaterialIcon {
- text: "check"
- color: Colours.palette.m3onSecondaryContainer
- visible: adapter.modelData === root.session.bt.currentAdapter
- }
- }
- }
- }
- }
-
- Behavior on opacity {
- Anim {}
- }
-
- Behavior on scale {
- Anim {
- duration: Appearance.anim.durations.expressiveFastSpatial
- easing.bezierCurve: Appearance.anim.curves.expressiveFastSpatial
- }
- }
-
- Behavior on implicitHeight {
- Anim {
- duration: Appearance.anim.durations.expressiveDefaultSpatial
- easing.bezierCurve: Appearance.anim.curves.expressiveDefaultSpatial
- }
- }
- }
- }
- }
-
- RowLayout {
- Layout.fillWidth: true
- spacing: Appearance.spacing.normal
-
- StyledText {
- Layout.fillWidth: true
- text: qsTr("Discoverable timeout")
- }
-
- CustomSpinBox {
- min: 0
- value: root.session.bt.currentAdapter?.discoverableTimeout ?? 0
- onValueModified: value => {
- if (root.session.bt.currentAdapter) {
- root.session.bt.currentAdapter.discoverableTimeout = value;
- }
- }
- }
- }
-
- RowLayout {
- Layout.fillWidth: true
- spacing: Appearance.spacing.small
-
- Item {
- id: renameAdapter
-
- Layout.fillWidth: true
- Layout.rightMargin: Appearance.spacing.small
-
- implicitHeight: renameLabel.implicitHeight + adapterNameEdit.implicitHeight
-
- states: State {
- name: "editingAdapterName"
- when: root.session.bt.editingAdapterName
-
- AnchorChanges {
- target: adapterNameEdit
- anchors.top: renameAdapter.top
- }
- PropertyChanges {
- renameAdapter.implicitHeight: adapterNameEdit.implicitHeight
- renameLabel.opacity: 0
- adapterNameEdit.padding: Appearance.padding.normal
- }
- }
-
- transitions: Transition {
- AnchorAnimation {
- duration: Appearance.anim.durations.normal
- easing.type: Easing.BezierSpline
- easing.bezierCurve: Appearance.anim.curves.standard
- }
- Anim {
- properties: "implicitHeight,opacity,padding"
- }
- }
-
- StyledText {
- id: renameLabel
-
- anchors.left: parent.left
-
- text: qsTr("Rename adapter (currently does not work)")
- color: Colours.palette.m3outline
- font.pointSize: Appearance.font.size.small
- }
-
- StyledTextField {
- id: adapterNameEdit
-
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.top: renameLabel.bottom
- anchors.leftMargin: root.session.bt.editingAdapterName ? 0 : -Appearance.padding.normal
-
- text: root.session.bt.currentAdapter?.name ?? ""
- readOnly: !root.session.bt.editingAdapterName
- onAccepted: {
- root.session.bt.editingAdapterName = false;
- }
-
- leftPadding: Appearance.padding.normal
- rightPadding: Appearance.padding.normal
-
- background: StyledRect {
- radius: Appearance.rounding.small
- border.width: 2
- border.color: Colours.palette.m3primary
- opacity: root.session.bt.editingAdapterName ? 1 : 0
-
- Behavior on border.color {
- CAnim {}
- }
-
- Behavior on opacity {
- Anim {}
- }
- }
-
- Behavior on anchors.leftMargin {
- Anim {}
- }
- }
- }
-
- StyledRect {
- implicitWidth: implicitHeight
- implicitHeight: cancelEditIcon.implicitHeight + Appearance.padding.smaller * 2
-
- radius: Appearance.rounding.small
- color: Colours.palette.m3secondaryContainer
- opacity: root.session.bt.editingAdapterName ? 1 : 0
- scale: root.session.bt.editingAdapterName ? 1 : 0.5
-
- StateLayer {
- color: Colours.palette.m3onSecondaryContainer
- disabled: !root.session.bt.editingAdapterName
-
- function onClicked(): void {
- root.session.bt.editingAdapterName = false;
- adapterNameEdit.text = Qt.binding(() => root.session.bt.currentAdapter?.name ?? "");
- }
- }
-
- MaterialIcon {
- id: cancelEditIcon
-
- anchors.centerIn: parent
- animate: true
- text: "cancel"
- color: Colours.palette.m3onSecondaryContainer
- }
-
- Behavior on opacity {
- Anim {}
- }
-
- Behavior on scale {
- Anim {
- duration: Appearance.anim.durations.expressiveFastSpatial
- easing.bezierCurve: Appearance.anim.curves.expressiveFastSpatial
- }
- }
- }
-
- StyledRect {
- implicitWidth: implicitHeight
- implicitHeight: editIcon.implicitHeight + Appearance.padding.smaller * 2
-
- radius: root.session.bt.editingAdapterName ? Appearance.rounding.small : implicitHeight / 2 * Math.min(1, Appearance.rounding.scale)
- color: Qt.alpha(Colours.palette.m3primary, root.session.bt.editingAdapterName ? 1 : 0)
-
- StateLayer {
- color: root.session.bt.editingAdapterName ? Colours.palette.m3onPrimary : Colours.palette.m3onSurface
-
- function onClicked(): void {
- root.session.bt.editingAdapterName = !root.session.bt.editingAdapterName;
- if (root.session.bt.editingAdapterName)
- adapterNameEdit.forceActiveFocus();
- else
- adapterNameEdit.accepted();
- }
- }
-
- MaterialIcon {
- id: editIcon
-
- anchors.centerIn: parent
- animate: true
- text: root.session.bt.editingAdapterName ? "check_circle" : "edit"
- color: root.session.bt.editingAdapterName ? Colours.palette.m3onPrimary : Colours.palette.m3onSurface
- }
-
- Behavior on radius {
- Anim {}
- }
- }
- }
- }
- }
-
- StyledText {
- Layout.topMargin: Appearance.spacing.large
- text: qsTr("Adapter information")
- font.pointSize: Appearance.font.size.larger
- font.weight: 500
- }
-
- StyledText {
- text: qsTr("Information about the default adapter")
- color: Colours.palette.m3outline
- }
-
- StyledRect {
- Layout.fillWidth: true
- implicitHeight: adapterInfo.implicitHeight + Appearance.padding.large * 2
-
- radius: Appearance.rounding.normal
- color: Colours.tPalette.m3surfaceContainer
-
- ColumnLayout {
- id: adapterInfo
-
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.verticalCenter: parent.verticalCenter
- anchors.margins: Appearance.padding.large
-
- spacing: Appearance.spacing.small / 2
-
- StyledText {
- text: qsTr("Adapter state")
- }
-
- StyledText {
- text: Bluetooth.defaultAdapter ? BluetoothAdapterState.toString(Bluetooth.defaultAdapter.state) : qsTr("Unknown")
- color: Colours.palette.m3outline
- font.pointSize: Appearance.font.size.small
- }
-
- StyledText {
- Layout.topMargin: Appearance.spacing.normal
- text: qsTr("Dbus path")
- }
-
- StyledText {
- text: Bluetooth.defaultAdapter?.dbusPath ?? ""
- color: Colours.palette.m3outline
- font.pointSize: Appearance.font.size.small
- }
-
- StyledText {
- Layout.topMargin: Appearance.spacing.normal
- text: qsTr("Adapter id")
- }
-
- StyledText {
- text: Bluetooth.defaultAdapter?.adapterId ?? ""
- color: Colours.palette.m3outline
- font.pointSize: Appearance.font.size.small
- }
- }
- }
-
- component Toggle: RowLayout {
- required property string label
- property alias checked: toggle.checked
- property alias toggle: toggle
-
- Layout.fillWidth: true
- spacing: Appearance.spacing.normal
-
- StyledText {
- Layout.fillWidth: true
- text: parent.label
- }
-
- StyledSwitch {
- id: toggle
-
- cLayer: 2
- }
- }
-}