From b35da808ad9128c59601632f8685fb3c65809504 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sun, 3 Aug 2025 21:02:14 +1000 Subject: dcontent: better bt settings --- modules/detachedcontent/bluetooth/BtPane.qml | 2 +- modules/detachedcontent/bluetooth/DeviceList.qml | 148 +++++++++++++++++++---- modules/detachedcontent/bluetooth/Settings.qml | 10 ++ 3 files changed, 136 insertions(+), 24 deletions(-) (limited to 'modules/detachedcontent') diff --git a/modules/detachedcontent/bluetooth/BtPane.qml b/modules/detachedcontent/bluetooth/BtPane.qml index bd48c7d..da18cdf 100644 --- a/modules/detachedcontent/bluetooth/BtPane.qml +++ b/modules/detachedcontent/bluetooth/BtPane.qml @@ -61,7 +61,7 @@ RowLayout { } Anim { property: "scale" - to: 0.7 + to: 0.8 easing.bezierCurve: Appearance.anim.curves.standardAccel } } diff --git a/modules/detachedcontent/bluetooth/DeviceList.qml b/modules/detachedcontent/bluetooth/DeviceList.qml index 26495f1..bbacf30 100644 --- a/modules/detachedcontent/bluetooth/DeviceList.qml +++ b/modules/detachedcontent/bluetooth/DeviceList.qml @@ -19,35 +19,63 @@ ColumnLayout { anchors.fill: parent spacing: Appearance.spacing.small - StyledText { - text: qsTr("Settings") - font.pointSize: Appearance.font.size.large - font.weight: 500 - } + RowLayout { + spacing: Appearance.spacing.smaller - StyledText { - text: qsTr("General bluetooth settings") - color: Colours.palette.m3outline - } + StyledText { + text: qsTr("Settings") + font.pointSize: Appearance.font.size.large + font.weight: 500 + } - StyledRect { - Layout.fillWidth: true - implicitHeight: settingsText.implicitHeight + Appearance.padding.normal * 2 + Item { + Layout.fillWidth: true + } - radius: Appearance.rounding.normal - color: Colours.palette.m3surfaceContainer + ToggleButton { + toggled: Bluetooth.defaultAdapter?.enabled ?? false + icon: "power" + accent: "Tertiary" - StateLayer { function onClicked(): void { - root.session.bt.active = null; + const adapter = Bluetooth.defaultAdapter; + if (adapter) + adapter.enabled = !adapter.enabled; } } - StyledText { - id: settingsText + ToggleButton { + toggled: Bluetooth.defaultAdapter?.discoverable ?? false + icon: QsWindow.window.screen.height <= 1080 ? "group_search" : "" + label: QsWindow.window.screen.height <= 1080 ? "" : qsTr("Discoverable") - anchors.centerIn: parent - text: qsTr("Bluetooth settings") + function onClicked(): void { + const adapter = Bluetooth.defaultAdapter; + if (adapter) + adapter.discoverable = !adapter.discoverable; + } + } + + ToggleButton { + toggled: Bluetooth.defaultAdapter?.pairable ?? false + icon: "missing_controller" + label: QsWindow.window.screen.height <= 960 ? "" : qsTr("Pairable") + + function onClicked(): void { + const adapter = Bluetooth.defaultAdapter; + if (adapter) + adapter.pairable = !adapter.pairable; + } + } + + ToggleButton { + toggled: !root.session.bt.active + icon: "settings" + accent: "Primary" + + function onClicked(): void { + root.session.bt.active = null; + } } } @@ -115,10 +143,11 @@ ColumnLayout { Layout.fillWidth: true Layout.fillHeight: true clip: true + spacing: Appearance.spacing.small / 2 ScrollBar.vertical: StyledScrollBar {} - delegate: Item { + delegate: StyledRect { id: device required property BluetoothDevice modelData @@ -129,11 +158,12 @@ ColumnLayout { anchors.right: parent.right implicitHeight: deviceInner.implicitHeight + Appearance.padding.normal * 2 + color: root.session.bt.active === modelData ? Colours.palette.m3surfaceContainer : "transparent" + radius: Appearance.rounding.normal + StateLayer { id: stateLayer - radius: Appearance.rounding.small - function onClicked(): void { root.session.bt.active = device.modelData; } @@ -246,6 +276,78 @@ ColumnLayout { } } + component ToggleButton: StyledRect { + id: toggleBtn + + required property bool toggled + property string icon + property string label + property string accent: "Secondary" + + function onClicked(): void { + } + + Layout.preferredWidth: implicitWidth + (toggleStateLayer.pressed ? Appearance.padding.larger * 2 : toggled ? Appearance.padding.small * 2 : 0) + implicitWidth: toggleBtnInner.implicitWidth + Appearance.padding.large * 2 + implicitHeight: toggleBtnIcon.implicitHeight + Appearance.padding.normal * 2 + + radius: toggled || toggleStateLayer.pressed ? Appearance.rounding.small : Math.min(width, height) / 2 + color: toggled ? Colours.palette[`m3${accent.toLowerCase()}`] : Colours.palette[`m3${accent.toLowerCase()}Container`] + + StateLayer { + id: toggleStateLayer + + color: toggleBtn.toggled ? Colours.palette[`m3on${toggleBtn.accent}`] : Colours.palette[`m3on${toggleBtn.accent}Container`] + + function onClicked(): void { + toggleBtn.onClicked(); + } + } + + RowLayout { + id: toggleBtnInner + + anchors.centerIn: parent + spacing: Appearance.spacing.normal + + MaterialIcon { + id: toggleBtnIcon + + visible: !!text + fill: toggleBtn.toggled ? 1 : 0 + text: toggleBtn.icon + color: toggleBtn.toggled ? Colours.palette[`m3on${toggleBtn.accent}`] : Colours.palette[`m3on${toggleBtn.accent}Container`] + font.pointSize: Appearance.font.size.large + + Behavior on fill { + Anim {} + } + } + + Loader { + asynchronous: true + active: !!toggleBtn.label + visible: active + + sourceComponent: StyledText { + text: toggleBtn.label + color: toggleBtn.toggled ? Colours.palette[`m3on${toggleBtn.accent}`] : Colours.palette[`m3on${toggleBtn.accent}Container`] + } + } + } + + Behavior on radius { + Anim {} + } + + Behavior on Layout.preferredWidth { + Anim { + duration: Appearance.anim.durations.expressiveFastSpatial + easing.bezierCurve: Appearance.anim.curves.expressiveFastSpatial + } + } + } + component Anim: NumberAnimation { duration: Appearance.anim.durations.normal easing.type: Easing.BezierSpline diff --git a/modules/detachedcontent/bluetooth/Settings.qml b/modules/detachedcontent/bluetooth/Settings.qml index b6f6ca1..663badc 100644 --- a/modules/detachedcontent/bluetooth/Settings.qml +++ b/modules/detachedcontent/bluetooth/Settings.qml @@ -77,6 +77,16 @@ ColumnLayout { adapter.discoverable = checked; } } + + Toggle { + label: qsTr("Pairable") + checked: Bluetooth.defaultAdapter?.pairable ?? false + toggle.onToggled: { + const adapter = Bluetooth.defaultAdapter; + if (adapter) + adapter.pairable = checked; + } + } } } -- cgit v1.2.3-freya