BT Menu
This commit is contained in:
parent
d2acdd1c19
commit
32b6a363af
1 changed files with 276 additions and 251 deletions
|
|
@ -71,7 +71,7 @@ NLoader {
|
||||||
radius: Style.radiusLarge * scaling
|
radius: Style.radiusLarge * scaling
|
||||||
border.color: Color.mOutlineVariant
|
border.color: Color.mOutlineVariant
|
||||||
border.width: Math.max(1, Style.borderThin * scaling)
|
border.width: Math.max(1, Style.borderThin * scaling)
|
||||||
width: 400 * scaling
|
width: 380 * scaling
|
||||||
height: 500 * scaling
|
height: 500 * scaling
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
|
@ -159,6 +159,15 @@ NLoader {
|
||||||
|
|
||||||
NDivider {}
|
NDivider {}
|
||||||
|
|
||||||
|
ScrollView {
|
||||||
|
id: scrollView
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
clip: true
|
||||||
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
||||||
|
ScrollBar.vertical.policy: ScrollBar.AsNeeded
|
||||||
|
|
||||||
// Available devices
|
// Available devices
|
||||||
Column {
|
Column {
|
||||||
id: column
|
id: column
|
||||||
|
|
@ -167,7 +176,6 @@ NLoader {
|
||||||
spacing: Style.marginMedium * scaling
|
spacing: Style.marginMedium * scaling
|
||||||
visible: BluetoothService.adapter && BluetoothService.adapter.enabled
|
visible: BluetoothService.adapter && BluetoothService.adapter.enabled
|
||||||
|
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
spacing: Style.marginMedium * scaling
|
spacing: Style.marginMedium * scaling
|
||||||
|
|
@ -177,7 +185,6 @@ NLoader {
|
||||||
font.pointSize: Style.fontSizeLarge * scaling
|
font.pointSize: Style.fontSizeLarge * scaling
|
||||||
color: Color.mOnSurface
|
color: Color.mOnSurface
|
||||||
font.weight: Style.fontWeightMedium
|
font.weight: Style.fontWeightMedium
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -203,26 +210,18 @@ NLoader {
|
||||||
radius: Style.radiusMedium * scaling
|
radius: Style.radiusMedium * scaling
|
||||||
color: {
|
color: {
|
||||||
if (availableDeviceArea.containsMouse && !isBusy)
|
if (availableDeviceArea.containsMouse && !isBusy)
|
||||||
return Qt.rgba(Color.mPrimary.r, Color.mPrimary.g, Color.mPrimary.b, 0.08)
|
return Color.mTertiary
|
||||||
|
|
||||||
if (modelData.pairing || modelData.state === BluetoothDeviceState.Connecting)
|
if (modelData.pairing || modelData.state === BluetoothDeviceState.Connecting)
|
||||||
return Qt.rgba(Color.mError.r, Color.mError.g, Color.mError.b, 0.12)
|
return Color.mPrimary
|
||||||
|
|
||||||
if (modelData.blocked)
|
if (modelData.blocked)
|
||||||
return Color.mError
|
return Color.mError
|
||||||
|
|
||||||
return Color.mSurfaceVariant
|
return Color.mSurfaceVariant
|
||||||
}
|
}
|
||||||
border.color: {
|
border.color: Color.mOutline
|
||||||
if (modelData.pairing)
|
border.width: Math.max(1, Style.borderThin * scaling)
|
||||||
return Color.mError
|
|
||||||
|
|
||||||
if (modelData.blocked)
|
|
||||||
return Color.mError
|
|
||||||
|
|
||||||
return Color.mOutline
|
|
||||||
}
|
|
||||||
border.width: 1
|
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
|
|
@ -230,16 +229,20 @@ NLoader {
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
spacing: Style.marginSmall * scaling
|
spacing: Style.marginSmall * scaling
|
||||||
|
|
||||||
|
// One device BT icon
|
||||||
NText {
|
NText {
|
||||||
text: BluetoothService.getDeviceIcon(modelData)
|
text: BluetoothService.getDeviceIcon(modelData)
|
||||||
font.family: "Material Symbols Outlined"
|
font.family: "Material Symbols Outlined"
|
||||||
font.pointSize: Style.fontSizeXL * scaling
|
font.pointSize: Style.fontSizeXL * scaling
|
||||||
color: {
|
color: {
|
||||||
if (modelData.pairing)
|
if (availableDeviceArea.containsMouse)
|
||||||
return Color.mError
|
return Color.mOnTertiary
|
||||||
|
|
||||||
|
if (modelData.pairing || modelData.state === BluetoothDeviceState.Connecting)
|
||||||
|
return Color.mOnPrimary
|
||||||
|
|
||||||
if (modelData.blocked)
|
if (modelData.blocked)
|
||||||
return Color.mError
|
return Color.mOnError
|
||||||
|
|
||||||
return Color.mOnSurface
|
return Color.mOnSurface
|
||||||
}
|
}
|
||||||
|
|
@ -247,22 +250,27 @@ NLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
spacing: 2
|
spacing: Style.marginTiniest * scaling
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
||||||
|
// One device name
|
||||||
NText {
|
NText {
|
||||||
text: modelData.name || modelData.deviceName
|
text: modelData.name || modelData.deviceName
|
||||||
font.pointSize: Style.fonttSizeMedium * scaling
|
font.pointSize: Style.fonttSizeMedium * scaling
|
||||||
|
elide: Text.ElideRight
|
||||||
color: {
|
color: {
|
||||||
if (modelData.pairing)
|
if (availableDeviceArea.containsMouse)
|
||||||
return Color.mError
|
return Color.mOnTertiary
|
||||||
|
|
||||||
|
if (modelData.pairing || modelData.state === BluetoothDeviceState.Connecting)
|
||||||
|
return Color.mOnPrimary
|
||||||
|
|
||||||
if (modelData.blocked)
|
if (modelData.blocked)
|
||||||
return Color.mError
|
return Color.mOnError
|
||||||
|
|
||||||
return Color.mOnSurface
|
return Color.mOnSurface
|
||||||
}
|
}
|
||||||
font.weight: modelData.pairing ? Style.fontWeightMedium : Font.Normal
|
font.weight: Style.fontWeightMedium
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
|
|
@ -271,6 +279,7 @@ NLoader {
|
||||||
Row {
|
Row {
|
||||||
spacing: Style.marginSmall * spacing
|
spacing: Style.marginSmall * spacing
|
||||||
|
|
||||||
|
// One device signal strength - "Unknown" when not connected
|
||||||
NText {
|
NText {
|
||||||
text: {
|
text: {
|
||||||
if (modelData.pairing)
|
if (modelData.pairing)
|
||||||
|
|
@ -283,13 +292,16 @@ NLoader {
|
||||||
}
|
}
|
||||||
font.pointSize: Style.fontSizeSmall * scaling
|
font.pointSize: Style.fontSizeSmall * scaling
|
||||||
color: {
|
color: {
|
||||||
if (modelData.pairing)
|
if (availableDeviceArea.containsMouse)
|
||||||
return Color.mError
|
return Color.mOnTertiary
|
||||||
|
|
||||||
|
if (modelData.pairing || modelData.state === BluetoothDeviceState.Connecting)
|
||||||
|
return Color.mOnPrimary
|
||||||
|
|
||||||
if (modelData.blocked)
|
if (modelData.blocked)
|
||||||
return Theme.error
|
return Color.mOnError
|
||||||
|
|
||||||
return Qt.rgba(Color.mOnSurface.r, Color.mOnSurface.g, Color.mOnSurface.b, 0.7)
|
return Color.mOnSurface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -297,7 +309,18 @@ NLoader {
|
||||||
text: BluetoothService.getSignalIcon(modelData)
|
text: BluetoothService.getSignalIcon(modelData)
|
||||||
font.family: "Material Symbols Outlined"
|
font.family: "Material Symbols Outlined"
|
||||||
font.pointSize: Style.fontSizeSmall * scaling
|
font.pointSize: Style.fontSizeSmall * scaling
|
||||||
color: Qt.rgba(Color.mOnSurface.r, Color.mOnSurface.g, Color.mOnSurface.b, 0.7)
|
color: {
|
||||||
|
if (availableDeviceArea.containsMouse)
|
||||||
|
return Color.mOnTertiary
|
||||||
|
|
||||||
|
if (modelData.pairing || modelData.state === BluetoothDeviceState.Connecting)
|
||||||
|
return Color.mOnPrimary
|
||||||
|
|
||||||
|
if (modelData.blocked)
|
||||||
|
return Color.mOnError
|
||||||
|
|
||||||
|
return Color.mOnSurface
|
||||||
|
}
|
||||||
visible: modelData.signalStrength !== undefined && modelData.signalStrength > 0
|
visible: modelData.signalStrength !== undefined && modelData.signalStrength > 0
|
||||||
&& !modelData.pairing && !modelData.blocked
|
&& !modelData.pairing && !modelData.blocked
|
||||||
}
|
}
|
||||||
|
|
@ -306,7 +329,18 @@ NLoader {
|
||||||
text: (modelData.signalStrength !== undefined
|
text: (modelData.signalStrength !== undefined
|
||||||
&& modelData.signalStrength > 0) ? modelData.signalStrength + "%" : ""
|
&& modelData.signalStrength > 0) ? modelData.signalStrength + "%" : ""
|
||||||
font.pointSize: Style.fontSizeSmall * scaling
|
font.pointSize: Style.fontSizeSmall * scaling
|
||||||
color: Qt.rgba(Color.mOnSurface.r, Color.mOnSurface.g, Color.mOnSurface.b, 0.5)
|
color: {
|
||||||
|
if (availableDeviceArea.containsMouse)
|
||||||
|
return Color.mOnTertiary
|
||||||
|
|
||||||
|
if (modelData.pairing || modelData.state === BluetoothDeviceState.Connecting)
|
||||||
|
return Color.mOnPrimary
|
||||||
|
|
||||||
|
if (modelData.blocked)
|
||||||
|
return Color.mOnError
|
||||||
|
|
||||||
|
return Color.mOnSurface
|
||||||
|
}
|
||||||
visible: modelData.signalStrength !== undefined && modelData.signalStrength > 0
|
visible: modelData.signalStrength !== undefined && modelData.signalStrength > 0
|
||||||
&& !modelData.pairing && !modelData.blocked
|
&& !modelData.pairing && !modelData.blocked
|
||||||
}
|
}
|
||||||
|
|
@ -316,27 +350,26 @@ NLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
width: 80
|
width: 80 * scaling
|
||||||
height: 28
|
height: 28 * scaling
|
||||||
radius: Style.radiusMedium * scaling
|
radius: Style.radiusMedium * scaling
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.rightMargin: Style.marginMedium * scaling
|
anchors.rightMargin: Style.marginMedium * scaling
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
visible: modelData.state !== BluetoothDeviceState.Connecting
|
visible: modelData.state !== BluetoothDeviceState.Connecting
|
||||||
color: {
|
color: Color.transparent
|
||||||
if (!canConnect && !isBusy)
|
|
||||||
return Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.3)
|
|
||||||
|
|
||||||
if (actionButtonArea.containsMouse && !isBusy)
|
border.color: {
|
||||||
return Qt.rgba(Color.mPrimary.r, Color.mPrimary.g, Color.mPrimary.b, 0.12)
|
if (availableDeviceArea.containsMouse) {
|
||||||
|
return Color.mOnTertiary
|
||||||
return "transparent"
|
} else {
|
||||||
|
return Color.mPrimary
|
||||||
}
|
}
|
||||||
border.color: canConnect || isBusy ? Color.mPrimary : Qt.rgba(Theme.outline.r, Theme.outline.g,
|
}
|
||||||
Theme.outline.b, 0.2)
|
border.width: Math.max(1, Style.borderThin * scaling)
|
||||||
border.width: 1
|
|
||||||
opacity: canConnect || isBusy ? 1 : 0.5
|
opacity: canConnect || isBusy ? 1 : 0.5
|
||||||
|
|
||||||
|
// On device connect button
|
||||||
NText {
|
NText {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text: {
|
text: {
|
||||||
|
|
@ -349,13 +382,19 @@ NLoader {
|
||||||
return "Connect"
|
return "Connect"
|
||||||
}
|
}
|
||||||
font.pointSize: Style.fontSizeSmall * scaling
|
font.pointSize: Style.fontSizeSmall * scaling
|
||||||
color: canConnect || isBusy ? Color.mPrimary : Qt.rgba(Color.mOnSurface.r, Color.mOnSurface.g,
|
|
||||||
Color.mOnSurface.b, 0.5)
|
|
||||||
font.weight: Style.fontWeightMedium
|
font.weight: Style.fontWeightMedium
|
||||||
|
color: {
|
||||||
|
if (availableDeviceArea.containsMouse) {
|
||||||
|
return Color.mOnTertiary
|
||||||
|
} else {
|
||||||
|
return Color.mPrimary
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: actionButtonArea
|
id: availableDeviceArea
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
|
|
@ -368,23 +407,9 @@ NLoader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: availableDeviceArea
|
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.rightMargin: 90
|
|
||||||
hoverEnabled: true
|
|
||||||
cursorShape: canConnect && !isBusy ? Qt.PointingHandCursor : (isBusy ? Qt.BusyCursor : Qt.ArrowCursor)
|
|
||||||
enabled: canConnect && !isBusy
|
|
||||||
onClicked: {
|
|
||||||
if (modelData)
|
|
||||||
BluetoothService.connectDeviceWithTrust(modelData)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fallback if nothing available
|
||||||
Column {
|
Column {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
spacing: Style.marginMedium * scaling
|
spacing: Style.marginMedium * scaling
|
||||||
|
|
@ -408,7 +433,7 @@ NLoader {
|
||||||
NText {
|
NText {
|
||||||
text: "sync"
|
text: "sync"
|
||||||
font.family: "Material Symbols Outlined"
|
font.family: "Material Symbols Outlined"
|
||||||
font.pointSize: 32 * scaling
|
font.pointSize: Style.fontSizeXLL * 1.5 * scaling
|
||||||
color: Color.mPrimary
|
color: Color.mPrimary
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
||||||
|
|
@ -433,7 +458,7 @@ NLoader {
|
||||||
NText {
|
NText {
|
||||||
text: "Make sure your device is in pairing mode"
|
text: "Make sure your device is in pairing mode"
|
||||||
font.pointSize: Style.fontSizeMedium * scaling
|
font.pointSize: Style.fontSizeMedium * scaling
|
||||||
color: Qt.rgba(Color.mOnSurface.r, Color.mOnSurface.g, Color.mOnSurface.b, 0.7)
|
color: Color.mOnSurfaceVariant
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -441,7 +466,7 @@ NLoader {
|
||||||
NText {
|
NText {
|
||||||
text: "No devices found. Put your device in pairing mode and click Start Scanning."
|
text: "No devices found. Put your device in pairing mode and click Start Scanning."
|
||||||
font.pointSize: Style.fontSizeMedium * scaling
|
font.pointSize: Style.fontSizeMedium * scaling
|
||||||
color: Qt.rgba(Color.mOnSurface.r, Color.mOnSurface.g, Color.mOnSurface.b, 0.7)
|
color: Color.mOnSurfaceVariant
|
||||||
visible: {
|
visible: {
|
||||||
if (!BluetoothService.adapter || !Bluetooth.devices)
|
if (!BluetoothService.adapter || !Bluetooth.devices)
|
||||||
return true
|
return true
|
||||||
|
|
@ -459,7 +484,7 @@ NLoader {
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// This item takes up all the remaining vertical space.
|
// This item takes up all the remaining vertical space.
|
||||||
Item {
|
Item {
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue