mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Save Bluetooth download mode settings
Save the dive computer download mode flag. In this way, if the user used Bluetooth mode to download its dives on his last session he doesn't need to open the Bth selection dialog if he wants to use the same device. Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
384ab944f2
commit
9e97f124c6
5 changed files with 17 additions and 3 deletions
|
@ -53,7 +53,7 @@ int enumerate_devices(device_callback_t callback, void *userdata, int dc_type);
|
||||||
extern const char *default_dive_computer_vendor;
|
extern const char *default_dive_computer_vendor;
|
||||||
extern const char *default_dive_computer_product;
|
extern const char *default_dive_computer_product;
|
||||||
extern const char *default_dive_computer_device;
|
extern const char *default_dive_computer_device;
|
||||||
|
extern int default_dive_computer_download_mode;
|
||||||
#define AMB_PERCENTAGE 50.0
|
#define AMB_PERCENTAGE 50.0
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
const char *default_dive_computer_vendor;
|
const char *default_dive_computer_vendor;
|
||||||
const char *default_dive_computer_product;
|
const char *default_dive_computer_product;
|
||||||
const char *default_dive_computer_device;
|
const char *default_dive_computer_device;
|
||||||
|
int default_dive_computer_download_mode;
|
||||||
DiveComputerList dcList;
|
DiveComputerList dcList;
|
||||||
|
|
||||||
DiveComputerList::DiveComputerList()
|
DiveComputerList::DiveComputerList()
|
||||||
|
@ -172,6 +173,16 @@ void set_default_dive_computer_device(const char *name)
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_default_dive_computer_download_mode(int download_mode)
|
||||||
|
{
|
||||||
|
QSettings s;
|
||||||
|
|
||||||
|
default_dive_computer_download_mode = download_mode;
|
||||||
|
s.beginGroup("DiveComputer");
|
||||||
|
s.setValue("dive_computer_download_mode", download_mode);
|
||||||
|
s.endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" void set_dc_nickname(struct dive *dive)
|
extern "C" void set_dc_nickname(struct dive *dive)
|
||||||
{
|
{
|
||||||
if (!dive)
|
if (!dive)
|
||||||
|
|
|
@ -25,6 +25,7 @@ QString get_pressure_string(pressure_t pressure, bool showunit = false);
|
||||||
QString get_pressure_unit();
|
QString get_pressure_unit();
|
||||||
void set_default_dive_computer(const char *vendor, const char *product);
|
void set_default_dive_computer(const char *vendor, const char *product);
|
||||||
void set_default_dive_computer_device(const char *name);
|
void set_default_dive_computer_device(const char *name);
|
||||||
|
void set_default_dive_computer_download_mode(int downloadMode);
|
||||||
QString getSubsurfaceDataPath(QString folderToFind);
|
QString getSubsurfaceDataPath(QString folderToFind);
|
||||||
extern const QString get_dc_nickname(const char *model, uint32_t deviceid);
|
extern const QString get_dc_nickname(const char *model, uint32_t deviceid);
|
||||||
int gettimezoneoffset(timestamp_t when = 0);
|
int gettimezoneoffset(timestamp_t when = 0);
|
||||||
|
|
|
@ -102,6 +102,7 @@ DownloadFromDCWidget::DownloadFromDCWidget(QWidget *parent, Qt::WindowFlags f) :
|
||||||
|
|
||||||
#if defined(BT_SUPPORT)
|
#if defined(BT_SUPPORT)
|
||||||
ui.bluetoothMode->setText(tr("Choose Bluetooth download mode"));
|
ui.bluetoothMode->setText(tr("Choose Bluetooth download mode"));
|
||||||
|
ui.bluetoothMode->setChecked(default_dive_computer_download_mode == DC_TRANSPORT_BLUETOOTH);
|
||||||
btDeviceSelectionDialog = 0;
|
btDeviceSelectionDialog = 0;
|
||||||
ui.chooseBluetoothDevice->setEnabled(ui.bluetoothMode->isChecked());
|
ui.chooseBluetoothDevice->setEnabled(ui.bluetoothMode->isChecked());
|
||||||
connect(ui.bluetoothMode, SIGNAL(stateChanged(int)), this, SLOT(enableBluetoothMode(int)));
|
connect(ui.bluetoothMode, SIGNAL(stateChanged(int)), this, SLOT(enableBluetoothMode(int)));
|
||||||
|
@ -321,7 +322,7 @@ void DownloadFromDCWidget::on_downloadCancelRetryButton_clicked()
|
||||||
data.product = strdup(ui.product->currentText().toUtf8().data());
|
data.product = strdup(ui.product->currentText().toUtf8().data());
|
||||||
#if defined(BT_SUPPORT)
|
#if defined(BT_SUPPORT)
|
||||||
data.bluetooth_mode = ui.bluetoothMode->isChecked();
|
data.bluetooth_mode = ui.bluetoothMode->isChecked();
|
||||||
if (data.bluetooth_mode) {
|
if (data.bluetooth_mode && btDeviceSelectionDialog != NULL) {
|
||||||
// Get the selected device address
|
// Get the selected device address
|
||||||
data.devname = strdup(btDeviceSelectionDialog->getSelectedDeviceAddress().toUtf8().data());
|
data.devname = strdup(btDeviceSelectionDialog->getSelectedDeviceAddress().toUtf8().data());
|
||||||
} else
|
} else
|
||||||
|
@ -346,7 +347,7 @@ void DownloadFromDCWidget::on_downloadCancelRetryButton_clicked()
|
||||||
data.deviceid = data.diveid = 0;
|
data.deviceid = data.diveid = 0;
|
||||||
set_default_dive_computer(data.vendor, data.product);
|
set_default_dive_computer(data.vendor, data.product);
|
||||||
set_default_dive_computer_device(data.devname);
|
set_default_dive_computer_device(data.devname);
|
||||||
|
set_default_dive_computer_download_mode(ui.bluetoothMode->isChecked() ? DC_TRANSPORT_BLUETOOTH : DC_TRANSPORT_SERIAL);
|
||||||
thread = new DownloadThread(this, &data);
|
thread = new DownloadThread(this, &data);
|
||||||
|
|
||||||
connect(thread, SIGNAL(finished()),
|
connect(thread, SIGNAL(finished()),
|
||||||
|
|
|
@ -1127,6 +1127,7 @@ void MainWindow::readSettings()
|
||||||
default_dive_computer_vendor = getSetting(s, "dive_computer_vendor");
|
default_dive_computer_vendor = getSetting(s, "dive_computer_vendor");
|
||||||
default_dive_computer_product = getSetting(s, "dive_computer_product");
|
default_dive_computer_product = getSetting(s, "dive_computer_product");
|
||||||
default_dive_computer_device = getSetting(s, "dive_computer_device");
|
default_dive_computer_device = getSetting(s, "dive_computer_device");
|
||||||
|
default_dive_computer_download_mode = s.value("dive_computer_download_mode").toInt();
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
QNetworkProxy proxy;
|
QNetworkProxy proxy;
|
||||||
proxy.setType(QNetworkProxy::ProxyType(prefs.proxy_type));
|
proxy.setType(QNetworkProxy::ProxyType(prefs.proxy_type));
|
||||||
|
|
Loading…
Reference in a new issue