summaryrefslogtreecommitdiffstats
path: root/core/subsurface-qt
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@gmail.com>2016-08-26 16:52:51 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-08-27 11:40:45 -0700
commit9b2404fcb4b360a12a8f997a4b9111e5f44bf444 (patch)
tree3c8cb2f24394c3dca2a3a563682466a9b3612c7e /core/subsurface-qt
parent8f178301d8b93f50c38cd00b7cc47a259e1fed43 (diff)
downloadsubsurface-9b2404fcb4b360a12a8f997a4b9111e5f44bf444.tar.gz
Settings update: Move loadPreferences out of qt-helper.cpp
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/subsurface-qt')
-rw-r--r--core/subsurface-qt/SettingsObjectWrapper.cpp163
1 files changed, 162 insertions, 1 deletions
diff --git a/core/subsurface-qt/SettingsObjectWrapper.cpp b/core/subsurface-qt/SettingsObjectWrapper.cpp
index 6145e277a..09246b508 100644
--- a/core/subsurface-qt/SettingsObjectWrapper.cpp
+++ b/core/subsurface-qt/SettingsObjectWrapper.cpp
@@ -3,8 +3,10 @@
#include <QApplication>
#include <QFont>
#include <QDate>
+#include <QNetworkProxy>
-#include "../dive.h" // TODO: remove copy_string from dive.h
+#include "core/dive.h" // TODO: remove copy_string from dive.h
+#include "core/helpers.h"
DiveComputerSettings::DiveComputerSettings(QObject *parent):
QObject(parent), group(QStringLiteral("DiveComputer"))
@@ -1746,6 +1748,165 @@ QObject(parent),
void SettingsObjectWrapper::load()
{
QSettings s;
+ QVariant v;
+
+ uiLanguage(NULL);
+ s.beginGroup("Units");
+ if (s.value("unit_system").toString() == "metric") {
+ prefs.unit_system = METRIC;
+ prefs.units = SI_units;
+ } else if (s.value("unit_system").toString() == "imperial") {
+ prefs.unit_system = IMPERIAL;
+ prefs.units = IMPERIAL_units;
+ } else {
+ prefs.unit_system = PERSONALIZE;
+ GET_UNIT("length", length, units::FEET, units::METERS);
+ GET_UNIT("pressure", pressure, units::PSI, units::BAR);
+ GET_UNIT("volume", volume, units::CUFT, units::LITER);
+ GET_UNIT("temperature", temperature, units::FAHRENHEIT, units::CELSIUS);
+ GET_UNIT("weight", weight, units::LBS, units::KG);
+ }
+ GET_UNIT("vertical_speed_time", vertical_speed_time, units::MINUTES, units::SECONDS);
+ GET_BOOL("coordinates", coordinates_traditional);
+ s.endGroup();
+ s.beginGroup("TecDetails");
+ GET_BOOL("po2graph", pp_graphs.po2);
+ GET_BOOL("pn2graph", pp_graphs.pn2);
+ GET_BOOL("phegraph", pp_graphs.phe);
+ GET_DOUBLE("po2threshold", pp_graphs.po2_threshold);
+ GET_DOUBLE("pn2threshold", pp_graphs.pn2_threshold);
+ GET_DOUBLE("phethreshold", pp_graphs.phe_threshold);
+ GET_BOOL("mod", mod);
+ GET_DOUBLE("modpO2", modpO2);
+ GET_BOOL("ead", ead);
+ GET_BOOL("redceiling", redceiling);
+ GET_BOOL("dcceiling", dcceiling);
+ GET_BOOL("calcceiling", calcceiling);
+ GET_BOOL("calcceiling3m", calcceiling3m);
+ GET_BOOL("calcndltts", calcndltts);
+ GET_BOOL("calcalltissues", calcalltissues);
+ GET_BOOL("hrgraph", hrgraph);
+ GET_BOOL("tankbar", tankbar);
+ GET_BOOL("RulerBar", rulergraph);
+ GET_BOOL("percentagegraph", percentagegraph);
+ GET_INT("gflow", gflow);
+ GET_INT("gfhigh", gfhigh);
+ GET_BOOL("gf_low_at_maxdepth", gf_low_at_maxdepth);
+ GET_BOOL("show_ccr_setpoint",show_ccr_setpoint);
+ GET_BOOL("show_ccr_sensors",show_ccr_sensors);
+ GET_BOOL("zoomed_plot", zoomed_plot);
+ set_gf(prefs.gflow, prefs.gfhigh, prefs.gf_low_at_maxdepth);
+ GET_BOOL("show_sac", show_sac);
+ GET_BOOL("display_unused_tanks", display_unused_tanks);
+ GET_BOOL("show_average_depth", show_average_depth);
+ s.endGroup();
+
+ s.beginGroup("GeneralSettings");
+ GET_TXT("default_filename", default_filename);
+ GET_INT("default_file_behavior", default_file_behavior);
+ if (prefs.default_file_behavior == UNDEFINED_DEFAULT_FILE) {
+ // undefined, so check if there's a filename set and
+ // use that, otherwise go with no default file
+ if (QString(prefs.default_filename).isEmpty())
+ prefs.default_file_behavior = NO_DEFAULT_FILE;
+ else
+ prefs.default_file_behavior = LOCAL_DEFAULT_FILE;
+ }
+ GET_TXT("default_cylinder", default_cylinder);
+ GET_BOOL("use_default_file", use_default_file);
+ GET_INT("defaultsetpoint", defaultsetpoint);
+ GET_INT("o2consumption", o2consumption);
+ GET_INT("pscr_ratio", pscr_ratio);
+ s.endGroup();
+
+ s.beginGroup("Display");
+ // get the font from the settings or our defaults
+ // respect the system default font size if none is explicitly set
+ QFont defaultFont = s.value("divelist_font", prefs.divelist_font).value<QFont>();
+ if (IS_FP_SAME(system_divelist_default_font_size, -1.0)) {
+ prefs.font_size = qApp->font().pointSizeF();
+ system_divelist_default_font_size = prefs.font_size; // this way we don't save it on exit
+ }
+ prefs.font_size = s.value("font_size", prefs.font_size).toFloat();
+ // painful effort to ignore previous default fonts on Windows - ridiculous
+ QString fontName = defaultFont.toString();
+ if (fontName.contains(","))
+ fontName = fontName.left(fontName.indexOf(","));
+ if (subsurface_ignore_font(fontName.toUtf8().constData())) {
+ defaultFont = QFont(prefs.divelist_font);
+ } else {
+ free((void *)prefs.divelist_font);
+ prefs.divelist_font = strdup(fontName.toUtf8().constData());
+ }
+ defaultFont.setPointSizeF(prefs.font_size);
+ qApp->setFont(defaultFont);
+ GET_INT("displayinvalid", display_invalid_dives);
+ s.endGroup();
+
+ s.beginGroup("Animations");
+ GET_INT("animation_speed", animation_speed);
+ s.endGroup();
+
+ s.beginGroup("Network");
+ GET_INT_DEF("proxy_type", proxy_type, QNetworkProxy::DefaultProxy);
+ GET_TXT("proxy_host", proxy_host);
+ GET_INT("proxy_port", proxy_port);
+ GET_BOOL("proxy_auth", proxy_auth);
+ GET_TXT("proxy_user", proxy_user);
+ GET_TXT("proxy_pass", proxy_pass);
+ s.endGroup();
+
+ s.beginGroup("CloudStorage");
+ GET_TXT("email", cloud_storage_email);
+#ifndef SUBSURFACE_MOBILE
+ GET_BOOL("save_password_local", save_password_local);
+#else
+ // always save the password in Subsurface-mobile
+ prefs.save_password_local = true;
+#endif
+ if (prefs.save_password_local) { // GET_TEXT macro is not a single statement
+ GET_TXT("password", cloud_storage_password);
+ }
+ GET_INT("cloud_verification_status", cloud_verification_status);
+ GET_BOOL("cloud_background_sync", cloud_background_sync);
+ GET_BOOL("git_local_only", git_local_only);
+
+ // creating the git url here is simply a convenience when C code wants
+ // to compare against that git URL - it's always derived from the base URL
+ GET_TXT("cloud_base_url", cloud_base_url);
+ prefs.cloud_git_url = strdup(qPrintable(QString(prefs.cloud_base_url) + "/git"));
+ s.endGroup();
+
+ // Subsurface webservice id is stored outside of the groups
+ GET_TXT("subsurface_webservice_uid", userid);
+
+ // but the related time / distance threshold (only used in the mobile app)
+ // are in their own group
+ s.beginGroup("locationService");
+ GET_INT("distance_threshold", distance_threshold);
+ GET_INT("time_threshold", time_threshold);
+ s.endGroup();
+
+ // GeoManagement
+ s.beginGroup("geocoding");
+#ifdef DISABLED
+ GET_BOOL("enable_geocoding", geocoding.enable_geocoding);
+ GET_BOOL("parse_dive_without_gps", geocoding.parse_dive_without_gps);
+ GET_BOOL("tag_existing_dives", geocoding.tag_existing_dives);
+#else
+ prefs.geocoding.enable_geocoding = true;
+#endif
+ GET_ENUM("cat0", taxonomy_category, geocoding.category[0]);
+ GET_ENUM("cat1", taxonomy_category, geocoding.category[1]);
+ GET_ENUM("cat2", taxonomy_category, geocoding.category[2]);
+ s.endGroup();
+
+ // GPS service time and distance thresholds
+ s.beginGroup("LocationService");
+ GET_INT("time_threshold", time_threshold);
+ GET_INT("distance_threshold", distance_threshold);
+ s.endGroup();
+
s.beginGroup("Planner");
prefs.last_stop = s.value("last_stop", prefs.last_stop).toBool();
prefs.verbatim_plan = s.value("verbatim_plan", prefs.verbatim_plan).toBool();