dcontent: better bt settings
This commit is contained in:
parent
baf04ec30f
commit
b35da808ad
3 changed files with 136 additions and 24 deletions
|
|
@ -61,7 +61,7 @@ RowLayout {
|
||||||
}
|
}
|
||||||
Anim {
|
Anim {
|
||||||
property: "scale"
|
property: "scale"
|
||||||
to: 0.7
|
to: 0.8
|
||||||
easing.bezierCurve: Appearance.anim.curves.standardAccel
|
easing.bezierCurve: Appearance.anim.curves.standardAccel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,35 +19,63 @@ ColumnLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
spacing: Appearance.spacing.small
|
spacing: Appearance.spacing.small
|
||||||
|
|
||||||
StyledText {
|
RowLayout {
|
||||||
text: qsTr("Settings")
|
spacing: Appearance.spacing.smaller
|
||||||
font.pointSize: Appearance.font.size.large
|
|
||||||
font.weight: 500
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
text: qsTr("General bluetooth settings")
|
text: qsTr("Settings")
|
||||||
color: Colours.palette.m3outline
|
font.pointSize: Appearance.font.size.large
|
||||||
}
|
font.weight: 500
|
||||||
|
}
|
||||||
|
|
||||||
StyledRect {
|
Item {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
implicitHeight: settingsText.implicitHeight + Appearance.padding.normal * 2
|
}
|
||||||
|
|
||||||
radius: Appearance.rounding.normal
|
ToggleButton {
|
||||||
color: Colours.palette.m3surfaceContainer
|
toggled: Bluetooth.defaultAdapter?.enabled ?? false
|
||||||
|
icon: "power"
|
||||||
|
accent: "Tertiary"
|
||||||
|
|
||||||
StateLayer {
|
|
||||||
function onClicked(): void {
|
function onClicked(): void {
|
||||||
root.session.bt.active = null;
|
const adapter = Bluetooth.defaultAdapter;
|
||||||
|
if (adapter)
|
||||||
|
adapter.enabled = !adapter.enabled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
ToggleButton {
|
||||||
id: settingsText
|
toggled: Bluetooth.defaultAdapter?.discoverable ?? false
|
||||||
|
icon: QsWindow.window.screen.height <= 1080 ? "group_search" : ""
|
||||||
|
label: QsWindow.window.screen.height <= 1080 ? "" : qsTr("Discoverable")
|
||||||
|
|
||||||
anchors.centerIn: parent
|
function onClicked(): void {
|
||||||
text: qsTr("Bluetooth settings")
|
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.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
clip: true
|
clip: true
|
||||||
|
spacing: Appearance.spacing.small / 2
|
||||||
|
|
||||||
ScrollBar.vertical: StyledScrollBar {}
|
ScrollBar.vertical: StyledScrollBar {}
|
||||||
|
|
||||||
delegate: Item {
|
delegate: StyledRect {
|
||||||
id: device
|
id: device
|
||||||
|
|
||||||
required property BluetoothDevice modelData
|
required property BluetoothDevice modelData
|
||||||
|
|
@ -129,11 +158,12 @@ ColumnLayout {
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
implicitHeight: deviceInner.implicitHeight + Appearance.padding.normal * 2
|
implicitHeight: deviceInner.implicitHeight + Appearance.padding.normal * 2
|
||||||
|
|
||||||
|
color: root.session.bt.active === modelData ? Colours.palette.m3surfaceContainer : "transparent"
|
||||||
|
radius: Appearance.rounding.normal
|
||||||
|
|
||||||
StateLayer {
|
StateLayer {
|
||||||
id: stateLayer
|
id: stateLayer
|
||||||
|
|
||||||
radius: Appearance.rounding.small
|
|
||||||
|
|
||||||
function onClicked(): void {
|
function onClicked(): void {
|
||||||
root.session.bt.active = device.modelData;
|
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 {
|
component Anim: NumberAnimation {
|
||||||
duration: Appearance.anim.durations.normal
|
duration: Appearance.anim.durations.normal
|
||||||
easing.type: Easing.BezierSpline
|
easing.type: Easing.BezierSpline
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,16 @@ ColumnLayout {
|
||||||
adapter.discoverable = checked;
|
adapter.discoverable = checked;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Toggle {
|
||||||
|
label: qsTr("Pairable")
|
||||||
|
checked: Bluetooth.defaultAdapter?.pairable ?? false
|
||||||
|
toggle.onToggled: {
|
||||||
|
const adapter = Bluetooth.defaultAdapter;
|
||||||
|
if (adapter)
|
||||||
|
adapter.pairable = checked;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue