aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pref.h29
-rw-r--r--profile.c12
-rw-r--r--qt-ui/mainwindow.cpp24
-rw-r--r--qt-ui/preferences.cpp26
-rw-r--r--qt-ui/profile/divecartesianaxis.cpp13
-rw-r--r--qt-ui/profile/diveprofileitem.cpp28
-rw-r--r--qt-ui/profile/profilewidget2.cpp31
-rw-r--r--subsurfacestartup.c14
8 files changed, 80 insertions, 97 deletions
diff --git a/pref.h b/pref.h
index 712a2d153..fd7aa82a7 100644
--- a/pref.h
+++ b/pref.h
@@ -23,14 +23,14 @@ struct preferences {
double font_size;
partial_pressure_graphs_t pp_graphs;
short mod;
- double mod_ppO2;
+ double modppO2;
short ead;
- short profile_dc_ceiling;
- short profile_red_ceiling;
- short profile_calc_ceiling;
- short calc_ceiling_3m_incr;
- short calc_all_tissues;
- short calc_ndl_tts;
+ short dcceiling;
+ short redceiling;
+ short calcceiling;
+ short calcceiling3m;
+ short calcalltissues;
+ short calcndltts;
short gflow;
short gfhigh;
short animation;
@@ -39,10 +39,10 @@ struct preferences {
short unit_system;
struct units units;
short show_sac;
- bool display_unused_tanks;
- bool show_average_depth;
- bool zoomed_plot;
- short heart_rate;
+ short display_unused_tanks;
+ short show_average_depth;
+ short zoomed_plot;
+ short hrgraph;
};
enum unit_system_values {
METRIC,
@@ -54,16 +54,9 @@ extern struct preferences prefs, default_prefs;
#define PP_GRAPHS_ENABLED (prefs.pp_graphs.po2 || prefs.pp_graphs.pn2 || prefs.pp_graphs.phe)
-extern void subsurface_open_conf(void);
extern void subsurface_set_conf(const char *name, const char *value);
extern void subsurface_set_conf_bool(const char *name, bool value);
extern void subsurface_set_conf_int(const char *name, int value);
-extern void subsurface_unset_conf(const char *name);
-extern const char *subsurface_get_conf(const char *name);
-extern int subsurface_get_conf_bool(const char *name);
-extern int subsurface_get_conf_int(const char *name);
-extern void subsurface_flush_conf(void);
-extern void subsurface_close_conf(void);
extern const char system_divelist_default_font[];
extern const int system_divelist_default_font_size;
diff --git a/profile.c b/profile.c
index 0d3f0ab7e..4d5e05aa4 100644
--- a/profile.c
+++ b/profile.c
@@ -1096,13 +1096,13 @@ void calculate_deco_information(struct dive *dive, struct divecomputer *dc, stru
if (t0 == t1)
entry->ceiling = (entry - 1)->ceiling;
else
- entry->ceiling = deco_allowed_depth(tissue_tolerance, surface_pressure, dive, !prefs.calc_ceiling_3m_incr);
+ entry->ceiling = deco_allowed_depth(tissue_tolerance, surface_pressure, dive, !prefs.calcceiling3m);
for (j = 0; j < 16; j++)
entry->ceilings[j] = deco_allowed_depth(tolerated_by_tissue[j], surface_pressure, dive, 1);
/* should we do more calculations?
* We don't for print-mode because this info doesn't show up there */
- if (prefs.calc_ndl_tts && !print_mode) {
+ if (prefs.calcndltts && !print_mode) {
/* We are going to mess up deco state, so store it for later restore */
char *cache_data = NULL;
cache_deco_state(tissue_tolerance, &cache_data);
@@ -1153,7 +1153,7 @@ static void calculate_gas_information_new(struct dive *dive, struct plot_info *p
* so there is no difference in calculating between OC and CC
* END takes O2 + N2 (air) into account ("Narcotic" for trimix dives)
* EAD just uses N2 ("Air" for nitrox dives) */
- entry->mod = (prefs.mod_ppO2 / fo2 * 1000 - 1) * 10000;
+ entry->mod = (prefs.modppO2 / fo2 * 1000 - 1) * 10000;
entry->end = (entry->depth + 10000) * (1000 - fhe) / 1000.0 - 10000;
entry->ead = (entry->depth + 10000) * (1000 - fo2 - fhe) / (double)N2_IN_AIR - 10000;
entry->eadd = (entry->depth + 10000) *
@@ -1303,7 +1303,7 @@ static void plot_string(struct plot_info *pi, struct plot_data *entry, struct me
* (ascent_mm_per_step / ascent_s_per_step)
* everything will be ok. */
put_string(b, translate("gettextFromC", "In deco (calc)\n"));
- } else if (prefs.calc_ndl_tts && entry->ndl_calc != 0) {
+ } else if (prefs.calcndltts && entry->ndl_calc != 0) {
put_format(b, translate("gettextFromC", "NDL: %umin (calc)\n"), DIV_UP(entry->ndl_calc, 60));
}
if (entry->tts_calc)
@@ -1311,7 +1311,7 @@ static void plot_string(struct plot_info *pi, struct plot_data *entry, struct me
if (entry->ceiling) {
depthvalue = get_depth_units(entry->ceiling, NULL, &depth_unit);
put_format(b, translate("gettextFromC", "Calculated ceiling %.0f%s\n"), depthvalue, depth_unit);
- if (prefs.calc_all_tissues) {
+ if (prefs.calcalltissues) {
int k;
for (k = 0; k < 16; k++) {
if (entry->ceilings[k]) {
@@ -1321,7 +1321,7 @@ static void plot_string(struct plot_info *pi, struct plot_data *entry, struct me
}
}
}
- if (entry->heartbeat && prefs.heart_rate)
+ if (entry->heartbeat && prefs.hrgraph)
put_format(b, translate("gettextFromC", "heartbeat: %d\n"), entry->heartbeat);
if (entry->bearing)
put_format(b, translate("gettextFromC", "bearing: %d\n"), entry->bearing);
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 313a508ab..0b00d4fd1 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -693,17 +693,17 @@ void MainWindow::readSettings()
s.endGroup();
s.beginGroup("TecDetails");
- TOOLBOX_PREF_BUTTON(calc_all_tissues, calcalltissues, profCalcAllTissues);
- TOOLBOX_PREF_BUTTON(profile_calc_ceiling, calcceiling, profCalcCeiling);
- TOOLBOX_PREF_BUTTON(profile_dc_ceiling, dcceiling, profDcCeiling);
+ TOOLBOX_PREF_BUTTON(calcalltissues, calcalltissues, profCalcAllTissues);
+ TOOLBOX_PREF_BUTTON(calcceiling, calcceiling, profCalcCeiling);
+ TOOLBOX_PREF_BUTTON(dcceiling, dcceiling, profDcCeiling);
TOOLBOX_PREF_BUTTON(ead, ead, profEad);
- TOOLBOX_PREF_BUTTON(calc_ceiling_3m_incr, calcceiling3m, profIncrement3m);
+ TOOLBOX_PREF_BUTTON(calcceiling3m, calcceiling3m, profIncrement3m);
TOOLBOX_PREF_BUTTON(mod, mod, profMod);
- TOOLBOX_PREF_BUTTON(calc_ndl_tts, calcndltts, profNdl_tts);
+ TOOLBOX_PREF_BUTTON(calcndltts, calcndltts, profNdl_tts);
TOOLBOX_PREF_BUTTON(pp_graphs.phe, phegraph, profPhe);
TOOLBOX_PREF_BUTTON(pp_graphs.pn2, pn2graph, profPn2);
TOOLBOX_PREF_BUTTON(pp_graphs.po2, po2graph, profPO2);
- TOOLBOX_PREF_BUTTON(heart_rate, hrgraph, profHR);
+ TOOLBOX_PREF_BUTTON(hrgraph, hrgraph, profHR);
ui.profRuler->setChecked(s.value("rulergraph").toBool());
TOOLBOX_PREF_BUTTON(show_sac, show_sac, profSAC);
}
@@ -1118,17 +1118,17 @@ void MainWindow::editCurrentDive()
void MainWindow::on_profCalcAllTissues_clicked(bool triggered)
{
- prefs.calc_all_tissues = triggered;
+ prefs.calcalltissues = triggered;
TOOLBOX_PREF_PROFILE(calcalltissues);
}
void MainWindow::on_profCalcCeiling_clicked(bool triggered)
{
- prefs.profile_calc_ceiling = triggered;
+ prefs.calcceiling = triggered;
TOOLBOX_PREF_PROFILE(calcceiling);
}
void MainWindow::on_profDcCeiling_clicked(bool triggered)
{
- prefs.profile_dc_ceiling = triggered;
+ prefs.dcceiling = triggered;
TOOLBOX_PREF_PROFILE(dcceiling);
}
void MainWindow::on_profEad_clicked(bool triggered)
@@ -1138,7 +1138,7 @@ void MainWindow::on_profEad_clicked(bool triggered)
}
void MainWindow::on_profIncrement3m_clicked(bool triggered)
{
- prefs.calc_ceiling_3m_incr = triggered;
+ prefs.calcceiling3m = triggered;
TOOLBOX_PREF_PROFILE(calcceiling3m);
}
void MainWindow::on_profMod_clicked(bool triggered)
@@ -1148,7 +1148,7 @@ void MainWindow::on_profMod_clicked(bool triggered)
}
void MainWindow::on_profNdl_tts_clicked(bool triggered)
{
- prefs.calc_ndl_tts = triggered;
+ prefs.calcndltts = triggered;
TOOLBOX_PREF_PROFILE(calcndltts);
}
void MainWindow::on_profPhe_clicked(bool triggered)
@@ -1168,7 +1168,7 @@ void MainWindow::on_profPO2_clicked(bool triggered)
}
void MainWindow::on_profHR_clicked(bool triggered)
{
- prefs.heart_rate = triggered;
+ prefs.hrgraph = triggered;
TOOLBOX_PREF_PROFILE(hrgraph);
}
void MainWindow::on_profRuler_clicked(bool triggered)
diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp
index b22991c5b..c93dd3628 100644
--- a/qt-ui/preferences.cpp
+++ b/qt-ui/preferences.cpp
@@ -49,8 +49,8 @@ void PreferencesDialog::setUiFromPrefs()
ui.pheThreshold->setValue(prefs.pp_graphs.phe_threshold);
ui.po2Threshold->setValue(prefs.pp_graphs.po2_threshold);
ui.pn2Threshold->setValue(prefs.pp_graphs.pn2_threshold);
- ui.maxppo2->setValue(prefs.mod_ppO2);
- ui.red_ceiling->setChecked(prefs.profile_red_ceiling);
+ ui.maxppo2->setValue(prefs.modppO2);
+ ui.red_ceiling->setChecked(prefs.redceiling);
ui.units_group->setEnabled(ui.personalize->isChecked());
ui.gflow->setValue(prefs.gflow);
@@ -179,7 +179,6 @@ void PreferencesDialog::syncSettings()
// Graph
s.beginGroup("TecDetails");
-
s.setValue("phethreshold", ui.pheThreshold->value());
s.setValue("po2threshold", ui.po2Threshold->value());
s.setValue("pn2threshold", ui.pn2Threshold->value());
@@ -203,6 +202,7 @@ void PreferencesDialog::syncSettings()
s.setValue("weight", ui.lbs->isChecked() ? units::LBS : units::KG);
s.setValue("vertical_speed_time", ui.vertical_speed_minutes->isChecked() ? units::MINUTES : units::SECONDS);
s.endGroup();
+
// Defaults
s.beginGroup("GeneralSettings");
s.setValue("default_filename", ui.defaultfilename->text());
@@ -216,6 +216,7 @@ void PreferencesDialog::syncSettings()
s.endGroup();
s.sync();
+ // Locale
QLocale loc;
s.beginGroup("Language");
bool useSystemLang = s.value("UseSystemLanguage", true).toBool();
@@ -228,8 +229,11 @@ void PreferencesDialog::syncSettings()
s.setValue("UiLanguage", ui.languageView->currentIndex().data(Qt::UserRole));
s.endGroup();
+ // Animation
s.beginGroup("Animations");
s.setValue("animation_speed",ui.velocitySlider->value());
+ s.endGroup();
+
loadSettings();
emit settingsChanged();
}
@@ -271,15 +275,15 @@ void PreferencesDialog::loadSettings()
GET_DOUBLE("pn2threshold", pp_graphs.pn2_threshold);
GET_DOUBLE("phethreshold", pp_graphs.phe_threshold);
GET_BOOL("mod", mod);
- GET_DOUBLE("modppO2", mod_ppO2);
+ GET_DOUBLE("modppO2", modppO2);
GET_BOOL("ead", ead);
- GET_BOOL("redceiling", profile_red_ceiling);
- GET_BOOL("dcceiling", profile_dc_ceiling);
- GET_BOOL("calcceiling", profile_calc_ceiling);
- GET_BOOL("calcceiling3m", calc_ceiling_3m_incr);
- GET_BOOL("calcndltts", calc_ndl_tts);
- GET_BOOL("calcalltissues", calc_all_tissues);
- GET_BOOL("hrgraph", heart_rate);
+ 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_INT("gflow", gflow);
GET_INT("gfhigh", gfhigh);
GET_BOOL("gf_low_at_maxdepth", gf_low_at_maxdepth);
diff --git a/qt-ui/profile/divecartesianaxis.cpp b/qt-ui/profile/divecartesianaxis.cpp
index f5ba988e8..2729647f3 100644
--- a/qt-ui/profile/divecartesianaxis.cpp
+++ b/qt-ui/profile/divecartesianaxis.cpp
@@ -353,10 +353,7 @@ QColor DepthAxis::colorForValue(double value)
static bool isPPGraphEnabled()
{
- QSettings s;
-
- s.beginGroup("TecDetails");
- return s.value("phegraph").toBool() || s.value("po2graph").toBool() || s.value("pn2graph").toBool();
+ return prefs.pp_graphs.po2 || prefs.pp_graphs.pn2 || prefs.pp_graphs.phe;
}
DepthAxis::DepthAxis() : showWithPPGraph(false)
@@ -426,11 +423,9 @@ void PartialGasPressureAxis::setModel(DivePlotDataModel *m)
void PartialGasPressureAxis::preferencesChanged()
{
- QSettings s;
- s.beginGroup("TecDetails");
- bool showPhe = s.value("phegraph").toBool();
- bool showPn2 = s.value("pn2graph").toBool();
- bool showPo2 = s.value("po2graph").toBool();
+ bool showPhe = prefs.pp_graphs.phe;
+ bool showPn2 = prefs.pp_graphs.pn2;
+ bool showPo2 = prefs.pp_graphs.po2;
setVisible(showPhe || showPn2 || showPo2);
if (!model->rowCount())
return;
diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp
index 6490c9b7a..c239d39a9 100644
--- a/qt-ui/profile/diveprofileitem.cpp
+++ b/qt-ui/profile/diveprofileitem.cpp
@@ -145,11 +145,11 @@ void DiveProfileItem::modelDataChanged(const QModelIndex &topLeft, const QModelI
if (polygon().isEmpty())
return;
- show_reported_ceiling = prefs.profile_dc_ceiling;
- reported_ceiling_in_red = prefs.profile_red_ceiling;
+ show_reported_ceiling = prefs.dcceiling;
+ reported_ceiling_in_red = prefs.redceiling;
/* Show any ceiling we may have encountered */
- if (prefs.profile_dc_ceiling && !prefs.profile_red_ceiling) {
+ if (prefs.dcceiling && !prefs.redceiling) {
QPolygonF p = polygon();
plot_data *entry = dataModel->data().entry + dataModel->rowCount() - 1;
for (int i = dataModel->rowCount() - 1; i >= 0; i--, entry--) {
@@ -197,7 +197,7 @@ void DiveProfileItem::modelDataChanged(const QModelIndex &topLeft, const QModelI
void DiveProfileItem::preferencesChanged()
{
//TODO: Only modelDataChanged() here if we need to rebuild the graph ( for instance,
- // if the prefs.profile_dc_ceiling are enabled, but prefs.profile_red_ceiling is disabled
+ // if the prefs.dcceiling are enabled, but prefs.redceiling is disabled
// and only if it changed something. let's not waste cpu cycles repoloting something we don't need to.
modelDataChanged();
}
@@ -552,9 +552,7 @@ DiveCalculatedTissue::DiveCalculatedTissue()
void DiveCalculatedTissue::preferencesChanged()
{
- QSettings s;
- s.beginGroup("TecDetails");
- setVisible(s.value("calcalltissues").toBool() && s.value("calcceiling").toBool());
+ setVisible(prefs.calcalltissues && prefs.calcceiling);
}
void DiveReportedCeiling::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
@@ -579,7 +577,7 @@ void DiveReportedCeiling::modelDataChanged(const QModelIndex &topLeft, const QMo
setPolygon(p);
QLinearGradient pat(0, p.boundingRect().top(), 0, p.boundingRect().bottom());
// does the user want the ceiling in "surface color" or in red?
- if (prefs.profile_red_ceiling) {
+ if (prefs.redceiling) {
pat.setColorAt(0, getColor(CEILING_SHALLOW));
pat.setColorAt(1, getColor(CEILING_DEEP));
} else {
@@ -592,23 +590,17 @@ void DiveReportedCeiling::modelDataChanged(const QModelIndex &topLeft, const QMo
void DiveCalculatedCeiling::preferencesChanged()
{
- QSettings s;
- s.beginGroup("TecDetails");
-
- bool shouldShow3mIncrement = s.value("calcceiling3m").toBool();
- if (dataModel && is3mIncrement != shouldShow3mIncrement) {
+ if (dataModel && is3mIncrement != prefs.calcceiling3m) {
// recalculate that part.
dataModel->calculateDecompression();
}
- is3mIncrement = shouldShow3mIncrement;
- setVisible(s.value("calcceiling").toBool());
+ is3mIncrement = prefs.calcceiling3m;
+ setVisible(prefs.calcceiling);
}
void DiveReportedCeiling::preferencesChanged()
{
- QSettings s;
- s.beginGroup("TecDetails");
- setVisible(s.value("dcceiling").toBool());
+ setVisible(prefs.dcceiling);
}
void DiveReportedCeiling::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 97511c785..17af08bd4 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -13,8 +13,8 @@
#include "planner.h"
#include "device.h"
#include "ruleritem.h"
-#include "../../dive.h"
-#include "../../pref.h"
+#include "dive.h"
+#include "pref.h"
#include <libdivecomputer/parser.h>
#include <QSignalTransition>
#include <QPropertyAnimation>
@@ -477,7 +477,7 @@ void ProfileWidget2::settingsChanged()
{
QSettings s;
s.beginGroup("TecDetails");
- if (s.value("phegraph").toBool() || s.value("po2graph").toBool() || s.value("pn2graph").toBool()) {
+ if (prefs.pp_graphs.phe || prefs.pp_graphs.po2 || prefs.pp_graphs.pn2) {
profileYAxis->animateChangeLine(itemPos.depth.shrinked);
temperatureAxis->animateChangeLine(itemPos.temperature.shrinked);
cylinderPressureAxis->animateChangeLine(itemPos.cylinder.shrinked);
@@ -486,8 +486,8 @@ void ProfileWidget2::settingsChanged()
temperatureAxis->animateChangeLine(itemPos.temperature.expanded);
cylinderPressureAxis->animateChangeLine(itemPos.cylinder.expanded);
}
- if (s.value("zoomed_plot").toBool() != isPlotZoomed) {
- isPlotZoomed = s.value("zoomed_plot").toBool();
+ if (prefs.zoomed_plot != isPlotZoomed) {
+ isPlotZoomed = prefs.zoomed_plot;
replot();
}
@@ -635,9 +635,7 @@ void ProfileWidget2::setProfileState()
cylinderPressureAxis->setVisible(true);
profileYAxis->setPos(itemPos.depth.pos.on);
- QSettings s;
- s.beginGroup("TecDetails");
- if (s.value("phegraph").toBool() || s.value("po2graph").toBool() || s.value("pn2graph").toBool()) {
+ if (prefs.pp_graphs.phe || prefs.pp_graphs.po2 || prefs.pp_graphs.pn2) {
profileYAxis->setLine(itemPos.depth.shrinked);
temperatureAxis->setLine(itemPos.temperature.shrinked);
cylinderPressureAxis->setLine(itemPos.cylinder.shrinked);
@@ -646,9 +644,9 @@ void ProfileWidget2::setProfileState()
temperatureAxis->setLine(itemPos.temperature.expanded);
cylinderPressureAxis->setLine(itemPos.cylinder.expanded);
}
- pn2GasItem->setVisible(s.value("pn2graph").toBool());
- po2GasItem->setVisible(s.value("po2graph").toBool());
- pheGasItem->setVisible(s.value("phegraph").toBool());
+ pn2GasItem->setVisible(prefs.pp_graphs.pn2);
+ po2GasItem->setVisible(prefs.pp_graphs.po2);
+ pheGasItem->setVisible(prefs.pp_graphs.phe);
gasYAxis->setPos(itemPos.partialPressure.pos.on);
gasYAxis->setLine(itemPos.partialPressure.expanded);
@@ -660,21 +658,22 @@ void ProfileWidget2::setProfileState()
temperatureAxis->setPos(itemPos.temperature.pos.on);
heartBeatAxis->setPos(itemPos.heartBeat.pos.on);
heartBeatAxis->setLine(itemPos.heartBeat.expanded);
- heartBeatItem->setVisible(s.value("hrgraph").toBool());
+ heartBeatItem->setVisible(prefs.hrgraph);
meanDepth->setVisible(true);
diveComputerText->setVisible(true);
diveComputerText->setPos(itemPos.dcLabel.on);
- diveCeiling->setVisible(s.value("calcceiling").toBool());
- reportedCeiling->setVisible(s.value("dcceiling").toBool());
+ diveCeiling->setVisible(prefs.calcceiling);
+ reportedCeiling->setVisible(prefs.dcceiling);
- if (s.value("calcalltissues").toBool()) {
+ if (prefs.calcalltissues) {
Q_FOREACH(DiveCalculatedTissue * tissue, allTissues) {
tissue->setVisible(true);
}
}
-
+ QSettings s;
+ s.beginGroup("TecDetails");
bool rulerVisible = s.value("rulergraph", false).toBool();
rulerItem->setVisible(rulerVisible);
rulerItem->destNode()->setVisible(rulerVisible);
diff --git a/subsurfacestartup.c b/subsurfacestartup.c
index 4e7550ce3..471fea64e 100644
--- a/subsurfacestartup.c
+++ b/subsurfacestartup.c
@@ -16,14 +16,14 @@ struct preferences default_prefs = {
.phe_threshold = 13.0,
},
.mod = false,
- .mod_ppO2 = 1.6,
+ .modppO2 = 1.6,
.ead = false,
- .heart_rate = true,
- .profile_dc_ceiling = true,
- .profile_red_ceiling = false,
- .profile_calc_ceiling = false,
- .calc_ceiling_3m_incr = false,
- .calc_ndl_tts = false,
+ .hrgraph = true,
+ .dcceiling = true,
+ .redceiling = false,
+ .calcceiling = false,
+ .calcceiling3m = false,
+ .calcndltts = false,
.gflow = 30,
.gfhigh = 75,
.animation = 500,