Some more fixes in the bluetooth discovery

pull/732/head
Michael Zanetti 2021-12-15 17:43:20 +01:00
parent a8abdff274
commit bd0ef7da74
3 changed files with 13 additions and 13 deletions

View File

@ -124,11 +124,10 @@ bool BluetoothDiscovery::discovering() const
void BluetoothDiscovery::setDiscoveryEnabled(bool discoveryEnabled)
{
if (m_discoveryEnabled == discoveryEnabled) {
return;
if (m_discoveryEnabled != discoveryEnabled) {
m_discoveryEnabled = discoveryEnabled;
emit discoveryEnabledChanged(m_discoveryEnabled);
}
m_discoveryEnabled = discoveryEnabled;
emit discoveryEnabledChanged(m_discoveryEnabled);
if (m_discoveryEnabled) {
start();
@ -171,6 +170,9 @@ void BluetoothDiscovery::onBluetoothHostModeChanged(const QBluetoothLocalDevice:
m_discoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);
#endif
connect(m_discoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, this, &BluetoothDiscovery::deviceDiscovered);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
connect(m_discoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceUpdated, this, &BluetoothDiscovery::deviceDiscovered);
#endif
connect(m_discoveryAgent, &QBluetoothDeviceDiscoveryAgent::finished, this, &BluetoothDiscovery::discoveryFinished);
connect(m_discoveryAgent, &QBluetoothDeviceDiscoveryAgent::canceled, this, &BluetoothDiscovery::discoveryCancelled);
connect(m_discoveryAgent, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error)), this, SLOT(onError(QBluetoothDeviceDiscoveryAgent::Error)));
@ -250,7 +252,10 @@ void BluetoothDiscovery::start()
m_discoveryAgent->stop();
}
m_deviceInfos->clearModel();
foreach (const QBluetoothDeviceInfo &info, m_discoveryAgent->discoveredDevices()) {
qCDebug(dcBtWiFiSetup()) << "Already discovered device:" << info.name();
deviceDiscovered(info);
}
qCDebug(dcBtWiFiSetup) << "BluetoothDiscovery: Starting discovery.";
m_discoveryAgent->start();

View File

@ -12,7 +12,9 @@ AutoSizeMenu {
property bool showLogs: true
Component.onCompleted: {
root.addItem(menuEntryComponent.createObject(root, {text: qsTr("Magic"), iconSource: "../images/magic.svg", functionName: "openThingMagicPage"}))
if (Configuration.magicEnabled) {
root.addItem(menuEntryComponent.createObject(root, {text: qsTr("Magic"), iconSource: "../images/magic.svg", functionName: "openThingMagicPage"}))
}
if (root.showDetails) {
root.addItem(menuEntryComponent.createObject(root, {text: qsTr("Details"), iconSource: "../images/info.svg", functionName: "openGenericThingPage"}))

View File

@ -160,13 +160,6 @@ ThingPageBase {
readonly property string title: model.value.trim().replace(/, ?.*/, "")
readonly property string text: model.value.trim().replace(/.*, ?/, "")
onPressAndHold: {
var contextMenuComponent = Qt.createComponent("../components/ThingContextMenu.qml");
var contextMenu = contextMenuComponent.createObject(root, { thing: root.thing })
contextMenu.x = Qt.binding(function() { return (root.width - contextMenu.width) / 2 })
contextMenu.open()
}
contentItem: RowLayout {
ColumnLayout {
Label {