summaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
authorGravatar jan Iversen <jani@apache.org>2018-08-15 11:50:53 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-08-15 16:11:39 -0700
commit6aee600aa7022dd8f0453c658c967d5268c611b3 (patch)
tree6c3547dc39c59d4cd79eb72adb45bc3e3760a58f /desktop-widgets
parent3b84dbe554a76e2f024b7254c079c761429223ac (diff)
downloadsubsurface-6aee600aa7022dd8f0453c658c967d5268c611b3.tar.gz
desktop-widgets/preferences: reemove SettingsObjectWrapper
remove use of SettingsObjectWrapper:: remove include of SettingsObjectWrapper.h use qPrefFoo:: for setters and getters replace prefs.foo with qPrefXYZ::foo() where feasible (this expands to the same code, but gives us more control over the variable). Signed-off-by: Jan Iversen <jani@apache.org>
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/preferences/preferences_defaults.cpp52
-rw-r--r--desktop-widgets/preferences/preferences_georeference.cpp9
-rw-r--r--desktop-widgets/preferences/preferences_graph.cpp47
-rw-r--r--desktop-widgets/preferences/preferences_language.cpp20
-rw-r--r--desktop-widgets/preferences/preferences_network.cpp1
-rw-r--r--desktop-widgets/preferences/preferences_units.cpp23
6 files changed, 71 insertions, 81 deletions
diff --git a/desktop-widgets/preferences/preferences_defaults.cpp b/desktop-widgets/preferences/preferences_defaults.cpp
index 748817e02..cf7b03c9e 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(qPrefAnimations::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,17 +85,17 @@ 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()
@@ -115,11 +114,8 @@ void PreferencesDefaults::syncSettings()
general->set_extract_video_thumbnails_position(ui->videoThumbnailPosition->value());
general->set_ffmpeg_executable(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());
+ qPrefDisplay::set_divelist_font(ui->font->currentFont().toString());
+ qPrefDisplay::set_font_size(ui->fontsize->value());
+ qPrefDisplay::set_display_invalid_dives(ui->displayinvalid->isChecked());
+ qPrefAnimations::set_animation_speed(ui->velocitySlider->value());
}
diff --git a/desktop-widgets/preferences/preferences_georeference.cpp b/desktop-widgets/preferences/preferences_georeference.cpp
index 08764434a..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 = qPrefGeocoding::instance();
- geocoding->set_first_taxonomy_category((taxonomy_category) ui->first_item->currentIndex());
- geocoding->set_second_taxonomy_category((taxonomy_category) ui->second_item->currentIndex());
- geocoding->set_third_taxonomy_category((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 cbb2b2c39..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 = qPrefGeneral::instance();
- general->set_defaultsetpoint(lrint(ui->defaultSetpoint->value() * 1000.0));
- general->set_o2consumption(lrint(ui->psro2rate->value() *1000.0));
- general->set_pscr_ratio(lrint(1000.0 / ui->pscrfactor->value()));
- general->set_auto_recalculate_thumbnails(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 = qPrefPartialPressureGas::instance();
- pp_gas->set_phe_threshold(ui->pheThreshold->value());
- pp_gas->set_po2_threshold_max(ui->po2ThresholdMax->value());
- pp_gas->set_po2_threshold_min(ui->po2ThresholdMin->value());
- pp_gas->set_pn2_threshold(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 2bcd3422d..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 = qPrefLanguage::instance();
- lang->set_language(currentText);
- lang->set_lang_locale(currentLocale);
- lang->set_use_system_language(ui->languageSystemDefault->isChecked());
- lang->set_time_format_override(!ui->timeFormatSystemDefault->isChecked());
- lang->set_date_format_override(!ui->dateFormatSystemDefault->isChecked());
- lang->set_time_format(ui->timeFormatEntry->currentText());
- lang->set_date_format(ui->dateFormatEntry->currentText());
- lang->set_date_format_short(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());
}