Skip to content

Commit

Permalink
Improve bluetooth disconnecting state
Browse files Browse the repository at this point in the history
  • Loading branch information
emericg committed Apr 15, 2024
1 parent 130ff66 commit 1fbfb0a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 41 deletions.
50 changes: 20 additions & 30 deletions qml/components/ButtonScanMenu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,10 @@ T.Button {

// icon
property url source: {
if (!selectedDevice) return ""
if (selectedDevice.status === DeviceUtils.DEVICE_OFFLINE)
return "qrc:/assets/icons_material/baseline-bluetooth-24px.svg"
else if (selectedDevice.status <= DeviceUtils.DEVICE_CONNECTING)
return "qrc:/assets/icons_material/duotone-bluetooth_searching-24px.svg"
else if (selectedDevice.status === DeviceUtils.DEVICE_WORKING)
return "qrc:/assets/icons_material/duotone-bluetooth_searching-24px.svg"
else
return "qrc:/assets/icons_material/duotone-bluetooth_connected-24px.svg"
if (!selectedDevice || selectedDevice.status === DeviceUtils.DEVICE_OFFLINE)
return "qrc:/assets/icons/material-icons/outlined/bluetooth.svg"

return getDeviceStatusIcon(selectedDevice.status)
}
property int sourceSize: UtilsNumber.alignTo(height * 0.666, 2)

Expand All @@ -49,14 +44,11 @@ T.Button {

text: {
if (!selectedDevice) return ""
if (selectedDevice.status === DeviceUtils.DEVICE_OFFLINE)
return qsTr("scan device")
else if (selectedDevice.status === DeviceUtils.DEVICE_WORKING)
return qsTr("scanning...")
else if (selectedDevice.status >= DeviceUtils.DEVICE_CONNECTED)
return qsTr("connected")
else if (selectedDevice.status <= DeviceUtils.DEVICE_CONNECTING)
return qsTr("connecting...")
if (selectedDevice.status === DeviceUtils.DEVICE_OFFLINE) return qsTr("scan device")
if (selectedDevice.status === DeviceUtils.DEVICE_DISCONNECTING) return qsTr("disconnecting...")
if (selectedDevice.status === DeviceUtils.DEVICE_CONNECTING) return qsTr("connecting...")
if (selectedDevice.status === DeviceUtils.DEVICE_WORKING) return qsTr("scanning...")
if (selectedDevice.status >= DeviceUtils.DEVICE_CONNECTED) return qsTr("connected")
}

////////////////
Expand Down Expand Up @@ -378,25 +370,23 @@ T.Button {

text: {
if (!selectedDevice) return ""
if (selectedDevice.status === DeviceUtils.DEVICE_OFFLINE)
return qsTr("scan device")
else if (selectedDevice.status === DeviceUtils.DEVICE_WORKING)
return qsTr("scanning...")
else if (selectedDevice.status >= DeviceUtils.DEVICE_CONNECTED)
return qsTr("connected")
else if (selectedDevice.status <= DeviceUtils.DEVICE_CONNECTING)
return qsTr("connecting...")
if (selectedDevice.status === DeviceUtils.DEVICE_OFFLINE) return qsTr("scan device")
if (selectedDevice.status === DeviceUtils.DEVICE_WORKING) return qsTr("scanning...")
if (selectedDevice.status === DeviceUtils.DEVICE_DISCONNECTING) return qsTr("disconnecting...")
if (selectedDevice.status === DeviceUtils.DEVICE_CONNECTING) return qsTr("connecting...")
if (selectedDevice.status >= DeviceUtils.DEVICE_CONNECTED) return qsTr("connected")
}
source: {
if (!selectedDevice) return ""
if (selectedDevice.status === DeviceUtils.DEVICE_OFFLINE)
return "qrc:/assets/icons_material/baseline-bluetooth-24px.svg"
else if (selectedDevice.status <= DeviceUtils.DEVICE_CONNECTING)
return "qrc:/assets/icons_material/duotone-bluetooth_searching-24px.svg"
return "qrc:/assets/icons/material-icons/outlined/bluetooth.svg"
else if (selectedDevice.status <= DeviceUtils.DEVICE_DISCONNECTING ||
selectedDevice.status <= DeviceUtils.DEVICE_CONNECTING)
return "qrc:/assets/icons/material-icons/duotone/bluetooth_searching.svg"
else if (selectedDevice.status === DeviceUtils.DEVICE_WORKING)
return "qrc:/assets/icons_material/duotone-bluetooth_searching-24px.svg"
return "qrc:/assets/icons/material-icons/duotone/bluetooth_searching.svg"
else
return "qrc:/assets/icons_material/duotone-bluetooth_connected-24px.svg"
return "qrc:/assets/icons/material-icons/duotone/bluetooth_connected.svg"
}

onClicked: {
Expand Down
22 changes: 11 additions & 11 deletions qml/components_js/UtilsDeviceSensors.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// UtilsDeviceSensors.js
// Version -1
// Version 5

.import DeviceUtils 1.0 as DeviceUtils
.import ThemeEngine 1.0 as ThemeEngine
.import DeviceUtils as DeviceUtils
.import ThemeEngine as ThemeEngine

/* ************************************************************************** */

Expand Down Expand Up @@ -55,21 +55,21 @@ function getDeviceStatusColor(deviceStatus) {
}

function getDeviceStatusIcon(deviceStatus) {
var src = "qrc:/assets/icons_material/baseline-bluetooth-24px.svg"
var src = "qrc:/assets/icons/material-icons/outlined/bluetooth.svg"

if (deviceStatus === DeviceUtils.DeviceUtils.DEVICE_OFFLINE) {
src = "qrc:/assets/icons_material/baseline-bluetooth_disabled-24px.svg"
} else if (deviceStatus === DeviceUtils.DeviceUtils.DEVICE_QUEUED) {
src = "qrc:/assets/icons_material/duotone-settings_bluetooth-24px.svg"
} else if (deviceStatus === DeviceUtils.DeviceUtils.DEVICE_CONNECTING) {
src = "qrc:/assets/icons_material/duotone-bluetooth_searching-24px.svg"
src = "qrc:/assets/icons/material/bluetooth_disabled.svg"
} else if (deviceStatus === DeviceUtils.DeviceUtils.DEVICE_QUEUED ||
deviceStatus === DeviceUtils.DeviceUtils.DEVICE_DISCONNECTING ||
deviceStatus === DeviceUtils.DeviceUtils.DEVICE_CONNECTING) {
src = "qrc:/assets/icons/material-icons/duotone/settings_bluetooth.svg"
} else if (deviceStatus === DeviceUtils.DeviceUtils.DEVICE_CONNECTED) {
src = "qrc:/assets/icons_material/duotone-bluetooth_connected-24px.svg"
src = "qrc:/assets/icons/material-icons/duotone/bluetooth_connected.svg"
} else if (deviceStatus === DeviceUtils.DeviceUtils.DEVICE_WORKING ||
deviceStatus === DeviceUtils.DeviceUtils.DEVICE_UPDATING ||
deviceStatus === DeviceUtils.DeviceUtils.DEVICE_UPDATING_HISTORY ||
deviceStatus === DeviceUtils.DeviceUtils.DEVICE_UPDATING_REALTIME) {
src = "qrc:/assets/icons_material/duotone-settings_bluetooth-24px.svg"
src = "qrc:/assets/icons/material-icons/duotone/bluetooth_searching.svg"
}

return src
Expand Down

0 comments on commit 1fbfb0a

Please sign in to comment.