diff options
Diffstat (limited to 'desktop-widgets')
20 files changed, 226 insertions, 289 deletions
diff --git a/desktop-widgets/configuredivecomputerdialog.cpp b/desktop-widgets/configuredivecomputerdialog.cpp index 137859388..cb7ec8371 100644 --- a/desktop-widgets/configuredivecomputerdialog.cpp +++ b/desktop-widgets/configuredivecomputerdialog.cpp @@ -3,7 +3,7 @@ #include "core/display.h" #include "core/qthelper.h" -#include "core/subsurface-qt/SettingsObjectWrapper.h" +#include "core/settings/qPrefDiveComputer.h" #include "desktop-widgets/mainwindow.h" // For fill_computer_list, descriptorLookup #include "core/downloadfromdcthread.h" @@ -132,9 +132,8 @@ ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : QDia memset(&device_data, 0, sizeof(device_data)); fill_computer_list(); - auto dc = SettingsObjectWrapper::instance()->dive_computer_settings; - if (!dc->device().isEmpty()) - ui.device->setEditText(dc->device()); + if (!qPrefDiveComputer::device().isEmpty()) + ui.device->setEditText(qPrefDiveComputer::device()); ui.DiveComputerList->setCurrentRow(0); on_DiveComputerList_currentRowChanged(0); @@ -912,11 +911,10 @@ void ConfigureDiveComputerDialog::getDeviceData() device_data.descriptor = descriptorLookup.value(selected_vendor + selected_product); device_data.deviceid = device_data.diveid = 0; - auto dc = SettingsObjectWrapper::instance()->dive_computer_settings; - dc->set_device(device_data.devname); + qPrefDiveComputer::set_device(device_data.devname); #ifdef BT_SUPPORT if (ui.bluetoothMode && btDeviceSelectionDialog) - dc->set_device_name(btDeviceSelectionDialog->getSelectedDeviceName()); + qPrefDiveComputer::set_device_name(btDeviceSelectionDialog->getSelectedDeviceName()); #endif } diff --git a/desktop-widgets/divelogexportdialog.cpp b/desktop-widgets/divelogexportdialog.cpp index bf01b0e9f..2dbbe3817 100644 --- a/desktop-widgets/divelogexportdialog.cpp +++ b/desktop-widgets/divelogexportdialog.cpp @@ -12,6 +12,7 @@ #include "desktop-widgets/subsurfacewebservices.h" #include "core/worldmap-save.h" #include "core/save-html.h" +#include "core/settings/qPrefDisplay.h" #include "desktop-widgets/mainwindow.h" #include "profile-widget/profilewidget2.h" #include "core/dive.h" // Allows access to helper functions in TeX export. @@ -121,15 +122,10 @@ void DiveLogExportDialog::on_buttonBox_accepted() { QString filename; QString stylesheet; - QSettings settings; QString lastDir = QDir::homePath(); - settings.beginGroup("FileDialog"); - if (settings.contains("LastDir")) { - if (QDir(settings.value("LastDir").toString()).exists()) - lastDir = settings.value("LastDir").toString(); - } - settings.endGroup(); + if (QDir(qPrefDisplay::lastDir()).exists()) + lastDir = qPrefDisplay::lastDir(); switch (ui->tabWidget->currentIndex()) { case 0: @@ -184,9 +180,7 @@ void DiveLogExportDialog::on_buttonBox_accepted() if (!filename.isNull() && !filename.isEmpty()) { // remember the last export path QFileInfo fileInfo(filename); - settings.beginGroup("FileDialog"); - settings.setValue("LastDir", fileInfo.dir().path()); - settings.endGroup(); + qPrefDisplay::set_lastDir(fileInfo.dir().path()); // the non XSLT exports are called directly above, the XSLT based ons are called here if (!stylesheet.isEmpty()) { future = QtConcurrent::run(export_dives_xslt, filename.toUtf8(), ui->exportSelected->isChecked(), ui->CSVUnits_2->currentIndex(), stylesheet.toUtf8()); @@ -351,10 +345,10 @@ void DiveLogExportDialog::export_TeX(const char *filename, const bool selected_o if (is_cylinder_used(dive, i) || (prefs.display_unused_tanks && dive->cylinder[i].type.description)){ put_format(&buf, "\\def\\cyl%cdescription{%s}\n", 'a' + i, dive->cylinder[i].type.description); - put_format(&buf, "\\def\\cyl%cgasname{%s}\n", 'a' + i, gasname(&dive->cylinder[i].gasmix)); - put_format(&buf, "\\def\\cyl%cmixO2{%.1f\\%%}\n", 'a' + i, get_o2(&dive->cylinder[i].gasmix)/10.0); - put_format(&buf, "\\def\\cyl%cmixHe{%.1f\\%%}\n", 'a' + i, get_he(&dive->cylinder[i].gasmix)/10.0); - put_format(&buf, "\\def\\cyl%cmixN2{%.1f\\%%}\n", 'a' + i, (100.0 - (get_o2(&dive->cylinder[i].gasmix)/10.0) - (get_he(&dive->cylinder[i].gasmix)/10.0))); + put_format(&buf, "\\def\\cyl%cgasname{%s}\n", 'a' + i, gasname(dive->cylinder[i].gasmix)); + put_format(&buf, "\\def\\cyl%cmixO2{%.1f\\%%}\n", 'a' + i, get_o2(dive->cylinder[i].gasmix)/10.0); + put_format(&buf, "\\def\\cyl%cmixHe{%.1f\\%%}\n", 'a' + i, get_he(dive->cylinder[i].gasmix)/10.0); + put_format(&buf, "\\def\\cyl%cmixN2{%.1f\\%%}\n", 'a' + i, (100.0 - (get_o2(dive->cylinder[i].gasmix)/10.0) - (get_he(dive->cylinder[i].gasmix)/10.0))); delta_p.mbar += dive->cylinder[i].start.mbar - dive->cylinder[i].end.mbar; put_format(&buf, "\\def\\cyl%cstartpress{%.1f\\pressureunit}\n", 'a' + i, get_pressure_units(dive->cylinder[i].start.mbar, &unit)/1.0); put_format(&buf, "\\def\\cyl%cendpress{%.1f\\pressureunit}\n", 'a' + i, get_pressure_units(dive->cylinder[i].end.mbar, &unit)/1.0); diff --git a/desktop-widgets/diveplanner.cpp b/desktop-widgets/diveplanner.cpp index e2f192f8e..63c3a97ec 100644 --- a/desktop-widgets/diveplanner.cpp +++ b/desktop-widgets/diveplanner.cpp @@ -4,7 +4,7 @@ #include "desktop-widgets/mainwindow.h" #include "core/planner.h" #include "core/qthelper.h" -#include "core/subsurface-qt/SettingsObjectWrapper.h" +#include "core/settings/qPrefDivePlanner.h" #include "core/gettextfromc.h" #include "qt-models/cylindermodel.h" @@ -14,7 +14,6 @@ #include <QGraphicsSceneMouseEvent> #include <QMessageBox> -#include <QSettings> #include <QShortcut> #define TIME_INITIAL_MAX 30 diff --git a/desktop-widgets/diveshareexportdialog.cpp b/desktop-widgets/diveshareexportdialog.cpp index 2689eaca8..fc26e0ced 100644 --- a/desktop-widgets/diveshareexportdialog.cpp +++ b/desktop-widgets/diveshareexportdialog.cpp @@ -6,9 +6,9 @@ #include "desktop-widgets/subsurfacewebservices.h" #include "core/qthelper.h" #include "core/cloudstorage.h" +#include "core/settings/qPrefGeneral.h" #include <QDesktopServices> -#include <QSettings> DiveShareExportDialog::DiveShareExportDialog(QWidget *parent) : QDialog(parent), @@ -43,12 +43,11 @@ void DiveShareExportDialog::prepareDivesForUpload(bool selected) ui->frameConfigure->setVisible(true); ui->frameResults->setVisible(false); - QSettings settings; - if (settings.contains("diveshareExport/uid")) - ui->txtUID->setText(settings.value("diveshareExport/uid").toString()); + if (qPrefGeneral::diveshareExport_uid() != "") + ui->txtUID->setText(qPrefGeneral::diveshareExport_uid()); - if (settings.contains("diveshareExport/private")) - ui->chkPrivate->setChecked(settings.value("diveshareExport/private").toBool()); + if (qPrefGeneral::diveshareExport_private()) + ui->chkPrivate->setChecked(qPrefGeneral::diveshareExport_private()); show(); } @@ -108,9 +107,8 @@ void DiveShareExportDialog::finishedSlot() void DiveShareExportDialog::doUpload() { //Store current settings - QSettings settings; - settings.setValue("diveshareExport/uid", ui->txtUID->text()); - settings.setValue("diveshareExport/private", ui->chkPrivate->isChecked()); + qPrefGeneral::set_diveshareExport_uid(ui->txtUID->text()); + qPrefGeneral::set_diveshareExport_private(ui->chkPrivate->isChecked()); //Change UI into results mode ui->frameConfigure->setVisible(false); diff --git a/desktop-widgets/downloadfromdivecomputer.cpp b/desktop-widgets/downloadfromdivecomputer.cpp index 4b5a0c917..4d86958af 100644 --- a/desktop-widgets/downloadfromdivecomputer.cpp +++ b/desktop-widgets/downloadfromdivecomputer.cpp @@ -2,7 +2,7 @@ #include "desktop-widgets/downloadfromdivecomputer.h" #include "core/display.h" #include "core/qthelper.h" -#include "core/subsurface-qt/SettingsObjectWrapper.h" +#include "core/settings/qPrefDiveComputer.h" #include "core/subsurface-string.h" #include "core/uemis.h" #include "desktop-widgets/divelistview.h" @@ -71,12 +71,11 @@ DownloadFromDCWidget::DownloadFromDCWidget(QWidget *parent, Qt::WindowFlags f) : MainWindow *w = MainWindow::instance(); connect(&thread, SIGNAL(finished()), w, SLOT(refreshDisplay())); - auto dc = SettingsObjectWrapper::instance()->dive_computer_settings; - if (!dc->vendor().isEmpty()) { - ui.vendor->setCurrentIndex(ui.vendor->findText(dc->vendor())); - productModel.setStringList(productList[dc->vendor()]); - if (!dc->product().isEmpty()) - ui.product->setCurrentIndex(ui.product->findText(dc->product())); + if (!qPrefDiveComputer::vendor().isEmpty()) { + ui.vendor->setCurrentIndex(ui.vendor->findText(qPrefDiveComputer::vendor())); + productModel.setStringList(productList[qPrefDiveComputer::vendor()]); + if (!qPrefDiveComputer::product().isEmpty()) + ui.product->setCurrentIndex(ui.product->findText(qPrefDiveComputer::product())); } updateState(INITIAL); @@ -84,16 +83,16 @@ DownloadFromDCWidget::DownloadFromDCWidget(QWidget *parent, Qt::WindowFlags f) : ui.downloadCancelRetryButton->setEnabled(true); ui.downloadCancelRetryButton->setText(tr("Download")); - QString deviceText = dc->device(); + QString deviceText = qPrefDiveComputer::device(); #if defined(BT_SUPPORT) ui.bluetoothMode->setText(tr("Choose Bluetooth download mode")); - ui.bluetoothMode->setChecked(dc->download_mode() == DC_TRANSPORT_BLUETOOTH); + ui.bluetoothMode->setChecked(qPrefDiveComputer::download_mode() == DC_TRANSPORT_BLUETOOTH); btDeviceSelectionDialog = 0; connect(ui.bluetoothMode, SIGNAL(stateChanged(int)), this, SLOT(enableBluetoothMode(int))); connect(ui.chooseBluetoothDevice, SIGNAL(clicked()), this, SLOT(selectRemoteBluetoothDevice())); ui.chooseBluetoothDevice->setEnabled(ui.bluetoothMode->isChecked()); if (ui.bluetoothMode->isChecked()) - deviceText = BtDeviceSelectionDialog::formatDeviceText(dc->device(), dc->device_name()); + deviceText = BtDeviceSelectionDialog::formatDeviceText(qPrefDiveComputer::device(), qPrefDiveComputer::device_name()); #else ui.bluetoothMode->hide(); ui.chooseBluetoothDevice->hide(); @@ -288,9 +287,8 @@ void DownloadFromDCWidget::on_downloadCancelRetryButton_clicked() data->setDevName(btDeviceSelectionDialog->getSelectedDeviceAddress()); data->setDevBluetoothName(btDeviceSelectionDialog->getSelectedDeviceName()); } else { - auto dc = SettingsObjectWrapper::instance()->dive_computer_settings; - data->setDevName(dc->device()); - data->setDevBluetoothName(dc->device_name()); + data->setDevName(qPrefDiveComputer::device()); + data->setDevBluetoothName(qPrefDiveComputer::device_name()); } } else // this breaks an "else if" across lines... not happy... @@ -313,13 +311,12 @@ void DownloadFromDCWidget::on_downloadCancelRetryButton_clicked() data->setSaveLog(ui.logToFile->isChecked()); data->setSaveDump(ui.dumpToFile->isChecked()); - auto dc = SettingsObjectWrapper::instance()->dive_computer_settings; - dc->set_vendor(data->vendor()); - dc->set_product(data->product()); - dc->set_device(data->devName()); + qPrefDiveComputer::set_vendor(data->vendor()); + qPrefDiveComputer::set_product(data->product()); + qPrefDiveComputer::set_device(data->devName()); #if defined(BT_SUPPORT) - dc->set_download_mode(ui.bluetoothMode->isChecked() ? DC_TRANSPORT_BLUETOOTH : DC_TRANSPORT_SERIAL); + qPrefDiveComputer::set_download_mode(ui.bluetoothMode->isChecked() ? DC_TRANSPORT_BLUETOOTH : DC_TRANSPORT_SERIAL); #endif // before we start, remember where the dive_table ended diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index cc3bc7c54..f45f27b71 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -61,7 +61,6 @@ #include "core/color.h" #include "core/isocialnetworkintegration.h" #include "core/pluginmanager.h" -#include "core/subsurface-qt/SettingsObjectWrapper.h" #if defined(FBSUPPORT) #include "plugins/facebook/facebook_integration.h" @@ -284,47 +283,48 @@ MainWindow::MainWindow() : QMainWindow(), set_error_cb(&showErrorFromC); // Toolbar Connections related to the Profile Update - SettingsObjectWrapper *sWrapper = SettingsObjectWrapper::instance(); - connect(ui.profCalcAllTissues, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_calcalltissues); - connect(ui.profCalcCeiling, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_calcceiling); - connect(ui.profDcCeiling, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_dcceiling); - connect(ui.profEad, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_ead); - connect(ui.profIncrement3m, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_calcceiling3m); - connect(ui.profMod, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_mod); - connect(ui.profNdl_tts, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_calcndltts); - connect(ui.profHR, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_hrgraph); - connect(ui.profRuler, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_rulergraph); - connect(ui.profSAC, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_show_sac); - connect(ui.profScaled, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_zoomed_plot); - connect(ui.profTogglePicture, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_show_pictures_in_profile); - connect(ui.profTankbar, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_tankbar); - connect(ui.profTissues, &QAction::triggered, sWrapper->techDetails, &qPrefTechnicalDetails::set_percentagegraph); + auto tec = qPrefTechnicalDetails::instance(); + connect(ui.profCalcAllTissues, &QAction::triggered, tec, &qPrefTechnicalDetails::set_calcalltissues); + connect(ui.profCalcCeiling, &QAction::triggered, tec, &qPrefTechnicalDetails::set_calcceiling); + connect(ui.profDcCeiling, &QAction::triggered, tec, &qPrefTechnicalDetails::set_dcceiling); + connect(ui.profEad, &QAction::triggered, tec, &qPrefTechnicalDetails::set_ead); + connect(ui.profIncrement3m, &QAction::triggered, tec, &qPrefTechnicalDetails::set_calcceiling3m); + connect(ui.profMod, &QAction::triggered, tec, &qPrefTechnicalDetails::set_mod); + connect(ui.profNdl_tts, &QAction::triggered, tec, &qPrefTechnicalDetails::set_calcndltts); + connect(ui.profHR, &QAction::triggered, tec, &qPrefTechnicalDetails::set_hrgraph); + connect(ui.profRuler, &QAction::triggered, tec, &qPrefTechnicalDetails::set_rulergraph); + connect(ui.profSAC, &QAction::triggered, tec, &qPrefTechnicalDetails::set_show_sac); + connect(ui.profScaled, &QAction::triggered, tec, &qPrefTechnicalDetails::set_zoomed_plot); + connect(ui.profTogglePicture, &QAction::triggered, tec, &qPrefTechnicalDetails::set_show_pictures_in_profile); + connect(ui.profTankbar, &QAction::triggered, tec, &qPrefTechnicalDetails::set_tankbar); + connect(ui.profTissues, &QAction::triggered, tec, &qPrefTechnicalDetails::set_percentagegraph); connect(ui.profTissues, &QAction::triggered, this, &MainWindow::unsetProfHR); connect(ui.profHR, &QAction::triggered, this, &MainWindow::unsetProfTissues); - connect(ui.profPhe, &QAction::triggered, sWrapper->pp_gas, &PartialPressureGasSettings::setShowPhe); - connect(ui.profPn2, &QAction::triggered, sWrapper->pp_gas, &PartialPressureGasSettings::setShowPn2); - connect(ui.profPO2, &QAction::triggered, sWrapper->pp_gas, &PartialPressureGasSettings::setShowPo2); - - connect(sWrapper->techDetails, &qPrefTechnicalDetails::calcalltissues_changed , graphics(), &ProfileWidget2::actionRequestedReplot); - connect(sWrapper->techDetails, &qPrefTechnicalDetails::calcceiling_changed , graphics(), &ProfileWidget2::actionRequestedReplot); - connect(sWrapper->techDetails, &qPrefTechnicalDetails::dcceiling_changed , graphics(), &ProfileWidget2::actionRequestedReplot); - connect(sWrapper->techDetails, &qPrefTechnicalDetails::ead_changed , graphics(), &ProfileWidget2::actionRequestedReplot); - connect(sWrapper->techDetails, &qPrefTechnicalDetails::calcceiling3m_changed , graphics(), &ProfileWidget2::actionRequestedReplot); - connect(sWrapper->techDetails, &qPrefTechnicalDetails::mod_changed , graphics(), &ProfileWidget2::actionRequestedReplot); - connect(sWrapper->techDetails, &qPrefTechnicalDetails::calcndltts_changed , graphics(), &ProfileWidget2::actionRequestedReplot); - connect(sWrapper->techDetails, &qPrefTechnicalDetails::hrgraph_changed , graphics(), &ProfileWidget2::actionRequestedReplot); - connect(sWrapper->techDetails, &qPrefTechnicalDetails::rulergraph_changed , graphics(), &ProfileWidget2::actionRequestedReplot); - connect(sWrapper->techDetails, &qPrefTechnicalDetails::show_sac_changed , graphics(), &ProfileWidget2::actionRequestedReplot); - connect(sWrapper->techDetails, &qPrefTechnicalDetails::zoomed_plot_changed , graphics(), &ProfileWidget2::actionRequestedReplot); - connect(sWrapper->techDetails, &qPrefTechnicalDetails::show_pictures_in_profile_changed , graphics(), &ProfileWidget2::actionRequestedReplot); - connect(sWrapper->techDetails, &qPrefTechnicalDetails::tankbar_changed , graphics(), &ProfileWidget2::actionRequestedReplot); - connect(sWrapper->techDetails, &qPrefTechnicalDetails::percentagegraph_changed , graphics(), &ProfileWidget2::actionRequestedReplot); - - connect(sWrapper->pp_gas, &PartialPressureGasSettings::showPheChanged, graphics(), &ProfileWidget2::actionRequestedReplot); - connect(sWrapper->pp_gas, &PartialPressureGasSettings::showPn2Changed, graphics(), &ProfileWidget2::actionRequestedReplot); - connect(sWrapper->pp_gas, &PartialPressureGasSettings::showPo2Changed, graphics(), &ProfileWidget2::actionRequestedReplot); + auto pp_gas = qPrefPartialPressureGas::instance(); + connect(ui.profPhe, &QAction::triggered, pp_gas, &qPrefPartialPressureGas::set_phe); + connect(ui.profPn2, &QAction::triggered, pp_gas, &qPrefPartialPressureGas::set_pn2); + connect(ui.profPO2, &QAction::triggered, pp_gas, &qPrefPartialPressureGas::set_po2); + + connect(tec, &qPrefTechnicalDetails::calcalltissues_changed , graphics(), &ProfileWidget2::actionRequestedReplot); + connect(tec, &qPrefTechnicalDetails::calcceiling_changed , graphics(), &ProfileWidget2::actionRequestedReplot); + connect(tec, &qPrefTechnicalDetails::dcceiling_changed , graphics(), &ProfileWidget2::actionRequestedReplot); + connect(tec, &qPrefTechnicalDetails::ead_changed , graphics(), &ProfileWidget2::actionRequestedReplot); + connect(tec, &qPrefTechnicalDetails::calcceiling3m_changed , graphics(), &ProfileWidget2::actionRequestedReplot); + connect(tec, &qPrefTechnicalDetails::mod_changed , graphics(), &ProfileWidget2::actionRequestedReplot); + connect(tec, &qPrefTechnicalDetails::calcndltts_changed , graphics(), &ProfileWidget2::actionRequestedReplot); + connect(tec, &qPrefTechnicalDetails::hrgraph_changed , graphics(), &ProfileWidget2::actionRequestedReplot); + connect(tec, &qPrefTechnicalDetails::rulergraph_changed , graphics(), &ProfileWidget2::actionRequestedReplot); + connect(tec, &qPrefTechnicalDetails::show_sac_changed , graphics(), &ProfileWidget2::actionRequestedReplot); + connect(tec, &qPrefTechnicalDetails::zoomed_plot_changed , graphics(), &ProfileWidget2::actionRequestedReplot); + connect(tec, &qPrefTechnicalDetails::show_pictures_in_profile_changed , graphics(), &ProfileWidget2::actionRequestedReplot); + connect(tec, &qPrefTechnicalDetails::tankbar_changed , graphics(), &ProfileWidget2::actionRequestedReplot); + connect(tec, &qPrefTechnicalDetails::percentagegraph_changed , graphics(), &ProfileWidget2::actionRequestedReplot); + + connect(pp_gas, &qPrefPartialPressureGas::phe_changed, graphics(), &ProfileWidget2::actionRequestedReplot); + connect(pp_gas, &qPrefPartialPressureGas::pn2_changed, graphics(), &ProfileWidget2::actionRequestedReplot); + connect(pp_gas, &qPrefPartialPressureGas::po2_changed, graphics(), &ProfileWidget2::actionRequestedReplot); // now let's set up some connections connect(graphics(), &ProfileWidget2::enableToolbar ,this, &MainWindow::setEnabledToolbar); @@ -336,23 +336,23 @@ MainWindow::MainWindow() : QMainWindow(), connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), graphics(), SLOT(settingsChanged())); - ui.profCalcAllTissues->setChecked(sWrapper->techDetails->calcalltissues()); - ui.profCalcCeiling->setChecked(sWrapper->techDetails->calcceiling()); - ui.profDcCeiling->setChecked(sWrapper->techDetails->dcceiling()); - ui.profEad->setChecked(sWrapper->techDetails->ead()); - ui.profIncrement3m->setChecked(sWrapper->techDetails->calcceiling3m()); - ui.profMod->setChecked(sWrapper->techDetails->mod()); - ui.profNdl_tts->setChecked(sWrapper->techDetails->calcndltts()); - ui.profPhe->setChecked(sWrapper->pp_gas->showPhe()); - ui.profPn2->setChecked(sWrapper->pp_gas->showPn2()); - ui.profPO2->setChecked(sWrapper->pp_gas->showPo2()); - ui.profHR->setChecked(sWrapper->techDetails->hrgraph()); - ui.profRuler->setChecked(sWrapper->techDetails->rulergraph()); - ui.profSAC->setChecked(sWrapper->techDetails->show_sac()); - ui.profTogglePicture->setChecked(sWrapper->techDetails->show_pictures_in_profile()); - ui.profTankbar->setChecked(sWrapper->techDetails->tankbar()); - ui.profTissues->setChecked(sWrapper->techDetails->percentagegraph()); - ui.profScaled->setChecked(sWrapper->techDetails->zoomed_plot()); + ui.profCalcAllTissues->setChecked(qPrefTechnicalDetails::calcalltissues()); + ui.profCalcCeiling->setChecked(qPrefTechnicalDetails::calcceiling()); + ui.profDcCeiling->setChecked(qPrefTechnicalDetails::dcceiling()); + ui.profEad->setChecked(qPrefTechnicalDetails::ead()); + ui.profIncrement3m->setChecked(qPrefTechnicalDetails::calcceiling3m()); + ui.profMod->setChecked(qPrefTechnicalDetails::mod()); + ui.profNdl_tts->setChecked(qPrefTechnicalDetails::calcndltts()); + ui.profPhe->setChecked(pp_gas->phe()); + ui.profPn2->setChecked(pp_gas->pn2()); + ui.profPO2->setChecked(pp_gas->po2()); + ui.profHR->setChecked(qPrefTechnicalDetails::hrgraph()); + ui.profRuler->setChecked(qPrefTechnicalDetails::rulergraph()); + ui.profSAC->setChecked(qPrefTechnicalDetails::show_sac()); + ui.profTogglePicture->setChecked(qPrefTechnicalDetails::show_pictures_in_profile()); + ui.profTankbar->setChecked(qPrefTechnicalDetails::tankbar()); + ui.profTissues->setChecked(qPrefTechnicalDetails::percentagegraph()); + ui.profScaled->setChecked(qPrefTechnicalDetails::zoomed_plot()); // full screen support is buggy on Windows and Ubuntu. // require the FULLSCREEN_SUPPORT macro to enable it! @@ -549,13 +549,10 @@ void MainWindow::on_actionNew_triggered() static QString lastUsedDir() { - QSettings settings; QString lastDir = QDir::homePath(); - settings.beginGroup("FileDialog"); - if (settings.contains("LastDir")) - if (QDir(settings.value("LastDir").toString()).exists()) - lastDir = settings.value("LastDir").toString(); + if (QDir(qPrefDisplay::lastDir()).exists()) + lastDir = qPrefDisplay::lastDir(); return lastDir; } @@ -620,7 +617,7 @@ void MainWindow::on_actionCloudstorageopen_triggered() showProgressBar(); QByteArray fileNamePtr = QFile::encodeName(filename); - if (!parse_file(fileNamePtr.data())) + if (!parse_file(fileNamePtr.data(), &dive_table)) setCurrentFile(fileNamePtr.data()); process_dives(false, false); hideProgressBar(); @@ -773,9 +770,7 @@ void MainWindow::on_actionClose_triggered() void MainWindow::updateLastUsedDir(const QString &dir) { - QSettings s; - s.beginGroup("FileDialog"); - s.setValue("LastDir", dir); + qPrefDisplay::set_lastDir(dir); } void MainWindow::on_actionPrint_triggered() @@ -1187,12 +1182,10 @@ void MainWindow::on_actionViewAll_triggered() listGlobeSizes.append(lrint(appW * 0.3)); } - QSettings settings; - settings.beginGroup("MainWindow"); - if (settings.value("mainSplitter").isValid()) { - ui.mainSplitter->restoreState(settings.value("mainSplitter").toByteArray()); - ui.topSplitter->restoreState(settings.value("topSplitter").toByteArray()); - ui.bottomSplitter->restoreState(settings.value("bottomSplitter").toByteArray()); + if (qPrefDisplay::mainSplitter() != "") { + ui.mainSplitter->restoreState(qPrefDisplay::mainSplitter()); + ui.topSplitter->restoreState(qPrefDisplay::topSplitter()); + ui.bottomSplitter->restoreState(qPrefDisplay::bottomSplitter()); if (ui.mainSplitter->sizes().first() == 0 || ui.mainSplitter->sizes().last() == 0) ui.mainSplitter->setSizes(mainSizes); if (ui.topSplitter->sizes().first() == 0 || ui.topSplitter->sizes().last() == 0) @@ -1225,10 +1218,8 @@ void MainWindow::enterEditState() int appW = qApp->desktop()->size().width(); QList<int> infoProfileSizes { (int)lrint(appW * 0.3), (int)lrint(appW * 0.7) }; - QSettings settings; - settings.beginGroup("MainWindow"); - if (settings.value("mainSplitter").isValid()) { - ui.topSplitter->restoreState(settings.value("topSplitter").toByteArray()); + if (qPrefDisplay::mainSplitter() != "") { + ui.topSplitter->restoreState(qPrefDisplay::topSplitter()); if (ui.topSplitter->sizes().first() == 0 || ui.topSplitter->sizes().last() == 0) ui.topSplitter->setSizes(infoProfileSizes); } else { @@ -1278,11 +1269,9 @@ void MainWindow::beginChangeState(CurrentState s) void MainWindow::saveSplitterSizes() { - QSettings settings; - settings.beginGroup("MainWindow"); - settings.setValue("mainSplitter", ui.mainSplitter->saveState()); - settings.setValue("topSplitter", ui.topSplitter->saveState()); - settings.setValue("bottomSplitter", ui.bottomSplitter->saveState()); + qPrefDisplay::set_mainSplitter(ui.mainSplitter->saveState()); + qPrefDisplay::set_topSplitter(ui.topSplitter->saveState()); + qPrefDisplay::set_bottomSplitter(ui.bottomSplitter->saveState()); } void MainWindow::on_actionPreviousDC_triggered() @@ -1469,17 +1458,14 @@ bool MainWindow::askSaveChanges() void MainWindow::initialUiSetup() { - QSettings settings; - settings.beginGroup("MainWindow"); - if (settings.value("maximized", isMaximized()).value<bool>()) { + if (qPrefDisplay::maximized()) { showMaximized(); } else { - restoreGeometry(settings.value("geometry").toByteArray()); - restoreState(settings.value("windowState", 0).toByteArray()); + restoreGeometry(qPrefDisplay::geometry()); + restoreState(qPrefDisplay::windowState()); } - enterState((CurrentState)settings.value("lastState", 0).toInt()); - settings.endGroup(); + enterState((CurrentState)qPrefDisplay::lastState()); show(); } @@ -1511,7 +1497,7 @@ void MainWindow::checkSurvey() // wait a week for production versions, but not at all for non-tagged builds int waitTime = 7; QDate firstUse42 = s.value("FirstUse42").toDate(); - if (run_survey || (firstUse42.daysTo(QDate().currentDate()) > waitTime && !s.contains("SurveyDone"))) { + if (run_survey || (firstUse42.daysTo(QDate().currentDate()) > waitTime && qPrefDisplay::UserSurvey() == "")) { if (!survey) survey = new UserSurvey(this); survey->show(); @@ -1521,16 +1507,12 @@ void MainWindow::checkSurvey() void MainWindow::writeSettings() { - QSettings settings; - - settings.beginGroup("MainWindow"); - settings.setValue("geometry", saveGeometry()); - settings.setValue("windowState", saveState()); - settings.setValue("maximized", isMaximized()); - settings.setValue("lastState", (int)state); + qPrefDisplay::set_geometry(saveGeometry()); + qPrefDisplay::set_windowState(saveState()); + qPrefDisplay::set_maximized(isMaximized()); + qPrefDisplay::set_lastState((int)state); if (state == VIEWALL) saveSplitterSizes(); - settings.endGroup(); } void MainWindow::closeEvent(QCloseEvent *event) @@ -1776,7 +1758,7 @@ void MainWindow::importFiles(const QStringList fileNames) for (int i = 0; i < fileNames.size(); ++i) { fileNamePtr = QFile::encodeName(fileNames.at(i)); - parse_file(fileNamePtr.data()); + parse_file(fileNamePtr.data(), &dive_table); } process_dives(true, false); refreshDisplay(); @@ -1823,7 +1805,7 @@ void MainWindow::loadFiles(const QStringList fileNames) showProgressBar(); for (int i = 0; i < fileNames.size(); ++i) { fileNamePtr = QFile::encodeName(fileNames.at(i)); - if (!parse_file(fileNamePtr.data())) { + if (!parse_file(fileNamePtr.data(), &dive_table)) { setCurrentFile(fileNamePtr.data()); addRecentFile(fileNamePtr, false); } @@ -1910,7 +1892,7 @@ void MainWindow::editCurrentDive() void MainWindow::turnOffNdlTts() { - SettingsObjectWrapper::instance()->techDetails->set_calcndltts(false); + qPrefTechnicalDetails::set_calcndltts(false); } #undef TOOLBOX_PREF_PROFILE @@ -2046,16 +2028,12 @@ void MainWindow::hideProgressBar() void MainWindow::unsetProfHR() { - SettingsObjectWrapper *sWrapper = SettingsObjectWrapper::instance(); - ui.profHR->setChecked(false); - sWrapper->techDetails->set_hrgraph(false); + qPrefTechnicalDetails::set_hrgraph(false); } void MainWindow::unsetProfTissues() { - SettingsObjectWrapper *sWrapper = SettingsObjectWrapper::instance(); - ui.profTissues->setChecked(false); - sWrapper->techDetails->set_percentagegraph(false); + qPrefTechnicalDetails::set_percentagegraph(false); } diff --git a/desktop-widgets/mainwindow.h b/desktop-widgets/mainwindow.h index 06365a8e6..7bd33cbf0 100644 --- a/desktop-widgets/mainwindow.h +++ b/desktop-widgets/mainwindow.h @@ -27,7 +27,6 @@ class QItemSelection; class DiveListView; class MainTab; class QWebView; -class QSettings; class UpdateManager; class UserManual; class DivePlannerWidget; diff --git a/desktop-widgets/plugins/facebook/facebookconnectwidget.cpp b/desktop-widgets/plugins/facebook/facebookconnectwidget.cpp index d76cc88cd..37410d2d6 100644 --- a/desktop-widgets/plugins/facebook/facebookconnectwidget.cpp +++ b/desktop-widgets/plugins/facebook/facebookconnectwidget.cpp @@ -27,7 +27,7 @@ #include "core/pref.h" #include "core/qthelper.h" -#include "core/subsurface-qt/SettingsObjectWrapper.h" +#include "core/settings/qPrefFacebook.h" #include "ui_socialnetworksdialog.h" #include "ui_facebookconnectwidget.h" @@ -88,18 +88,16 @@ void FacebookManager::tryLogin(const QUrl& loginResponse) int to = result.indexOf("&expires_in"); QString securityToken = result.mid(from, to-from); - auto fb = qPrefFacebook::instance(); - fb->set_access_token(securityToken); + qPrefFacebook::set_access_token(securityToken); qCDebug(lcFacebook) << "Got securityToken" << securityToken; requestUserId(); } void FacebookManager::logout() { - auto fb = qPrefFacebook::instance(); - fb->set_access_token(QString()); - fb->set_user_id(QString()); - fb->set_album_id(QString()); + qPrefFacebook::set_access_token(QString()); + qPrefFacebook::set_user_id(QString()); + qPrefFacebook::set_album_id(QString()); emit justLoggedOut(true); } @@ -116,15 +114,14 @@ void FacebookManager::albumListReceived() QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender()); QJsonDocument albumsDoc = QJsonDocument::fromJson(reply->readAll()); QJsonArray albumObj = albumsDoc.object().value("data").toArray(); - auto fb = qPrefFacebook::instance(); reply->deleteLater(); foreach(const QJsonValue &v, albumObj){ QJsonObject obj = v.toObject(); if (obj.value("name").toString() == fbInfo.albumName) { - fb->set_album_id(obj.value("id").toString()); + qPrefFacebook::set_album_id(obj.value("id").toString()); qCDebug(lcFacebook) << "Album" << fbInfo.albumName << "already exists, using id" << obj.value("id").toString(); - emit albumIdReceived(fb->album_id()); + emit albumIdReceived(qPrefFacebook::album_id()); return; } } @@ -158,9 +155,8 @@ void FacebookManager::facebookAlbumCreated() if (album.contains("id")) { qCDebug(lcFacebook) << "Album" << fbInfo.albumName << "created successfully with id" << album.value("id").toString(); - auto fb = qPrefFacebook::instance(); - fb->set_album_id(album.value("id").toString()); - emit albumIdReceived(fb->album_id()); + qPrefFacebook::set_album_id(album.value("id").toString()); + emit albumIdReceived(qPrefFacebook::album_id()); return; } else { qCDebug(lcFacebook) << "It was not possible to create the album with name" << fbInfo.albumName; @@ -168,8 +164,7 @@ void FacebookManager::facebookAlbumCreated() // FIXME: we are lacking 'user_photos' facebook permission to create an album, // but we are able to upload the image to Facebook (album will be named 'Subsurface Photos') qCDebug(lcFacebook) << "But we are still able to upload data. Album name will be 'Subsurface Photos'"; - auto fb = qPrefFacebook::instance(); - emit albumIdReceived(fb->album_id()); + emit albumIdReceived(qPrefFacebook::album_id()); } } @@ -189,7 +184,7 @@ void FacebookManager::userIdReceived() QJsonObject obj = jsonDoc.object(); if (obj.keys().contains("id")) { qCDebug(lcFacebook) << "User id requested successfully:" << obj.value("id").toString(); - qPrefFacebook::instance()->set_user_id(obj.value("id").toString()); + qPrefFacebook::set_user_id(obj.value("id").toString()); emit sendMessage(tr("Facebook logged in successfully")); emit justLoggedIn(true); } else { diff --git a/desktop-widgets/preferences/preferences_defaults.cpp b/desktop-widgets/preferences/preferences_defaults.cpp index 4d8aef610..b8af84b91 100644 --- a/desktop-widgets/preferences/preferences_defaults.cpp +++ b/desktop-widgets/preferences/preferences_defaults.cpp @@ -2,7 +2,6 @@ #include "preferences_defaults.h" #include "ui_preferences_defaults.h" #include "core/dive.h" -#include "core/subsurface-qt/SettingsObjectWrapper.h" #include "core/settings/qPref.h" #include <QFileDialog> @@ -61,24 +60,24 @@ void PreferencesDefaults::on_extractVideoThumbnails_toggled(bool toggled) void PreferencesDefaults::refreshSettings() { - ui->font->setCurrentFont(QString(prefs.divelist_font)); - ui->fontsize->setValue(prefs.font_size); - ui->defaultfilename->setText(prefs.default_filename); - ui->noDefaultFile->setChecked(prefs.default_file_behavior == NO_DEFAULT_FILE); - ui->cloudDefaultFile->setChecked(prefs.default_file_behavior == CLOUD_DEFAULT_FILE); - ui->localDefaultFile->setChecked(prefs.default_file_behavior == LOCAL_DEFAULT_FILE); + ui->font->setCurrentFont(qPrefDisplay::divelist_font()); + ui->fontsize->setValue(qPrefDisplay::font_size()); + ui->defaultfilename->setText(qPrefGeneral::default_filename()); + ui->noDefaultFile->setChecked(qPrefGeneral::default_file_behavior() == NO_DEFAULT_FILE); + ui->cloudDefaultFile->setChecked(qPrefGeneral::default_file_behavior() == CLOUD_DEFAULT_FILE); + ui->localDefaultFile->setChecked(qPrefGeneral::default_file_behavior() == LOCAL_DEFAULT_FILE); ui->default_cylinder->clear(); for (int i = 0; tank_info[i].name != NULL && i < MAX_TANK_INFO; i++) { ui->default_cylinder->addItem(tank_info[i].name); - if (prefs.default_cylinder && strcmp(tank_info[i].name, prefs.default_cylinder) == 0) + if (qPrefGeneral::default_cylinder() == tank_info[i].name) ui->default_cylinder->setCurrentIndex(i); } - ui->displayinvalid->setChecked(prefs.display_invalid_dives); - ui->velocitySlider->setValue(prefs.animation_speed); - ui->btnUseDefaultFile->setChecked(prefs.use_default_file); + ui->displayinvalid->setChecked(qPrefDisplay::display_invalid_dives()); + ui->velocitySlider->setValue(qPrefDisplay::animation_speed()); + ui->btnUseDefaultFile->setChecked(qPrefGeneral::use_default_file()); - if (prefs.cloud_verification_status == qPref::CS_VERIFIED) { + if (qPrefCloudStorage::cloud_verification_status() == qPref::CS_VERIFIED) { ui->cloudDefaultFile->setEnabled(true); } else { if (ui->cloudDefaultFile->isChecked()) @@ -86,40 +85,37 @@ void PreferencesDefaults::refreshSettings() ui->cloudDefaultFile->setEnabled(false); } - ui->defaultfilename->setEnabled(prefs.default_file_behavior == LOCAL_DEFAULT_FILE); - ui->btnUseDefaultFile->setEnabled(prefs.default_file_behavior == LOCAL_DEFAULT_FILE); - ui->chooseFile->setEnabled(prefs.default_file_behavior == LOCAL_DEFAULT_FILE); + ui->defaultfilename->setEnabled(qPrefGeneral::default_file_behavior() == LOCAL_DEFAULT_FILE); + ui->btnUseDefaultFile->setEnabled(qPrefGeneral::default_file_behavior() == LOCAL_DEFAULT_FILE); + ui->chooseFile->setEnabled(qPrefGeneral::default_file_behavior() == LOCAL_DEFAULT_FILE); - ui->videoThumbnailPosition->setEnabled(prefs.extract_video_thumbnails); - ui->ffmpegExecutable->setEnabled(prefs.extract_video_thumbnails); - ui->ffmpegFile->setEnabled(prefs.extract_video_thumbnails); + ui->videoThumbnailPosition->setEnabled(qPrefGeneral::extract_video_thumbnails()); + ui->ffmpegExecutable->setEnabled(qPrefGeneral::extract_video_thumbnails()); + ui->ffmpegFile->setEnabled(qPrefGeneral::extract_video_thumbnails()); - ui->extractVideoThumbnails->setChecked(prefs.extract_video_thumbnails); - ui->videoThumbnailPosition->setValue(prefs.extract_video_thumbnails_position); - ui->ffmpegExecutable->setText(prefs.ffmpeg_executable); + ui->extractVideoThumbnails->setChecked(qPrefGeneral::extract_video_thumbnails()); + ui->videoThumbnailPosition->setValue(qPrefGeneral::extract_video_thumbnails_position()); + ui->ffmpegExecutable->setText(qPrefGeneral::ffmpeg_executable()); } void PreferencesDefaults::syncSettings() { - auto general = SettingsObjectWrapper::instance()->general_settings; - general->setDefaultFilename(ui->defaultfilename->text()); - general->setDefaultCylinder(ui->default_cylinder->currentText()); - general->setUseDefaultFile(ui->btnUseDefaultFile->isChecked()); + auto general = qPrefGeneral::instance(); + general->set_default_filename(ui->defaultfilename->text()); + general->set_default_cylinder(ui->default_cylinder->currentText()); + general->set_use_default_file(ui->btnUseDefaultFile->isChecked()); if (ui->noDefaultFile->isChecked()) - general->setDefaultFileBehavior(NO_DEFAULT_FILE); + general->set_default_file_behavior(NO_DEFAULT_FILE); else if (ui->localDefaultFile->isChecked()) - general->setDefaultFileBehavior(LOCAL_DEFAULT_FILE); + general->set_default_file_behavior(LOCAL_DEFAULT_FILE); else if (ui->cloudDefaultFile->isChecked()) - general->setDefaultFileBehavior(CLOUD_DEFAULT_FILE); - general->setExtractVideoThumbnails(ui->extractVideoThumbnails->isChecked()); - general->setExtractVideoThumbnailsPosition(ui->videoThumbnailPosition->value()); - general->setFfmpegExecutable(ui->ffmpegExecutable->text()); - - auto display = qPrefDisplay::instance(); - display->set_divelist_font(ui->font->currentFont().toString()); - display->set_font_size(ui->fontsize->value()); - display->set_display_invalid_dives(ui->displayinvalid->isChecked()); - - auto animation = qPrefAnimations::instance(); - animation->set_animation_speed(ui->velocitySlider->value()); + general->set_default_file_behavior(CLOUD_DEFAULT_FILE); + general->set_extract_video_thumbnails(ui->extractVideoThumbnails->isChecked()); + general->set_extract_video_thumbnails_position(ui->videoThumbnailPosition->value()); + general->set_ffmpeg_executable(ui->ffmpegExecutable->text()); + + qPrefDisplay::set_divelist_font(ui->font->currentFont().toString()); + qPrefDisplay::set_font_size(ui->fontsize->value()); + qPrefDisplay::set_display_invalid_dives(ui->displayinvalid->isChecked()); + qPrefDisplay::set_animation_speed(ui->velocitySlider->value()); } diff --git a/desktop-widgets/preferences/preferences_georeference.cpp b/desktop-widgets/preferences/preferences_georeference.cpp index cb75cb646..40196e44f 100644 --- a/desktop-widgets/preferences/preferences_georeference.cpp +++ b/desktop-widgets/preferences/preferences_georeference.cpp @@ -2,7 +2,7 @@ #include "preferences_georeference.h" #include "ui_preferences_georeference.h" #include "core/qthelper.h" -#include "core/subsurface-qt/SettingsObjectWrapper.h" +#include "core/settings/qPrefGeocoding.h" #include "qt-models/divelocationmodel.h" #include <ctime> @@ -30,8 +30,7 @@ void PreferencesGeoreference::refreshSettings() void PreferencesGeoreference::syncSettings() { - auto geocoding = SettingsObjectWrapper::instance()->geocoding; - geocoding->setFirstTaxonomyCategory((taxonomy_category) ui->first_item->currentIndex()); - geocoding->setSecondTaxonomyCategory((taxonomy_category) ui->second_item->currentIndex()); - geocoding->setThirdTaxonomyCategory((taxonomy_category) ui->third_item->currentIndex()); + qPrefGeocoding::set_first_taxonomy_category((taxonomy_category) ui->first_item->currentIndex()); + qPrefGeocoding::set_second_taxonomy_category((taxonomy_category) ui->second_item->currentIndex()); + qPrefGeocoding::set_third_taxonomy_category((taxonomy_category) ui->third_item->currentIndex()); } diff --git a/desktop-widgets/preferences/preferences_graph.cpp b/desktop-widgets/preferences/preferences_graph.cpp index 6ddd7250a..29b749b4e 100644 --- a/desktop-widgets/preferences/preferences_graph.cpp +++ b/desktop-widgets/preferences/preferences_graph.cpp @@ -1,7 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 #include "preferences_graph.h" #include "ui_preferences_graph.h" -#include "core/subsurface-qt/SettingsObjectWrapper.h" +#include "core/settings/qPrefGeneral.h" +#include "core/settings/qPrefTechnicalDetails.h" +#include "core/settings/qPrefPartialPressureGas.h" #include <QMessageBox> #include "qt-models/models.h" @@ -52,32 +54,29 @@ void PreferencesGraph::refreshSettings() void PreferencesGraph::syncSettings() { - auto general = SettingsObjectWrapper::instance()->general_settings; - general->setDefaultSetPoint(lrint(ui->defaultSetpoint->value() * 1000.0)); - general->setO2Consumption(lrint(ui->psro2rate->value() *1000.0)); - general->setPscrRatio(lrint(1000.0 / ui->pscrfactor->value())); - general->setAutoRecalculateThumbnails(ui->auto_recalculate_thumbnails->isChecked()); + qPrefGeneral::set_defaultsetpoint(lrint(ui->defaultSetpoint->value() * 1000.0)); + qPrefGeneral::set_o2consumption(lrint(ui->psro2rate->value() *1000.0)); + qPrefGeneral::set_pscr_ratio(lrint(1000.0 / ui->pscrfactor->value())); + qPrefGeneral::set_auto_recalculate_thumbnails(ui->auto_recalculate_thumbnails->isChecked()); - auto pp_gas = SettingsObjectWrapper::instance()->pp_gas; - pp_gas->setPheThreshold(ui->pheThreshold->value()); - pp_gas->setPo2ThresholdMax(ui->po2ThresholdMax->value()); - pp_gas->setPo2ThresholdMin(ui->po2ThresholdMin->value()); - pp_gas->setPn2Threshold(ui->pn2Threshold->value()); + qPrefPartialPressureGas::set_phe_threshold(ui->pheThreshold->value()); + qPrefPartialPressureGas::set_po2_threshold_max(ui->po2ThresholdMax->value()); + qPrefPartialPressureGas::set_po2_threshold_min(ui->po2ThresholdMin->value()); + qPrefPartialPressureGas::set_pn2_threshold(ui->pn2Threshold->value()); - auto tech = qPrefTechnicalDetails::instance(); - tech->set_modpO2(ui->maxpo2->value()); - tech->set_redceiling(ui->red_ceiling->isChecked()); + qPrefTechnicalDetails::set_modpO2(ui->maxpo2->value()); + qPrefTechnicalDetails::set_redceiling(ui->red_ceiling->isChecked()); prefs.planner_deco_mode = ui->buehlmann->isChecked() ? BUEHLMANN : VPMB; - tech->set_gflow(ui->gflow->value()); - tech->set_gfhigh(ui->gfhigh->value()); - tech->set_vpmb_conservatism(ui->vpmb_conservatism->value()); - tech->set_show_ccr_setpoint(ui->show_ccr_setpoint->isChecked()); - tech->set_show_ccr_sensors(ui->show_ccr_sensors->isChecked()); - tech->set_show_scr_ocpo2(ui->show_scr_ocpo2->isChecked()); - tech->set_display_unused_tanks(ui->display_unused_tanks->isChecked()); - tech->set_show_average_depth(ui->show_average_depth->isChecked()); - tech->set_show_icd(ui->show_icd->isChecked()); - tech->set_display_deco_mode(ui->vpmb->isChecked() ? VPMB : BUEHLMANN); + qPrefTechnicalDetails::set_gflow(ui->gflow->value()); + qPrefTechnicalDetails::set_gfhigh(ui->gfhigh->value()); + qPrefTechnicalDetails::set_vpmb_conservatism(ui->vpmb_conservatism->value()); + qPrefTechnicalDetails::set_show_ccr_setpoint(ui->show_ccr_setpoint->isChecked()); + qPrefTechnicalDetails::set_show_ccr_sensors(ui->show_ccr_sensors->isChecked()); + qPrefTechnicalDetails::set_show_scr_ocpo2(ui->show_scr_ocpo2->isChecked()); + qPrefTechnicalDetails::set_display_unused_tanks(ui->display_unused_tanks->isChecked()); + qPrefTechnicalDetails::set_show_average_depth(ui->show_average_depth->isChecked()); + qPrefTechnicalDetails::set_show_icd(ui->show_icd->isChecked()); + qPrefTechnicalDetails::set_display_deco_mode(ui->vpmb->isChecked() ? VPMB : BUEHLMANN); } #define DANGER_GF (gf > 100) ? "* { color: red; }" : "" diff --git a/desktop-widgets/preferences/preferences_language.cpp b/desktop-widgets/preferences/preferences_language.cpp index e4a63ae9e..76763be14 100644 --- a/desktop-widgets/preferences/preferences_language.cpp +++ b/desktop-widgets/preferences/preferences_language.cpp @@ -2,7 +2,7 @@ #include "preferences_language.h" #include "ui_preferences_language.h" #include "core/qthelper.h" -#include "core/subsurface-qt/SettingsObjectWrapper.h" +#include "core/settings/qPrefLanguage.h" #include <QApplication> #include <QMessageBox> @@ -81,16 +81,14 @@ void PreferencesLanguage::syncSettings() if (languages.count()) currentLocale = m->data(languages.first(),Qt::UserRole).toString(); - - auto lang = SettingsObjectWrapper::instance()->language_settings; - lang->setLanguage(currentText); - lang->setLangLocale(currentLocale); - lang->setUseSystemLanguage(ui->languageSystemDefault->isChecked()); - lang->setTimeFormatOverride(!ui->timeFormatSystemDefault->isChecked()); - lang->setDateFormatOverride(!ui->dateFormatSystemDefault->isChecked()); - lang->setTimeFormat(ui->timeFormatEntry->currentText()); - lang->setDateFormat(ui->dateFormatEntry->currentText()); - lang->setDateFormatShort(ui->shortDateFormatEntry->text()); + qPrefLanguage::set_language(currentText); + qPrefLanguage::set_lang_locale(currentLocale); + qPrefLanguage::set_use_system_language(ui->languageSystemDefault->isChecked()); + qPrefLanguage::set_time_format_override(!ui->timeFormatSystemDefault->isChecked()); + qPrefLanguage::set_date_format_override(!ui->dateFormatSystemDefault->isChecked()); + qPrefLanguage::set_time_format(ui->timeFormatEntry->currentText()); + qPrefLanguage::set_date_format(ui->dateFormatEntry->currentText()); + qPrefLanguage::set_date_format_short(ui->shortDateFormatEntry->text()); uiLanguage(NULL); QString qDateTimeWeb = tr("These will be used as is. This might not be what you intended.\nSee http://doc.qt.io/qt-5/qdatetime.html#toString"); diff --git a/desktop-widgets/preferences/preferences_network.cpp b/desktop-widgets/preferences/preferences_network.cpp index bb72bef19..cb827f578 100644 --- a/desktop-widgets/preferences/preferences_network.cpp +++ b/desktop-widgets/preferences/preferences_network.cpp @@ -4,7 +4,6 @@ #include "subsurfacewebservices.h" #include "core/cloudstorage.h" #include "core/dive.h" -#include "core/subsurface-qt/SettingsObjectWrapper.h" #include "core/settings/qPref.h" #include <QNetworkProxy> diff --git a/desktop-widgets/preferences/preferences_units.cpp b/desktop-widgets/preferences/preferences_units.cpp index 7985ffb0c..eaef36b39 100644 --- a/desktop-widgets/preferences/preferences_units.cpp +++ b/desktop-widgets/preferences/preferences_units.cpp @@ -2,7 +2,7 @@ #include "preferences_units.h" #include "ui_preferences_units.h" #include "core/qthelper.h" -#include "core/subsurface-qt/SettingsObjectWrapper.h" +#include "core/settings/qPrefUnit.h" PreferencesUnits::PreferencesUnits(): AbstractPreferencesWidget(tr("Units"),QIcon(":units-icon"),1), ui(new Ui::PreferencesUnits()) { @@ -47,18 +47,17 @@ void PreferencesUnits::refreshSettings() void PreferencesUnits::syncSettings() { - auto units = SettingsObjectWrapper::instance()->unit_settings; QString unitSystem[] = {"metric", "imperial", "personal"}; short unitValue = ui->metric->isChecked() ? METRIC : (ui->imperial->isChecked() ? IMPERIAL : PERSONALIZE); - units->set_unit_system(unitSystem[unitValue]); - units->set_temperature(ui->fahrenheit->isChecked() ? units::FAHRENHEIT : units::CELSIUS); - units->set_length(ui->feet->isChecked() ? units::FEET : units::METERS); - units->set_pressure(ui->psi->isChecked() ? units::PSI : units::BAR); - units->set_volume(ui->cuft->isChecked() ? units::CUFT : units::LITER); - units->set_weight(ui->lbs->isChecked() ? units::LBS : units::KG); - units->set_vertical_speed_time(ui->vertical_speed_minutes->isChecked() ? units::MINUTES : units::SECONDS); - units->set_coordinates_traditional(ui->gpsTraditional->isChecked()); - units->set_duration_units(ui->duration_mixed->isChecked() ? units::MIXED : (ui->duration_no_hours->isChecked() ? units::MINUTES_ONLY : units::ALWAYS_HOURS)); - units->set_show_units_table(ui->show_units_table->isChecked()); + qPrefUnits::set_unit_system(unitSystem[unitValue]); + qPrefUnits::set_temperature(ui->fahrenheit->isChecked() ? units::FAHRENHEIT : units::CELSIUS); + qPrefUnits::set_length(ui->feet->isChecked() ? units::FEET : units::METERS); + qPrefUnits::set_pressure(ui->psi->isChecked() ? units::PSI : units::BAR); + qPrefUnits::set_volume(ui->cuft->isChecked() ? units::CUFT : units::LITER); + qPrefUnits::set_weight(ui->lbs->isChecked() ? units::LBS : units::KG); + qPrefUnits::set_vertical_speed_time(ui->vertical_speed_minutes->isChecked() ? units::MINUTES : units::SECONDS); + qPrefUnits::set_coordinates_traditional(ui->gpsTraditional->isChecked()); + qPrefUnits::set_duration_units(ui->duration_mixed->isChecked() ? units::MIXED : (ui->duration_no_hours->isChecked() ? units::MINUTES_ONLY : units::ALWAYS_HOURS)); + qPrefUnits::set_show_units_table(ui->show_units_table->isChecked()); } diff --git a/desktop-widgets/preferences/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp index 49b1f87bd..3b16260d2 100644 --- a/desktop-widgets/preferences/preferencesdialog.cpp +++ b/desktop-widgets/preferences/preferencesdialog.cpp @@ -32,12 +32,6 @@ void PreferencesDialog::emitSettingsChanged() PreferencesDialog::PreferencesDialog() { - //FIXME: This looks wrong. - //QSettings s; - //s.beginGroup("GeneralSettings"); - //s.setValue("default_directory", system_default_directory()); - //s.endGroup(); - setWindowIcon(QIcon(":subsurface-icon")); pagesList = new QListWidget(); pagesStack = new QStackedWidget(); diff --git a/desktop-widgets/printer.cpp b/desktop-widgets/printer.cpp index 64acf81c0..780dce2ba 100644 --- a/desktop-widgets/printer.cpp +++ b/desktop-widgets/printer.cpp @@ -3,6 +3,7 @@ #include "templatelayout.h" #include "core/statistics.h" #include "core/qthelper.h" +#include "core/settings/qPrefDisplay.h" #include <algorithm> #include <QPainter> @@ -135,7 +136,7 @@ void Printer::render(int Pages = 0) // keep original preferences QPointer<ProfileWidget2> profile = MainWindow::instance()->graphics(); int profileFrameStyle = profile->frameStyle(); - int animationOriginal = prefs.animation_speed; + int animationOriginal = qPrefDisplay::animation_speed(); double fontScale = profile->getFontPrintScale(); double printFontScale = 1.0; @@ -143,7 +144,7 @@ void Printer::render(int Pages = 0) profile->setFrameStyle(QFrame::NoFrame); profile->setPrintMode(true, !printOptions->color_selected); profile->setToolTipVisibile(false); - prefs.animation_speed = 0; + qPrefDisplay::set_animation_speed(0); // render the Qwebview QPainter painter; @@ -201,7 +202,7 @@ void Printer::render(int Pages = 0) #else profile->resize(originalSize); #endif - prefs.animation_speed = animationOriginal; + qPrefDisplay::set_animation_speed(animationOriginal); //replot the dive after returning the settings profile->plotDive(0, true, true); diff --git a/desktop-widgets/subsurfacewebservices.cpp b/desktop-widgets/subsurfacewebservices.cpp index d1af7715d..4d795237c 100644 --- a/desktop-widgets/subsurfacewebservices.cpp +++ b/desktop-widgets/subsurfacewebservices.cpp @@ -986,7 +986,7 @@ void DivelogsDeWebServices::buttonClicked(QAbstractButton *button) break; } /* parse file and import dives */ - parse_file(QFile::encodeName(zipFile.fileName())); + parse_file(QFile::encodeName(zipFile.fileName()), &dive_table); process_dives(true, false); MainWindow::instance()->refreshDisplay(); diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.cpp b/desktop-widgets/tab-widgets/TabDiveInformation.cpp index 09f180cb1..a4f8f455f 100644 --- a/desktop-widgets/tab-widgets/TabDiveInformation.cpp +++ b/desktop-widgets/tab-widgets/TabDiveInformation.cpp @@ -62,7 +62,7 @@ void TabDiveInformation::updateData() gaslist.append(separator); volumes.append(separator); SACs.append(separator); separator = "\n"; - gaslist.append(gasname(&displayed_dive.cylinder[i].gasmix)); + gaslist.append(gasname(displayed_dive.cylinder[i].gasmix)); if (!gases[i].mliter) continue; volumes.append(get_volume_string(gases[i], true)); diff --git a/desktop-widgets/updatemanager.cpp b/desktop-widgets/updatemanager.cpp index ccf70a67c..ee209474c 100644 --- a/desktop-widgets/updatemanager.cpp +++ b/desktop-widgets/updatemanager.cpp @@ -8,23 +8,21 @@ #include "core/version.h" #include "desktop-widgets/mainwindow.h" #include "core/cloudstorage.h" -#include "core/subsurface-qt/SettingsObjectWrapper.h" +#include "core/settings/qPrefUpdateManager.h" UpdateManager::UpdateManager(QObject *parent) : QObject(parent), isAutomaticCheck(false) { - auto update_settings = qPrefUpdateManager::instance(); - - if (update_settings->dont_check_for_updates()) + if (qPrefUpdateManager::dont_check_for_updates()) return; - if (update_settings->last_version_used() == subsurface_git_version() && - update_settings->next_check() > QDate::currentDate()) + if (qPrefUpdateManager::last_version_used() == subsurface_git_version() && + qPrefUpdateManager::next_check() > QDate::currentDate()) return; - update_settings->set_last_version_used(subsurface_git_version()); - update_settings->set_next_check(QDate::currentDate().addDays(14)); + qPrefUpdateManager::set_last_version_used(subsurface_git_version()); + qPrefUpdateManager::set_next_check(QDate::currentDate().addDays(14)); checkForUpdates(true); } diff --git a/desktop-widgets/usersurvey.cpp b/desktop-widgets/usersurvey.cpp index 326a51f9e..fdf3e7f95 100644 --- a/desktop-widgets/usersurvey.cpp +++ b/desktop-widgets/usersurvey.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include <QShortcut> #include <QMessageBox> -#include <QSettings> #include "desktop-widgets/usersurvey.h" #include "ui_usersurvey.h" @@ -11,6 +10,7 @@ #include "core/qthelper.h" #include "core/subsurfacesysinfo.h" +#include "core/settings/qPrefDisplay.h" UserSurvey::UserSurvey(QWidget *parent) : QDialog(parent), ui(new Ui::UserSurvey) @@ -88,9 +88,7 @@ void UserSurvey::on_buttonBox_rejected() // nothing to do here, we'll just ask again the next time they start break; case QDialog::Rejected: - QSettings s; - s.beginGroup("UserSurvey"); - s.setValue("SurveyDone", "declined"); + qPrefDisplay::set_UserSurvey("declined"); break; } hide(); @@ -116,9 +114,7 @@ void UserSurvey::requestReceived() if (responseBody == "OK") { msgText = tr("Survey successfully submitted."); - QSettings s; - s.beginGroup("UserSurvey"); - s.setValue("SurveyDone", "submitted"); + qPrefDisplay::set_UserSurvey("submitted"); } else { msgText = tr("There was an error while trying to check for updates.<br/><br/>%1").arg(responseBody); msgbox.setIcon(QMessageBox::Warning); |