summaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@gmail.com>2016-08-10 18:10:15 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-08-27 11:40:44 -0700
commitdb8e8957abc8b8dc407a94835e686f649c9643a6 (patch)
tree5c21bd7e9a4174704e1c53752146c1229464b2bc /desktop-widgets
parentb264c3e36704c83a6c9353fe5eac3dc0eb3c9a80 (diff)
downloadsubsurface-db8e8957abc8b8dc407a94835e686f649c9643a6.tar.gz
Settings update: Add "Dive Computer" settings to SettingsObjectWrapper
For some reason, the dive computer settings weren't in the settings prefs. This moves it, makes the boilerplate on Settings ObjectWrapper and make things compile. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/configuredivecomputerdialog.cpp9
-rw-r--r--desktop-widgets/downloadfromdivecomputer.cpp31
-rw-r--r--desktop-widgets/mainwindow.cpp20
3 files changed, 27 insertions, 33 deletions
diff --git a/desktop-widgets/configuredivecomputerdialog.cpp b/desktop-widgets/configuredivecomputerdialog.cpp
index 471db9a65..79cdcaf2f 100644
--- a/desktop-widgets/configuredivecomputerdialog.cpp
+++ b/desktop-widgets/configuredivecomputerdialog.cpp
@@ -3,6 +3,7 @@
#include "core/helpers.h"
#include "desktop-widgets/mainwindow.h"
#include "core/display.h"
+#include "core/subsurface-qt/SettingsObjectWrapper.h"
#include <QFileDialog>
#include <QMessageBox>
@@ -150,8 +151,9 @@ ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : QDia
memset(&device_data, 0, sizeof(device_data));
fill_computer_list();
- if (default_dive_computer_device)
- ui.device->setEditText(default_dive_computer_device);
+ auto dc = SettingsObjectWrapper::instance()->dive_computer_settings;
+ if (!dc->dc_device().isEmpty())
+ ui.device->setEditText(dc->dc_device());
ui.DiveComputerList->setCurrentRow(0);
on_DiveComputerList_currentRowChanged(0);
@@ -775,7 +777,8 @@ void ConfigureDiveComputerDialog::getDeviceData()
device_data.descriptor = descriptorLookup[selected_vendor + selected_product];
device_data.deviceid = device_data.diveid = 0;
- set_default_dive_computer_device(device_data.devname);
+ auto dc = SettingsObjectWrapper::instance()->dive_computer_settings;
+ dc->setDevice(device_data.devname);
}
void ConfigureDiveComputerDialog::on_cancel_clicked()
diff --git a/desktop-widgets/downloadfromdivecomputer.cpp b/desktop-widgets/downloadfromdivecomputer.cpp
index 7ef4e1e28..d58589636 100644
--- a/desktop-widgets/downloadfromdivecomputer.cpp
+++ b/desktop-widgets/downloadfromdivecomputer.cpp
@@ -4,6 +4,7 @@
#include "desktop-widgets/divelistview.h"
#include "core/display.h"
#include "core/uemis.h"
+#include "core/subsurface-qt/SettingsObjectWrapper.h"
#include "qt-models/models.h"
#include <QTimer>
@@ -78,15 +79,17 @@ DownloadFromDCWidget::DownloadFromDCWidget(QWidget *parent, Qt::WindowFlags f) :
connect(ui.unselectAllButton, SIGNAL(clicked()), diveImportedModel, SLOT(selectNone()));
vendorModel = new QStringListModel(vendorList);
ui.vendor->setModel(vendorModel);
- if (default_dive_computer_vendor) {
- ui.vendor->setCurrentIndex(ui.vendor->findText(default_dive_computer_vendor));
- productModel = new QStringListModel(productList[default_dive_computer_vendor]);
+
+ auto dc = SettingsObjectWrapper::instance()->dive_computer_settings;
+ if (!dc->dc_vendor().isEmpty()) {
+ ui.vendor->setCurrentIndex(ui.vendor->findText(dc->dc_vendor()));
+ productModel = new QStringListModel(productList[dc->dc_vendor()]);
ui.product->setModel(productModel);
- if (default_dive_computer_product)
- ui.product->setCurrentIndex(ui.product->findText(default_dive_computer_product));
+ if (!dc->dc_product().isEmpty())
+ ui.product->setCurrentIndex(ui.product->findText(dc->dc_product()));
}
- if (default_dive_computer_device)
- ui.device->setEditText(default_dive_computer_device);
+ if (!dc->dc_device().isEmpty())
+ ui.device->setEditText(dc->dc_device());
timer->setInterval(200);
connect(timer, SIGNAL(timeout()), this, SLOT(updateProgressBar()));
@@ -102,7 +105,7 @@ DownloadFromDCWidget::DownloadFromDCWidget(QWidget *parent, Qt::WindowFlags f) :
#if defined(BT_SUPPORT) && defined(SSRF_CUSTOM_SERIAL)
ui.bluetoothMode->setText(tr("Choose Bluetooth download mode"));
- ui.bluetoothMode->setChecked(default_dive_computer_download_mode == DC_TRANSPORT_BLUETOOTH);
+ ui.bluetoothMode->setChecked(dc->downloadMode() == DC_TRANSPORT_BLUETOOTH);
btDeviceSelectionDialog = 0;
ui.chooseBluetoothDevice->setEnabled(ui.bluetoothMode->isChecked());
connect(ui.bluetoothMode, SIGNAL(stateChanged(int)), this, SLOT(enableBluetoothMode(int)));
@@ -337,16 +340,20 @@ void DownloadFromDCWidget::on_downloadCancelRetryButton_clicked()
data.create_new_trip = ui.createNewTrip->isChecked();
data.trip = NULL;
data.deviceid = data.diveid = 0;
- set_default_dive_computer(data.vendor, data.product);
- set_default_dive_computer_device(data.devname);
+
+ auto dc = SettingsObjectWrapper::instance()->dive_computer_settings;
+ dc->setVendor(data.vendor);
+ dc->setProduct(data.product);
+ dc->setDevice(data.devname);
#if defined(BT_SUPPORT) && defined(SSRF_CUSTOM_SERIAL)
- set_default_dive_computer_download_mode(ui.bluetoothMode->isChecked() ? DC_TRANSPORT_BLUETOOTH : DC_TRANSPORT_SERIAL);
+ dc->setDownloadMode(ui.bluetoothMode->isChecked() ? DC_TRANSPORT_BLUETOOTH : DC_TRANSPORT_SERIAL);
#endif
- thread = new DownloadThread(this, &data);
+ thread = new DownloadThread(this, &data);
connect(thread, SIGNAL(finished()),
this, SLOT(onDownloadThreadFinished()), Qt::QueuedConnection);
+ //TODO: Don't call mainwindow.
MainWindow *w = MainWindow::instance();
connect(thread, SIGNAL(finished()), w, SLOT(refreshDisplay()));
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp
index 868545600..78faaadc5 100644
--- a/desktop-widgets/mainwindow.cpp
+++ b/desktop-widgets/mainwindow.cpp
@@ -1305,33 +1305,17 @@ void MainWindow::initialUiSetup()
show();
}
-const char *getSetting(const QSettings &s,const QString& name)
-{
- QVariant v;
- v = s.value(name);
- if (v.isValid()) {
- return strdup(v.toString().toUtf8().data());
- }
- return NULL;
-}
-
void MainWindow::readSettings()
{
static bool firstRun = true;
-
- QSettings s; //WARNING: Why those prefs are not on the prefs struct?
- s.beginGroup("DiveComputer");
- default_dive_computer_vendor = getSetting(s, "dive_computer_vendor");
- default_dive_computer_product = getSetting(s, "dive_computer_product");
- default_dive_computer_device = getSetting(s, "dive_computer_device");
- default_dive_computer_download_mode = s.value("dive_computer_download_mode").toInt();
- s.endGroup();
init_proxy();
// now make sure that the cloud menu items are enabled IFF cloud account is verified
enableDisableCloudActions();
#if !defined(SUBSURFACE_MOBILE)
+ QSettings s; //TODO: this 's' exists only for the loadRecentFiles, remove it.
+
loadRecentFiles(&s);
if (firstRun) {
checkSurvey(&s);