summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/downloadfromdcthread.cpp11
-rw-r--r--core/downloadfromdcthread.h6
-rw-r--r--core/pref.h1
-rw-r--r--core/subsurface-qt/SettingsObjectWrapper.cpp18
-rw-r--r--core/subsurface-qt/SettingsObjectWrapper.h4
5 files changed, 40 insertions, 0 deletions
diff --git a/core/downloadfromdcthread.cpp b/core/downloadfromdcthread.cpp
index e01de2881..a634b45aa 100644
--- a/core/downloadfromdcthread.cpp
+++ b/core/downloadfromdcthread.cpp
@@ -56,6 +56,7 @@ void DownloadThread::run()
dcs->setVendor(internalData->vendor);
dcs->setProduct(internalData->product);
dcs->setDevice(internalData->devname);
+ dcs->setDeviceName(m_data->devBluetoothName());
}
static void fill_supported_mobile_list()
@@ -239,6 +240,11 @@ QString DCDeviceData::devName() const
return data.devname;
}
+QString DCDeviceData::devBluetoothName() const
+{
+ return m_devBluetoothName;
+}
+
QString DCDeviceData::descriptor() const
{
return "";
@@ -284,6 +290,11 @@ void DCDeviceData::setDevName(const QString& devName)
data.devname = strdup(qPrintable(devName));
}
+void DCDeviceData::setDevBluetoothName(const QString& name)
+{
+ m_devBluetoothName = name;
+}
+
void DCDeviceData::setBluetoothMode(bool mode)
{
data.bluetooth_mode = mode;
diff --git a/core/downloadfromdcthread.h b/core/downloadfromdcthread.h
index ff4b8f39c..e95cb7a98 100644
--- a/core/downloadfromdcthread.h
+++ b/core/downloadfromdcthread.h
@@ -19,6 +19,7 @@ class DCDeviceData : public QObject {
Q_PROPERTY(QString product READ product WRITE setProduct)
Q_PROPERTY(bool bluetoothMode READ bluetoothMode WRITE setBluetoothMode)
Q_PROPERTY(QString devName READ devName WRITE setDevName)
+ Q_PROPERTY(QString devBluetoothName READ devBluetoothName WRITE setDevBluetoothName)
Q_PROPERTY(QString descriptor READ descriptor)
Q_PROPERTY(bool forceDownload READ forceDownload WRITE setForceDownload)
Q_PROPERTY(bool createNewTrip READ createNewTrip WRITE setCreateNewTrip)
@@ -34,6 +35,7 @@ public:
QString vendor() const;
QString product() const;
QString devName() const;
+ QString devBluetoothName() const;
QString descriptor() const;
bool bluetoothMode() const;
bool forceDownload() const;
@@ -57,6 +59,7 @@ public slots:
void setVendor(const QString& vendor);
void setProduct(const QString& product);
void setDevName(const QString& devName);
+ void setDevBluetoothName(const QString& devBluetoothName);
void setBluetoothMode(bool mode);
void setForceDownload(bool force);
void setCreateNewTrip(bool create);
@@ -67,6 +70,9 @@ public slots:
private:
static DCDeviceData *m_instance;
device_data_t data;
+
+ // Bluetooth name is managed outside of libdivecomputer
+ QString m_devBluetoothName;
};
class DownloadThread : public QThread {
diff --git a/core/pref.h b/core/pref.h
index 2d835dda1..d00d766a5 100644
--- a/core/pref.h
+++ b/core/pref.h
@@ -54,6 +54,7 @@ typedef struct {
char *vendor;
char *product;
char *device;
+ char *device_name;
int download_mode;
} dive_computer_prefs_t;
diff --git a/core/subsurface-qt/SettingsObjectWrapper.cpp b/core/subsurface-qt/SettingsObjectWrapper.cpp
index ed4b556d1..d1146b7b6 100644
--- a/core/subsurface-qt/SettingsObjectWrapper.cpp
+++ b/core/subsurface-qt/SettingsObjectWrapper.cpp
@@ -29,6 +29,11 @@ QString DiveComputerSettings::dc_device() const
return prefs.dive_computer.device;
}
+QString DiveComputerSettings::dc_device_name() const
+{
+ return prefs.dive_computer.device_name;
+}
+
int DiveComputerSettings::downloadMode() const
{
return prefs.dive_computer.download_mode;
@@ -70,6 +75,18 @@ void DiveComputerSettings::setDevice(const QString& device)
prefs.dive_computer.device = copy_string(qPrintable(device));
}
+void DiveComputerSettings::setDeviceName(const QString& device_name)
+{
+ if (device_name == prefs.dive_computer.device_name)
+ return;
+
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("dive_computer_device_name", device_name);
+ free(prefs.dive_computer.device_name);
+ prefs.dive_computer.device_name = copy_string(qPrintable(device_name));
+}
+
void DiveComputerSettings::setDownloadMode(int mode)
{
if (mode == prefs.dive_computer.download_mode)
@@ -2333,6 +2350,7 @@ void SettingsObjectWrapper::load()
GET_TXT("dive_computer_vendor",dive_computer.vendor);
GET_TXT("dive_computer_product", dive_computer.product);
GET_TXT("dive_computer_device", dive_computer.device);
+ GET_TXT("dive_computer_device_name", dive_computer.device_name);
GET_INT("dive_computer_download_mode", dive_computer.download_mode);
s.endGroup();
diff --git a/core/subsurface-qt/SettingsObjectWrapper.h b/core/subsurface-qt/SettingsObjectWrapper.h
index d16d3fa27..19cfcdd50 100644
--- a/core/subsurface-qt/SettingsObjectWrapper.h
+++ b/core/subsurface-qt/SettingsObjectWrapper.h
@@ -18,24 +18,28 @@ class DiveComputerSettings : public QObject {
Q_PROPERTY(QString vendor READ dc_vendor WRITE setVendor NOTIFY vendorChanged)
Q_PROPERTY(QString product READ dc_product WRITE setProduct NOTIFY productChanged)
Q_PROPERTY(QString device READ dc_device WRITE setDevice NOTIFY deviceChanged)
+ Q_PROPERTY(QString device_name READ dc_device_name WRITE setDeviceName NOTIFY deviceNameChanged)
Q_PROPERTY(int download_mode READ downloadMode WRITE setDownloadMode NOTIFY downloadModeChanged)
public:
DiveComputerSettings(QObject *parent);
QString dc_vendor() const;
QString dc_product() const;
QString dc_device() const;
+ QString dc_device_name() const;
int downloadMode() const;
public slots:
void setVendor(const QString& vendor);
void setProduct(const QString& product);
void setDevice(const QString& device);
+ void setDeviceName(const QString& device_name);
void setDownloadMode(int mode);
signals:
void vendorChanged(const QString& vendor);
void productChanged(const QString& product);
void deviceChanged(const QString& device);
+ void deviceNameChanged(const QString& device_name);
void downloadModeChanged(int mode);
private:
const QString group = QStringLiteral("DiveComputer");