summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/globe.cpp10
-rw-r--r--qt-ui/mainwindow.cpp14
-rw-r--r--qt-ui/preferences.cpp85
-rw-r--r--qt-ui/preferences.h10
-rw-r--r--qt-ui/preferences.ui77
-rw-r--r--qt-ui/profilegraphics.cpp71
6 files changed, 172 insertions, 95 deletions
diff --git a/qt-ui/globe.cpp b/qt-ui/globe.cpp
index fea564644..c1abd082f 100644
--- a/qt-ui/globe.cpp
+++ b/qt-ui/globe.cpp
@@ -39,8 +39,6 @@ GlobeGPS::GlobeGPS(QWidget* parent) : MarbleWidget(parent), loadedDives(0)
setShowOverviewMap(false);
setShowScaleBar(true);
setShowCompass(false);
- // set the zoom as seen from n kilometer above. 3km / 10,000ft seems pleasant
- zoomView(zoomFromDistance(3));
}
void GlobeGPS::reload()
@@ -52,6 +50,8 @@ void GlobeGPS::reload()
if (editingDiveCoords) {
editingDiveCoords = 0;
+ if (messageWidget->isVisible())
+ messageWidget->animatedHide();
}
loadedDives = new GeoDataDocument;
@@ -90,6 +90,12 @@ void GlobeGPS::centerOn(dive* dive)
prepareForGetDiveCoordinates(dive);
return;
}
+
+ // set the zoom as seen from n kilometer above. 3km / 10,000ft seems pleasant
+ // do not change it it was already modified by user
+ if (!zoom())
+ zoomView(zoomFromDistance(3));
+
centerOn(longitude,latitude, true);
}
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 69ffdb224..8c600ea19 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -372,11 +372,11 @@ void MainWindow::readSettings()
GET_BOOL(v, "OTU", prefs.visible_cols.otu);
GET_BOOL(v, "MAXCNS", prefs.visible_cols.maxcns);
GET_BOOL(v, "SAC", prefs.visible_cols.sac);
+ settings.endGroup();
+ settings.beginGroup("TecDetails");
GET_BOOL(v, "po2graph", prefs.pp_graphs.po2);
GET_BOOL(v, "pn2graph", prefs.pp_graphs.pn2);
GET_BOOL(v, "phegraph", prefs.pp_graphs.phe);
- settings.endGroup();
- settings.beginGroup("TecDetails");
v = settings.value(QString("po2threshold"));
if (v.isValid())
prefs.pp_graphs.po2_threshold = v.toDouble();
@@ -392,14 +392,15 @@ void MainWindow::readSettings()
prefs.mod_ppO2 = v.toDouble();
GET_BOOL(v, "ead", prefs.ead);
GET_BOOL(v, "redceiling", prefs.profile_red_ceiling);
+ GET_BOOL(v, "dcceiling", prefs.profile_dc_ceiling);
GET_BOOL(v, "calcceiling", prefs.profile_calc_ceiling);
GET_BOOL(v, "calcceiling3m", prefs.calc_ceiling_3m_incr);
v = settings.value(QString("gflow"));
if (v.isValid())
- prefs.gflow = v.toInt() / 100.0;
+ prefs.gflow = v.toInt();
v = settings.value(QString("gfhigh"));
if (v.isValid())
- prefs.gfhigh = v.toInt() / 100.0;
+ prefs.gfhigh = v.toInt();
set_gf(prefs.gflow, prefs.gfhigh);
settings.endGroup();
@@ -420,7 +421,9 @@ void MainWindow::readSettings()
#define SAVE_VALUE(name, field) \
if (prefs.field != default_prefs.field) \
- settings.setValue(name, prefs.field)
+ settings.setValue(name, prefs.field); \
+ else \
+ settings.remove(name)
void MainWindow::writeSettings()
{
@@ -468,6 +471,7 @@ void MainWindow::writeSettings()
SAVE_VALUE("redceiling", profile_red_ceiling);
SAVE_VALUE("calcceiling", profile_calc_ceiling);
SAVE_VALUE("calcceiling3m", calc_ceiling_3m_incr);
+ SAVE_VALUE("dcceiling", profile_dc_ceiling);
SAVE_VALUE("gflow", gflow);
SAVE_VALUE("gfhigh", gfhigh);
settings.endGroup();
diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp
index 3e684d88a..453f20c34 100644
--- a/qt-ui/preferences.cpp
+++ b/qt-ui/preferences.cpp
@@ -1,6 +1,5 @@
#include "preferences.h"
#include "ui_preferences.h"
-#include "../dive.h"
#include <QSettings>
PreferencesDialog* PreferencesDialog::instance()
@@ -9,32 +8,42 @@ PreferencesDialog* PreferencesDialog::instance()
return dialog;
}
+#define B(V, P) s.value(#V, default_prefs.P).toBool()
+#define D(V, P) s.value(#V, default_prefs.P).toDouble()
+#define I(V, P) s.value(#V, default_prefs.P).toInt()
+
PreferencesDialog::PreferencesDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f)
, ui(new Ui::PreferencesDialog())
{
ui->setupUi(this);
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(syncSettings()));
+ connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(resetSettings()));
- #define B(X) s.value(#X, false).toBool()
- #define D(X) s.value(#X, 0.0).toDouble()
+ oldPrefs = prefs;
QSettings s;
// Graph
s.beginGroup("TecDetails");
- ui->calculated_ceiling->setChecked(B(show_calculated_ceiling));
- ui->phe->setChecked(B(show_phe));
- ui->po2->setChecked(B(show_po2));
- ui->pn2->setChecked(B(show_pn2));
- ui->pheThreshould->setValue(D(phe_threshould));
- ui->po2Threashould->setValue(D(po2_threshould));
- ui->pn2Threshould->setValue(D(pn2_threshould));
- ui->ead_end_eadd->setChecked(B(show_ead_end_eadd));
- ui->dc_reported_ceiling->setChecked(B(show_dc_reported_ceiling));
- ui->calculated_ceiling->setChecked(B(show_calculated_ceiling));
- ui->increment_3m->setChecked(B(show_3m_increments));
- ui->gflow->setValue(D(gflow));
- ui->gfhigh->setValue(D(gfhigh));
+ ui->phe->setChecked(B(phegraph, pp_graphs.phe));
+ ui->pheThreshold->setEnabled(ui->phe->isChecked());
+ ui->po2->setChecked(B(po2graph, pp_graphs.po2));
+ ui->po2Threshold->setEnabled(ui->po2->isChecked());
+ ui->pn2->setChecked(B(pn2graph, pp_graphs.pn2));
+ ui->pn2Threshold->setEnabled(ui->pn2->isChecked());
+ ui->pheThreshold->setValue(D(phethreshold, pp_graphs.phe_threshold));
+ ui->po2Threshold->setValue(D(po2threshold, pp_graphs.po2_threshold));
+ ui->pn2Threshold->setValue(D(pn2threshold, pp_graphs.pn2_threshold));
+ ui->ead_end_eadd->setChecked(B(ead, ead));
+ ui->dc_reported_ceiling->setChecked(B(dcceiling, profile_dc_ceiling));
+ ui->red_ceiling->setEnabled(ui->dc_reported_ceiling->isChecked());
+ ui->red_ceiling->setChecked(B(redceiling, profile_red_ceiling));
+ ui->calculated_ceiling->setChecked(B(calcceiling, profile_calc_ceiling));
+ ui->increment_3m->setEnabled(ui->calculated_ceiling->isChecked());
+ ui->increment_3m->setChecked(B(calcceiling3m, calc_ceiling_3m_incr));
+
+ ui->gflow->setValue((int)(I(gflow, gflow)));
+ ui->gfhigh->setValue((int)(I(gfhigh, gfhigh)));
s.endGroup();
// Units
@@ -68,36 +77,45 @@ PreferencesDialog::PreferencesDialog(QWidget* parent, Qt::WindowFlags f) : QDial
// Defaults
s.beginGroup("GeneralSettings");
ui->font->setFont( QFont(s.value("table_fonts").toString()));
- ui->fontsize->setValue(D(font_size));
+ ui->fontsize->setValue(D(font_size, font_size));
- ui->defaultfilename->setText(s.value("default_file").toString());
- ui->displayinvalid->setChecked(B(show_invalid));
+ ui->defaultfilename->setText(s.value("default_filename").toString());
+ ui->displayinvalid->setChecked(B(show_invalid, show_invalid));
s.endGroup();
+}
+
#undef B
#undef D
+
+void PreferencesDialog::resetSettings()
+{
+ prefs = oldPrefs;
}
+#define SB(V, B) s.setValue(V, (int)(B->isChecked() ? 1 : 0))
+
void PreferencesDialog::syncSettings()
{
QSettings s;
// Graph
s.beginGroup("TecDetails");
- s.setValue("show_calculated_ceiling", ui->calculated_ceiling->isChecked());
- s.setValue("show_phe", ui->phe->isChecked());
- s.setValue("show_po2", ui->po2->isChecked());
- s.setValue("show_pn2", ui->pn2->isChecked());
- s.setValue("phe_threshould", ui->pheThreshould->value());
- s.setValue("po2_threshould", ui->po2Threashould->value());
- s.setValue("pn2_threshould", ui->pn2Threshould->value());
- s.setValue("show_ead_end_eadd", ui->ead_end_eadd->isChecked());
- s.setValue("show_dc_reported_ceiling", ui->dc_reported_ceiling->isChecked());
- s.setValue("show_calculated_ceiling", ui->calculated_ceiling->isChecked());
-
- s.setValue("show_3m_increments", ui->increment_3m->isChecked());
+
+ SB("phegraph", ui->phe);
+ SB("po2graph", ui->po2);
+ SB("pn2graph", ui->pn2);
+ s.setValue("phethreshold", ui->pheThreshold->value());
+ s.setValue("po2threshold", ui->po2Threshold->value());
+ s.setValue("pn2threshold", ui->pn2Threshold->value());
+ SB("ead", ui->ead_end_eadd);
+ SB("dcceiling", ui->dc_reported_ceiling);
+ SB("redceiling", ui->red_ceiling);
+ SB("calcceiling", ui->calculated_ceiling);
+ SB("calcceiling3m", ui->increment_3m);
s.setValue("gflow", ui->gflow->value());
s.setValue("gfhigh", ui->gfhigh->value());
s.endGroup();
+
// Units
s.beginGroup("Units");
s.setValue("units_metric", ui->metric->isChecked());
@@ -111,10 +129,13 @@ void PreferencesDialog::syncSettings()
s.beginGroup("GeneralSettings");
s.value("table_fonts", ui->font->font().family());
s.value("font_size", ui->fontsize->value());
- s.value("default_file", ui->defaultfilename->text());
+ s.value("default_filename", ui->defaultfilename->text());
s.value("displayinvalid", ui->displayinvalid->isChecked());
s.endGroup();
s.sync();
+ oldPrefs = prefs;
emit settingsChanged();
}
+
+#undef SB
diff --git a/qt-ui/preferences.h b/qt-ui/preferences.h
index ab5a214ed..34fc26b07 100644
--- a/qt-ui/preferences.h
+++ b/qt-ui/preferences.h
@@ -2,6 +2,8 @@
#define PREFERENCES_DIALOG_H
#include <QDialog>
+#include "../dive.h"
+#include "../pref.h"
namespace Ui{
class PreferencesDialog;
@@ -17,10 +19,12 @@ signals:
public slots:
void syncSettings();
-
+ void resetSettings();
+
private:
explicit PreferencesDialog(QWidget* parent = 0, Qt::WindowFlags f = 0);
- Ui::PreferencesDialog* ui;
+ Ui::PreferencesDialog* ui;
+ struct preferences oldPrefs;
};
-#endif \ No newline at end of file
+#endif
diff --git a/qt-ui/preferences.ui b/qt-ui/preferences.ui
index e36aef5b3..348e62ecd 100644
--- a/qt-ui/preferences.ui
+++ b/qt-ui/preferences.ui
@@ -449,12 +449,12 @@
<bool>false</bool>
</property>
<property name="text">
- <string>threshould</string>
+ <string>threshold</string>
</property>
</widget>
</item>
<item>
- <widget class="QSpinBox" name="po2Threashould">
+ <widget class="QDoubleSpinBox" name="po2Threshold">
<property name="enabled">
<bool>false</bool>
</property>
@@ -490,12 +490,12 @@
<bool>false</bool>
</property>
<property name="text">
- <string>threshould</string>
+ <string>threshold</string>
</property>
</widget>
</item>
<item>
- <widget class="QSpinBox" name="pn2Threshould">
+ <widget class="QDoubleSpinBox" name="pn2Threshold">
<property name="enabled">
<bool>false</bool>
</property>
@@ -531,12 +531,12 @@
<bool>false</bool>
</property>
<property name="text">
- <string>threshould</string>
+ <string>threshold</string>
</property>
</widget>
</item>
<item>
- <widget class="QSpinBox" name="pheThreshould">
+ <widget class="QDoubleSpinBox" name="pheThreshold">
<property name="enabled">
<bool>false</bool>
</property>
@@ -593,12 +593,39 @@
</widget>
</item>
<item>
- <widget class="QCheckBox" name="dc_reported_ceiling">
- <property name="text">
- <string>Dive computer reported ceiling</string>
- </property>
- </widget>
- </item>
+ <layout class="QHBoxLayout" name="horizontalLayout_10b">
+ <item>
+ <widget class="QCheckBox" name="dc_reported_ceiling">
+ <property name="text">
+ <string>Dive computer reported ceiling</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_6b">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="red_ceiling">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>draw ceiling red</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
@@ -650,7 +677,7 @@
</widget>
</item>
<item row="0" column="1">
- <widget class="QDoubleSpinBox" name="gflow"/>
+ <widget class="QSpinBox" name="gflow"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_20">
@@ -660,7 +687,7 @@
</widget>
</item>
<item row="1" column="1">
- <widget class="QDoubleSpinBox" name="gfhigh"/>
+ <widget class="QSpinBox" name="gfhigh"/>
</item>
</layout>
</widget>
@@ -754,7 +781,7 @@
<connection>
<sender>po2</sender>
<signal>clicked(bool)</signal>
- <receiver>po2Threashould</receiver>
+ <receiver>po2Threshold</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
@@ -786,7 +813,7 @@
<connection>
<sender>pn2</sender>
<signal>clicked(bool)</signal>
- <receiver>pn2Threshould</receiver>
+ <receiver>pn2Threshold</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
@@ -818,7 +845,7 @@
<connection>
<sender>phe</sender>
<signal>clicked(bool)</signal>
- <receiver>pheThreshould</receiver>
+ <receiver>pheThreshold</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
@@ -864,6 +891,22 @@
</hints>
</connection>
<connection>
+ <sender>dc_ceiling</sender>
+ <signal>clicked(bool)</signal>
+ <receiver>red_ceiling</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>288</x>
+ <y>364</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>555</x>
+ <y>371</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
<sender>calculated_ceiling</sender>
<signal>clicked(bool)</signal>
<receiver>increment_3m</receiver>
diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp
index bf244e9e9..663aefe25 100644
--- a/qt-ui/profilegraphics.cpp
+++ b/qt-ui/profilegraphics.cpp
@@ -429,7 +429,7 @@ void ProfileGraphicsView::plot_pp_gas_profile()
setup_pp_limits(&gc);
QColor c;
QPointF from, to;
- //if (prefs.pp_graphs.pn2) {
+ if (prefs.pp_graphs.pn2) {
c = profile_color[PN2].first();
entry = pi->entry;
from = QPointF(SCALEGC(entry->sec, entry->pn2));
@@ -465,9 +465,9 @@ void ProfileGraphicsView::plot_pp_gas_profile()
from = QPointF(SCALEGC(entry->sec, entry->pn2));
}
}
- //}
+ }
- //if (prefs.pp_graphs.phe) {
+ if (prefs.pp_graphs.phe) {
c = profile_color[PHE].first();
entry = pi->entry;
@@ -504,8 +504,8 @@ void ProfileGraphicsView::plot_pp_gas_profile()
from = QPointF(SCALEGC(entry->sec, entry->phe));
}
}
- //}
- //if (prefs.pp_graphs.po2) {
+ }
+ if (prefs.pp_graphs.po2) {
c = profile_color[PO2].first();
entry = pi->entry;
from = QPointF(SCALEGC(entry->sec, entry->po2));
@@ -539,7 +539,7 @@ void ProfileGraphicsView::plot_pp_gas_profile()
from = QPointF(SCALEGC(entry->sec, entry->po2));
}
}
- //}
+ }
}
void ProfileGraphicsView::plot_deco_text()
@@ -549,7 +549,7 @@ void ProfileGraphicsView::plot_deco_text()
float y = gc.topy = 1.0;
static text_render_options_t tro = {PRESSURE_TEXT_SIZE, PRESSURE_TEXT, CENTER, -0.2};
gc.bottomy = 0.0;
- plot_text(&tro, QPointF(x, y), QString("GF %1/%2").arg(prefs.gflow * 100).arg(prefs.gfhigh * 100));
+ plot_text(&tro, QPointF(x, y), QString("GF %1/%2").arg(prefs.gflow).arg(prefs.gfhigh));
}
}
@@ -1000,14 +1000,16 @@ void ProfileGraphicsView::plot_depth_profile()
p.append(QPointF(SCALEGC(entry->sec, entry->depth)));
/* Show any ceiling we may have encountered */
- for (i = gc.pi.nr - 1; i >= 0; i--, entry--) {
- if (entry->ndl) {
- /* non-zero NDL implies this is a safety stop, no ceiling */
- p.append(QPointF(SCALEGC(entry->sec, 0)));
- } else if (entry->stopdepth < entry->depth) {
- p.append(QPointF(SCALEGC(entry->sec, entry->stopdepth)));
- } else {
- p.append(QPointF(SCALEGC(entry->sec, entry->depth)));
+ if (prefs.profile_dc_ceiling) {
+ for (i = gc.pi.nr - 1; i >= 0; i--, entry--) {
+ if (entry->ndl) {
+ /* non-zero NDL implies this is a safety stop, no ceiling */
+ p.append(QPointF(SCALEGC(entry->sec, 0)));
+ } else if (entry->stopdepth < entry->depth) {
+ p.append(QPointF(SCALEGC(entry->sec, entry->stopdepth)));
+ } else {
+ p.append(QPointF(SCALEGC(entry->sec, entry->depth)));
+ }
}
}
pat.setColorAt(1, profile_color[DEPTH_BOTTOM].first());
@@ -1023,9 +1025,7 @@ void ProfileGraphicsView::plot_depth_profile()
/* if the user wants the deco ceiling more visible, do that here (this
* basically draws over the background that we had allowed to shine
* through so far) */
- // TODO: port the prefs.profile_red_ceiling to QSettings
-
- //if (prefs.profile_red_ceiling) {
+ if (prefs.profile_dc_ceiling && prefs.profile_red_ceiling) {
p.clear();
pat.setColorAt(0, profile_color[CEILING_SHALLOW].first());
pat.setColorAt(1, profile_color[CEILING_DEEP].first());
@@ -1049,12 +1049,10 @@ void ProfileGraphicsView::plot_depth_profile()
neatFill->setPolygon(p);
neatFill->setPen(QPen(QBrush(Qt::NoBrush),0));
scene()->addItem(neatFill);
- //}
+ }
/* finally, plot the calculated ceiling over all this */
- // TODO: Port the profile_calc_ceiling to QSettings
- // if (prefs.profile_calc_ceiling) {
-
+ if (prefs.profile_calc_ceiling) {
pat.setColorAt(0, profile_color[CALC_CEILING_SHALLOW].first());
pat.setColorAt(1, profile_color[CALC_CEILING_DEEP].first());
@@ -1073,25 +1071,26 @@ void ProfileGraphicsView::plot_depth_profile()
neatFill->setPen(QPen(QBrush(Qt::NoBrush),0));
neatFill->setBrush(pat);
scene()->addItem(neatFill);
- //}
+ }
/* next show where we have been bad and crossed the dc's ceiling */
- pat.setColorAt(0, profile_color[CEILING_SHALLOW].first());
- pat.setColorAt(1, profile_color[CEILING_DEEP].first());
-
- entry = gc.pi.entry;
- p.clear();
- p.append(QPointF(SCALEGC(0, 0)));
- for (i = 0; i < gc.pi.nr; i++, entry++)
- p.append(QPointF(SCALEGC(entry->sec, entry->depth)));
+ if (prefs.profile_dc_ceiling) {
+ pat.setColorAt(0, profile_color[CEILING_SHALLOW].first());
+ pat.setColorAt(1, profile_color[CEILING_DEEP].first());
- for (i = gc.pi.nr - 1; i >= 0; i--, entry--) {
- if (entry->ndl == 0 && entry->stopdepth > entry->depth) {
- p.append(QPointF(SCALEGC(entry->sec, entry->stopdepth)));
- } else {
+ entry = gc.pi.entry;
+ p.clear();
+ p.append(QPointF(SCALEGC(0, 0)));
+ for (i = 0; i < gc.pi.nr; i++, entry++)
p.append(QPointF(SCALEGC(entry->sec, entry->depth)));
+
+ for (i = gc.pi.nr - 1; i >= 0; i--, entry--) {
+ if (entry->ndl == 0 && entry->stopdepth > entry->depth) {
+ p.append(QPointF(SCALEGC(entry->sec, entry->stopdepth)));
+ } else {
+ p.append(QPointF(SCALEGC(entry->sec, entry->depth)));
+ }
}
}
-
neatFill = new QGraphicsPolygonItem();
neatFill->setPolygon(p);
neatFill->setPen(QPen(QBrush(Qt::NoBrush),0));