Skip to content

Commit a99e44a

Browse files
committed
macOS fixes and improvements
1 parent 3de44cb commit a99e44a

8 files changed

+76
-41
lines changed

qml/PanelDeviceInfos.qml

+1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ Flickable {
153153
Layout.minimumHeight: 32
154154

155155
text: (selectedDevice && selectedDevice.deviceAddress)
156+
font.pixelSize: Theme.fontSizeComponentSmall
156157
wrapMode: Text.WrapAnywhere
157158
}
158159
}

qml/components_themed/SpinBoxThemed_desktop.qml

-9
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,6 @@ T.SpinBox {
108108
inputMethodHints: Qt.ImhDigitsOnly
109109

110110
onEditingFinished: {
111-
var v = parseInt(text)
112-
if (text.length <= 0) v = control.from
113-
if (isNaN(v)) v = control.from
114-
if (v < control.from) v = control.from
115-
if (v > control.to) v = control.to
116-
117-
control.value = v
118-
control.valueModified()
119-
120111
control.focus = false
121112
focus = false
122113
}

src/DeviceManager.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -840,10 +840,10 @@ void DeviceManager::addBleDevice(const QBluetoothDeviceInfo &info)
840840
DeviceToolBLEx *d = new DeviceToolBLEx(info, this);
841841
if (d)
842842
{
843-
if (info.name().isEmpty()) d->setBeacon(true);
844-
if (info.name().replace('-', ':') == info.address().toString()) d->setBeacon(true);
845843
if (info.isCached() || info.rssi() == 0) d->setCached(true);
846-
if (m_devices_blacklist.contains(info.address().toString())) d->setBlacklisted(true);
844+
if (info.name().isEmpty()) d->setBeacon(true);
845+
if (info.name().replace('-', ':') == d->getAddress()) d->setBeacon(true);
846+
if (m_devices_blacklist.contains(d->getAddress())) d->setBlacklisted(true);
847847

848848
// Get a random color
849849
d->setDeviceColor(getAvailableColor());
@@ -856,7 +856,7 @@ void DeviceManager::addBleDevice(const QBluetoothDeviceInfo &info)
856856
SettingsManager *sm = SettingsManager::getInstance();
857857
if (sm->getScanCacheAuto() && !d->isBeacon())
858858
{
859-
cacheDevice(info.address().toString());
859+
cacheDevice(d->getAddress());
860860
}
861861

862862
//qDebug() << "Device added (from BLE discovery): " << d->getName() << "/" << d->getAddress();

src/SettingsManager.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ bool SettingsManager::readSettings()
8585
if (m_appVisibility < 1 || m_appVisibility > 5) m_appVisibility = 1;
8686
#endif
8787

88+
////
89+
8890
if (settings.contains("settings/appTheme"))
8991
m_appTheme = settings.value("settings/appTheme").toString();
9092

@@ -100,7 +102,7 @@ bool SettingsManager::readSettings()
100102
if (settings.contains("settings/appUnits"))
101103
m_appUnits = settings.value("settings/appUnits").toInt();
102104

103-
//
105+
////
104106

105107
if (settings.contains("settings/scanAuto"))
106108
m_scanAuto = settings.value("settings/scanAuto").toBool();

src/SettingsManager.h

-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ class SettingsManager: public QObject
216216

217217
////
218218

219-
// Utils
220219
Q_INVOKABLE void reloadSettings();
221220
Q_INVOKABLE void resetSettings();
222221
};

src/device.cpp

+51-21
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Device::Device(const QString &deviceAddr, const QString &deviceName, QObject *pa
6363
// Check address validity
6464
if (m_bleDevice.isValid() == false)
6565
{
66-
qWarning() << "Device() '" << m_deviceAddress << "' is an invalid QBluetoothDeviceInfo...";
66+
qWarning() << "Device() '" << getAddress() << "' is an invalid QBluetoothDeviceInfo...";
6767
}
6868

6969
// Database
@@ -111,7 +111,7 @@ Device::Device(const QBluetoothDeviceInfo &d, QObject *parent) : QObject(parent)
111111
// Check address validity
112112
if (m_bleDevice.isValid() == false)
113113
{
114-
qWarning() << "Device() '" << m_deviceAddress << "' is an invalid QBluetoothDeviceInfo...";
114+
qWarning() << "Device() '" << getAddress() << "' is an invalid QBluetoothDeviceInfo...";
115115
}
116116

117117
// Database
@@ -358,7 +358,7 @@ void Device::setTimeoutTimer(int)
358358

359359
bool Device::getSqlDeviceInfos()
360360
{
361-
//qDebug() << "Device::getSqlDeviceInfos(" << m_deviceAddress << ")";
361+
//qDebug() << "Device::getSqlDeviceInfos(" << getAddress() << ")";
362362
return false;
363363
}
364364

@@ -394,30 +394,60 @@ bool Device::isUpdating() const
394394

395395
bool Device::hasAddressMAC() const
396396
{
397-
#if !defined(Q_OS_MACOS) && !defined(Q_OS_IOS)
398-
return true;
399-
#endif
397+
if (m_deviceAddressMAC.size() == 17) return true;
398+
if (m_deviceAddress.size() == 17) return true;
400399

401-
return !m_deviceAddressMAC.isEmpty();
400+
return false;
402401
}
403402

404403
QString Device::getAddressMAC() const
405404
{
406-
#if !defined(Q_OS_MACOS) && !defined(Q_OS_IOS)
407-
return m_deviceAddress;
408-
#endif
405+
if (m_deviceAddressMAC.size() == 17) return m_deviceAddressMAC;
406+
if (m_deviceAddress.size() == 17) return m_deviceAddress;
409407

410-
return m_deviceAddressMAC;
408+
return QString();
411409
}
412410

413411
void Device::setAddressMAC(const QString &mac)
414412
{
415413
//qDebug() << "setAddressMAC(" << mac << ")";
416414

417-
if (m_deviceAddressMAC != mac)
415+
if (mac.size() == 17)
418416
{
419-
m_deviceAddressMAC = mac;
420-
Q_EMIT settingsUpdated();
417+
if (m_deviceAddressMAC != mac)
418+
{
419+
m_deviceAddressMAC = mac;
420+
Q_EMIT sensorUpdated();
421+
}
422+
}
423+
}
424+
425+
bool Device::hasAddressUUID() const
426+
{
427+
return (m_deviceAddress.size() == 38);
428+
}
429+
430+
QString Device::getAddressUUID() const
431+
{
432+
if (m_deviceAddress.size() == 38) return m_deviceAddress;
433+
434+
return QString();
435+
}
436+
437+
void Device::setAddressUUID(const QString &uuid)
438+
{
439+
//qDebug() << "setAddressUUID(" << uuid << ")";
440+
441+
if (uuid.size() == 38)
442+
{
443+
if (m_deviceAddress.isEmpty() || m_deviceAddress.size() == 38)
444+
{
445+
if (m_deviceAddress != uuid)
446+
{
447+
m_deviceAddress = uuid;
448+
Q_EMIT sensorUpdated();
449+
}
450+
}
421451
}
422452
}
423453

@@ -576,7 +606,7 @@ void Device::setCoreConfiguration(const int bleconf)
576606

577607
void Device::setDeviceClass(const int major, const int minor, const int service)
578608
{
579-
//qDebug() << "Device::setDeviceClass() " << info.name() << info.address() << info.minorDeviceClass() << info.majorDeviceClass() << info.serviceClasses();
609+
//qDebug() << "Device::setDeviceClass() " << getName() << getAddress() << major << minor << service;
580610

581611
if (m_major != major || m_minor != minor || m_service != service)
582612
{
@@ -620,7 +650,7 @@ void Device::cleanRssi()
620650

621651
void Device::deviceConnected()
622652
{
623-
//qDebug() << "Device::deviceConnected(" << m_deviceAddress << ")";
653+
//qDebug() << "Device::deviceConnected(" << getAddress() << ")";
624654

625655
m_ble_status = DeviceUtils::DEVICE_CONNECTED;
626656

@@ -679,7 +709,7 @@ void Device::deviceConnected()
679709

680710
void Device::deviceDisconnected()
681711
{
682-
//qDebug() << "Device::deviceDisconnected(" << m_deviceAddress << ")";
712+
//qDebug() << "Device::deviceDisconnected(" << getAddress() << ")";
683713

684714
Q_EMIT disconnected();
685715

@@ -690,7 +720,7 @@ void Device::deviceDisconnected()
690720
void Device::deviceErrored(QLowEnergyController::Error error)
691721
{
692722
if (error <= QLowEnergyController::NoError) return;
693-
qWarning() << "Device::deviceErrored(" << m_deviceAddress << ") error:" << error;
723+
qWarning() << "Device::deviceErrored(" << getAddress() << ") error:" << error;
694724
/*
695725
QLowEnergyController::NoError 0 No error has occurred.
696726
QLowEnergyController::UnknownError 1 An unknown error has occurred.
@@ -714,7 +744,7 @@ void Device::deviceErrored(QLowEnergyController::Error error)
714744

715745
void Device::deviceStateChanged(QLowEnergyController::ControllerState)
716746
{
717-
//qDebug() << "Device::deviceStateChanged(" << m_deviceAddress << ") state:" << state;
747+
//qDebug() << "Device::deviceStateChanged(" << getAddress() << ") state:" << state;
718748
}
719749

720750
/* ************************************************************************** */
@@ -726,12 +756,12 @@ void Device::addLowEnergyService(const QBluetoothUuid &)
726756

727757
void Device::serviceDetailsDiscovered(QLowEnergyService::ServiceState)
728758
{
729-
//qDebug() << "Device::serviceDetailsDiscovered(" << m_deviceAddress << ")";
759+
//qDebug() << "Device::serviceDetailsDiscovered(" << getAddress() << ")";
730760
}
731761

732762
void Device::serviceScanDone()
733763
{
734-
//qDebug() << "Device::serviceScanDone(" << m_deviceAddress << ")";
764+
//qDebug() << "Device::serviceScanDone(" << getAddress() << ")";
735765
}
736766

737767
/* ************************************************************************** */

src/device.h

+7-3
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,13 @@ class Device: public QObject
215215
QString getFirmware() const { return m_deviceFirmware; }
216216
int getBatteryLevel() const { return m_deviceBattery; }
217217

218+
bool hasAddressMAC() const;
219+
QString getAddressMAC() const;
220+
void setAddressMAC(const QString &mac);
221+
bool hasAddressUUID() const;
222+
QString getAddressUUID() const;
223+
void setAddressUUID(const QString &uuid);
224+
218225
// Device type, capabilities and sensors
219226
int getDeviceType() const { return m_deviceType; }
220227
int getDeviceCapabilities() const { return m_deviceCapabilities; }
@@ -248,9 +255,6 @@ class Device: public QObject
248255
bool isErrored() const; //!< Has emitted a BLE error
249256

250257
// Device associated data
251-
bool hasAddressMAC() const;
252-
QString getAddressMAC() const;
253-
void setAddressMAC(const QString &mac);
254258
bool isEnabled() const { return m_isEnabled; }
255259
// Device additional settings
256260
Q_INVOKABLE bool hasSetting(const QString &key) const;

src/device_toolblex.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -1086,9 +1086,17 @@ bool DeviceToolBLEx::exportDeviceInfo(const QString &exportPath,
10861086
QString str;
10871087
QString endl = QChar('\n');
10881088

1089+
// Name and address
10891090
str += "Device Name: " + m_deviceName + endl;
1090-
if (hasAddressMAC()) str += "Device MAC: " + m_deviceAddress + endl;
1091-
if (m_deviceManufacturer.length() > 0) str += "Device MAC manufacturer: " + m_deviceManufacturer + endl;
1091+
if (hasAddressMAC())
1092+
{
1093+
str += "Device MAC: " + getAddressMAC() + endl;
1094+
if (m_deviceManufacturer.length() > 0) str += "Device MAC manufacturer: " + m_deviceManufacturer + endl;
1095+
}
1096+
else if (hasAddressUUID())
1097+
{
1098+
str += "Device MAC: " + getAddressUUID() + endl;
1099+
}
10921100
str += endl;
10931101

10941102
// Generic info

0 commit comments

Comments
 (0)