diff --git a/qml/DeviceBrowser.qml b/qml/DeviceBrowser.qml index 764358d..4dacf94 100644 --- a/qml/DeviceBrowser.qml +++ b/qml/DeviceBrowser.qml @@ -96,12 +96,18 @@ Item { border.color: Theme.colorSeparator border.width: 1 + MouseArea { + anchors.fill: parent + onClicked: parent.visible = false + } + IconSvg { width: 28 height: 28 + anchors.top: parent.top + anchors.topMargin: 8 anchors.left: parent.left anchors.leftMargin: 8 - anchors.verticalCenter: parent.verticalCenter source: "qrc:/assets/icons_material/outline-info-24px.svg" color: Theme.colorIcon @@ -116,7 +122,7 @@ Item { anchors.right: parent.right anchors.rightMargin: 8 - text: qsTr("The device browser help you locate nearby BLE devices.") + text: qsTr("The device browser help you locate nearby BLE devices. You can also use this screen to blacklist sensors so the scan don't pick them up.") textFormat: Text.StyledText wrapMode: Text.WordWrap color: Theme.colorSubText @@ -192,6 +198,11 @@ Item { border.color: Theme.colorSeparator border.width: 1 + MouseArea { + anchors.fill: parent + onClicked: parent.visible = false + } + IconSvg { width: 28 height: 28 @@ -212,7 +223,7 @@ Item { anchors.right: parent.right anchors.rightMargin: 8 - text: qsTr("The device browser help you locate nearby BLE devices.") + text: qsTr("The device browser help you locate nearby BLE devices. You can also use this screen to blacklist sensors so the scan don't pick them up.") textFormat: Text.StyledText wrapMode: Text.WordWrap color: Theme.colorSubText @@ -326,7 +337,7 @@ Item { property real alpha: Math.random() * (3.14/2) + (3.14/4) property real a: c * Math.cos(alpha) property real b: c * Math.sin(alpha) - property real c: radar.height * Math.abs(((boxDevice.rssi)+10) / 100) + property real c: radar.height * Math.abs(((boxDevice.rssi)+12) / 100) x: (radar.width / 2) - a y: radar.height - b @@ -350,15 +361,9 @@ Item { } color: { - if (boxDevice.rssi < 0) { - if (boxDevice.rssi > -65) return Theme.colorGreen - if (boxDevice.rssi > -85) return Theme.colorOrange - if (boxDevice.rssi > -100) return Theme.colorRed - } else { - if (boxDevice.rssi < 65) return Theme.colorGreen - if (boxDevice.rssi < 85) return Theme.colorOrange - if (boxDevice.rssi < 100) return Theme.colorRed - } + if (Math.abs(boxDevice.rssi) < 65) return Theme.colorGreen + if (Math.abs(boxDevice.rssi) < 85) return Theme.colorOrange + if (Math.abs(boxDevice.rssi) < 100) return Theme.colorRed return Theme.colorRed } diff --git a/qml/DeviceNearbyWidget.qml b/qml/DeviceNearbyWidget.qml index d12b82c..d568fe1 100644 --- a/qml/DeviceNearbyWidget.qml +++ b/qml/DeviceNearbyWidget.qml @@ -5,14 +5,14 @@ import "qrc:/js/UtilsDeviceSensors.js" as UtilsDeviceSensors Rectangle { id: deviceNearbyWidget - implicitWidth: 640 + implicitWidth: 480 implicitHeight: 48 opacity: (device.rssi < 0) ? 1 : 0.66 color: (device.selected) ? Theme.colorForeground : Theme.colorBackground property var device: pointer - property bool deviceSupported: UtilsDeviceSensors.isDeviceSupported(device.deviceName) + property bool deviceSupported: true // UtilsDeviceSensors.isDeviceSupported(device.deviceName) property bool deviceBlacklisted: deviceManager.isBleDeviceBlacklisted(device.deviceAddress) Connections { @@ -63,6 +63,42 @@ Rectangle { //////// + IconSvg { + anchors.verticalCenter: parent.verticalCenter + + width: 20 + height: 20 + visible: deviceSupported + enabled: true + + source: deviceBlacklisted ? "qrc:/assets/icons_material/outline-remove_circle-24px.svg" + : "qrc:/assets/icons_material/outline-add_circle-24px.svg" + color: { + if (ma.hovered) return Theme.colorPrimary + if (deviceBlacklisted) return Theme.colorRed + return Theme.colorIcon + } + + MouseArea { + id: ma + anchors.fill: parent + + hoverEnabled: true + property bool hovered: false + onEntered: hovered = true + onExited: hovered = false + onCanceled: hovered = false + + onClicked: { + confirmBlacklistDevice.deviceName = device.deviceName + confirmBlacklistDevice.deviceAddress = device.deviceAddress + confirmBlacklistDevice.open() + } + } + } + + //////// + Rectangle { id: barbg anchors.verticalCenter: parent.verticalCenter @@ -79,15 +115,9 @@ Rectangle { width: parent.width * Math.abs(device.rssi / 100) radius: 3 color: { - if (device.rssi < 0) { - if (device.rssi > -65) return Theme.colorGreen - if (device.rssi > -85) return Theme.colorOrange - if (device.rssi > -100) return Theme.colorRed - } else { - if (device.rssi < 65) return Theme.colorGreen - if (device.rssi < 85) return Theme.colorOrange - if (device.rssi < 100) return Theme.colorRed - } + if (Math.abs(device.rssi) < 65) return Theme.colorGreen + if (Math.abs(device.rssi) < 85) return Theme.colorOrange + if (Math.abs(device.rssi) < 100) return Theme.colorRed return Theme.colorRed } diff --git a/src/DeviceManager.cpp b/src/DeviceManager.cpp index 80b644b..9d3968a 100644 --- a/src/DeviceManager.cpp +++ b/src/DeviceManager.cpp @@ -1324,14 +1324,13 @@ void DeviceManager::addBleDevice(const QBluetoothDeviceInfo &info) // Various sanity checks { if (info.rssi() >= 0) return; // we probably just hit the device cache - + if (info.isCached()) return; // we probably just hit the device cache + if ((info.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration) == false) return; // not a BLE device if (m_devices_blacklist.contains(info.address().toString())) return; // device is blacklisted SettingsManager *sm = SettingsManager::getInstance(); if (sm && sm->getBluetoothLimitScanningRange() && info.rssi() < -70) return; // device is too far away - if ((info.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration) == false) return; // not a BLE device - for (auto ed: qAsConst(m_devices_model->m_devices)) // device is already in the UI { Device *edd = qobject_cast(ed); diff --git a/src/DeviceManager_advertisement.cpp b/src/DeviceManager_advertisement.cpp index cb805ae..82c73d3 100644 --- a/src/DeviceManager_advertisement.cpp +++ b/src/DeviceManager_advertisement.cpp @@ -42,9 +42,12 @@ void DeviceManager::updateBleDevice(const QBluetoothDeviceInfo &info, //qDebug() << "updateBleDevice() " << info.name() << info.address(); // << info.deviceUuid() // << " updatedFields: " << updatedFields bool status = false; - // We don't use QBluetoothDeviceInfo::Fields, it's unreliable - Q_UNUSED(updatedFields) + Q_UNUSED(updatedFields) // We don't use QBluetoothDeviceInfo::Fields, it's unreliable + if (info.rssi() >= 0) return; // we probably just hit the device cache + if (info.isCached()) return; // we probably just hit the device cache + if ((info.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration) == false) return; // not a BLE device + if (m_devices_blacklist.contains(info.address().toString())) return; // device is blacklisted //if (info.name().isEmpty()) return; // skip beacons if (info.name().replace('-', ':') == info.address().toString()) return; // skip beacons