mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 06:15:26 +00:00
Mobile: only show dive computers in the Bluetooth connection list
And offer an option to show all devices in the settings. This is intentionally not stored in the preferences as this should never be needed. We don't support BT or BLE dive computers that we don't recognize. This is a last resort in case a new firmware were to change the name or some other weird issue causes us not to recognize a dive computer - and that should be fixed instead of worked around. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
f35a0f3b09
commit
9d582c5512
5 changed files with 60 additions and 2 deletions
|
@ -91,6 +91,7 @@ bool matchesKnownDiveComputerNames(QString btName)
|
|||
}
|
||||
|
||||
BTDiscovery::BTDiscovery(QObject*) : m_btValid(false),
|
||||
m_showNonDiveComputers(false),
|
||||
discoveryAgent(nullptr)
|
||||
{
|
||||
if (m_instance) {
|
||||
|
@ -104,6 +105,11 @@ BTDiscovery::BTDiscovery(QObject*) : m_btValid(false),
|
|||
#endif
|
||||
}
|
||||
|
||||
void BTDiscovery::showNonDiveComputers(bool show)
|
||||
{
|
||||
m_showNonDiveComputers = show;
|
||||
}
|
||||
|
||||
void BTDiscovery::BTDiscoveryReDiscover()
|
||||
{
|
||||
#if !defined(Q_OS_IOS)
|
||||
|
@ -232,7 +238,9 @@ void BTDiscovery::btDeviceDiscoveredMain(const btPairedDevice &device)
|
|||
connectionListModel.addAddress(newDevice + " " + device.address);
|
||||
return;
|
||||
}
|
||||
connectionListModel.addAddress(device.address);
|
||||
// Do we want only devices we recognize as dive computers?
|
||||
if (m_showNonDiveComputers)
|
||||
connectionListModel.addAddress(device.address);
|
||||
qDebug() << "Not recognized as dive computer";
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,8 @@ public:
|
|||
void btDeviceDiscovered(const QBluetoothDeviceInfo &device);
|
||||
void btDeviceDiscoveredMain(const btPairedDevice &device);
|
||||
bool btAvailable() const;
|
||||
void showNonDiveComputers(bool show);
|
||||
|
||||
#if defined(Q_OS_ANDROID)
|
||||
void getBluetoothDevices();
|
||||
#endif
|
||||
|
@ -57,6 +59,7 @@ public:
|
|||
private:
|
||||
static BTDiscovery *m_instance;
|
||||
bool m_btValid;
|
||||
bool m_showNonDiveComputers;
|
||||
|
||||
QList<struct btVendorProduct> btDCs; // recognized DCs
|
||||
QList<struct btVendorProduct> btAllDevices; // all paired BT stuff
|
||||
|
|
|
@ -530,6 +530,41 @@ Kirigami.ScrollablePage {
|
|||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
GridLayout {
|
||||
id: whichBluetoothDevices
|
||||
columns: 2
|
||||
Controls.Label {
|
||||
text: qsTr("Bluetooth")
|
||||
font.pointSize: subsurfaceTheme.headingPointSize
|
||||
font.weight: Font.Light
|
||||
color: subsurfaceTheme.textColor
|
||||
Layout.topMargin: Kirigami.Units.largeSpacing
|
||||
Layout.bottomMargin: Kirigami.Units.largeSpacing / 2
|
||||
Layout.columnSpan: 2
|
||||
}
|
||||
|
||||
Controls.Label {
|
||||
text: qsTr("Show all bluetooth devices \neven if not recognized as dive computers")
|
||||
font.pointSize: subsurfaceTheme.regularPointSize
|
||||
Layout.preferredWidth: gridWidth * 0.75
|
||||
}
|
||||
SsrfSwitch {
|
||||
id: nonDCButton
|
||||
checked: manager.showNonDiveComputers
|
||||
Layout.preferredWidth: gridWidth * 0.25
|
||||
onClicked: {
|
||||
manager.showNonDiveComputers = checked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
color: subsurfaceTheme.darkerPrimaryColor
|
||||
height: 1
|
||||
opacity: 0.5
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
GridLayout {
|
||||
id: developer
|
||||
columns: 2
|
||||
|
|
|
@ -144,7 +144,8 @@ QMLManager::QMLManager() : m_locationServiceEnabled(false),
|
|||
m_updateSelectedDive(-1),
|
||||
m_selectedDiveTimestamp(0),
|
||||
alreadySaving(false),
|
||||
m_pluggedInDeviceName("")
|
||||
m_pluggedInDeviceName(""),
|
||||
m_showNonDiveComputers(false)
|
||||
{
|
||||
LOG_STP("qmlmgr starting");
|
||||
m_instance = this;
|
||||
|
@ -1979,6 +1980,12 @@ void QMLManager::setFilter(const QString filterText)
|
|||
});
|
||||
}
|
||||
|
||||
void QMLManager::setShowNonDiveComputers(bool show)
|
||||
{
|
||||
m_showNonDiveComputers = show;
|
||||
BTDiscovery::instance()->showNonDiveComputers(show);
|
||||
}
|
||||
|
||||
#if defined(Q_OS_ANDROID)
|
||||
// implemented in core/android.cpp
|
||||
void checkPendingIntents();
|
||||
|
|
|
@ -48,6 +48,7 @@ class QMLManager : public QObject {
|
|||
Q_PROPERTY(bool DC_saveDump READ DC_saveDump WRITE DC_setSaveDump)
|
||||
Q_PROPERTY(int DC_deviceId READ DC_deviceId WRITE DC_setDeviceId)
|
||||
Q_PROPERTY(QString pluggedInDeviceName MEMBER m_pluggedInDeviceName NOTIFY pluggedInDeviceNameChanged)
|
||||
Q_PROPERTY(bool showNonDiveComputers MEMBER m_showNonDiveComputers WRITE setShowNonDiveComputers NOTIFY showNonDiveComputersChanged)
|
||||
public:
|
||||
QMLManager();
|
||||
~QMLManager();
|
||||
|
@ -126,6 +127,8 @@ public:
|
|||
bool btEnabled() const;
|
||||
void setBtEnabled(bool value);
|
||||
|
||||
void setShowNonDiveComputers(bool show);
|
||||
|
||||
DiveListSortModel *dlSortModel;
|
||||
|
||||
QStringList suitList() const;
|
||||
|
@ -234,6 +237,7 @@ private:
|
|||
bool m_btEnabled;
|
||||
void updateAllGlobalLists();
|
||||
QString m_pluggedInDeviceName;
|
||||
bool m_showNonDiveComputers;
|
||||
struct dive *m_copyPasteDive = NULL;
|
||||
struct dive_components what;
|
||||
|
||||
|
@ -262,6 +266,7 @@ signals:
|
|||
void locationListChanged();
|
||||
void waitingForPositionChanged();
|
||||
void pluggedInDeviceNameChanged();
|
||||
void showNonDiveComputersChanged();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue