summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2015-05-20 12:25:46 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-05-20 10:34:10 -0700
commit187f7dab9fb6fba4ee798beda707e82b1aeb32f0 (patch)
tree9437285e952a079f11d5a3bd0707433da093096c
parent0e78915c7e28166872039ba31448fe7615fb4661 (diff)
downloadsubsurface-187f7dab9fb6fba4ee798beda707e82b1aeb32f0.tar.gz
Add option to display GPS coordinates as decimals
This adds a field to the units preferences to have GPS coordinates show as decimals (as for example Google maps does it). Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--pref.h1
-rw-r--r--qt-ui/preferences.cpp4
-rw-r--r--qt-ui/preferences.ui283
-rw-r--r--qthelper.cpp30
-rw-r--r--subsurfacestartup.c1
5 files changed, 183 insertions, 136 deletions
diff --git a/pref.h b/pref.h
index afc5373fd..2e5bf83c7 100644
--- a/pref.h
+++ b/pref.h
@@ -48,6 +48,7 @@ struct preferences {
short display_invalid_dives;
short unit_system;
struct units units;
+ bool coordinates_traditional;
short show_sac;
short display_unused_tanks;
short show_average_depth;
diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp
index e4f97002e..aeccc961c 100644
--- a/qt-ui/preferences.cpp
+++ b/qt-ui/preferences.cpp
@@ -146,6 +146,8 @@ void PreferencesDialog::setUiFromPrefs()
ui.imperial->setChecked(true);
else
ui.personalize->setChecked(true);
+ ui.gpsTraditional->setChecked(prefs.coordinates_traditional);
+ ui.gpsDecimal->setChecked(!prefs.coordinates_traditional);
ui.celsius->setChecked(prefs.units.temperature == units::CELSIUS);
ui.fahrenheit->setChecked(prefs.units.temperature == units::FAHRENHEIT);
@@ -306,6 +308,7 @@ void PreferencesDialog::syncSettings()
s.setValue("volume", ui.cuft->isChecked() ? units::CUFT : units::LITER);
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.setValue("coordinates", ui.gpsTraditional->isChecked());
s.endGroup();
// Defaults
@@ -384,6 +387,7 @@ void PreferencesDialog::loadSettings()
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);
diff --git a/qt-ui/preferences.ui b/qt-ui/preferences.ui
index e67925f56..84c90d7ff 100644
--- a/qt-ui/preferences.ui
+++ b/qt-ui/preferences.ui
@@ -22,127 +22,6 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
- <widget class="QListWidget" name="listWidget">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Expanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>80</width>
- <height>0</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>80</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="iconSize">
- <size>
- <width>40</width>
- <height>40</height>
- </size>
- </property>
- <property name="textElideMode">
- <enum>Qt::ElideNone</enum>
- </property>
- <property name="movement">
- <enum>QListView::Static</enum>
- </property>
- <property name="isWrapping" stdset="0">
- <bool>true</bool>
- </property>
- <property name="layoutMode">
- <enum>QListView::Batched</enum>
- </property>
- <property name="spacing">
- <number>0</number>
- </property>
- <property name="gridSize">
- <size>
- <width>70</width>
- <height>60</height>
- </size>
- </property>
- <property name="viewMode">
- <enum>QListView::IconMode</enum>
- </property>
- <property name="uniformItemSizes">
- <bool>false</bool>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- <property name="currentRow">
- <number>-1</number>
- </property>
- <item>
- <property name="text">
- <string>Defaults</string>
- </property>
- <property name="icon">
- <iconset>
- <normalon>:/subsurface-icon</normalon>
- </iconset>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Units</string>
- </property>
- <property name="icon">
- <iconset>
- <normalon>:/units</normalon>
- </iconset>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Graph</string>
- </property>
- <property name="icon">
- <iconset>
- <normalon>:/graph</normalon>
- </iconset>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Language</string>
- </property>
- <property name="icon">
- <iconset>
- <normalon>:/advanced</normalon>
- </iconset>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Network</string>
- </property>
- <property name="icon">
- <iconset>
- <normalon>:/network</normalon>
- </iconset>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Facebook</string>
- </property>
- <property name="icon">
- <iconset>
- <normalon>:/facebook</normalon>
- </iconset>
- </property>
- </item>
- </widget>
- </item>
- <item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
@@ -585,6 +464,42 @@
</layout>
</item>
<item>
+ <widget class="QGroupBox" name="groupBox_11">
+ <property name="title">
+ <string>GPS coordinates</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_12">
+ <item>
+ <widget class="QLabel" name="label_27">
+ <property name="text">
+ <string>Location Display</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="gpsTraditional">
+ <property name="text">
+ <string>traditional (dms)</string>
+ </property>
+ <attribute name="buttonGroup">
+ <string notr="true">buttonGroup_7</string>
+ </attribute>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="gpsDecimal">
+ <property name="text">
+ <string>decimal</string>
+ </property>
+ <attribute name="buttonGroup">
+ <string notr="true">buttonGroup_7</string>
+ </attribute>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -1077,6 +992,127 @@
</widget>
</widget>
</item>
+ <item>
+ <widget class="QListWidget" name="listWidget">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>80</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>80</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>40</width>
+ <height>40</height>
+ </size>
+ </property>
+ <property name="textElideMode">
+ <enum>Qt::ElideNone</enum>
+ </property>
+ <property name="movement">
+ <enum>QListView::Static</enum>
+ </property>
+ <property name="isWrapping" stdset="0">
+ <bool>true</bool>
+ </property>
+ <property name="layoutMode">
+ <enum>QListView::Batched</enum>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="gridSize">
+ <size>
+ <width>70</width>
+ <height>60</height>
+ </size>
+ </property>
+ <property name="viewMode">
+ <enum>QListView::IconMode</enum>
+ </property>
+ <property name="uniformItemSizes">
+ <bool>false</bool>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ <property name="currentRow">
+ <number>-1</number>
+ </property>
+ <item>
+ <property name="text">
+ <string>Defaults</string>
+ </property>
+ <property name="icon">
+ <iconset>
+ <normalon>:/subsurface-icon</normalon>
+ </iconset>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Units</string>
+ </property>
+ <property name="icon">
+ <iconset>
+ <normalon>:/units</normalon>
+ </iconset>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Graph</string>
+ </property>
+ <property name="icon">
+ <iconset>
+ <normalon>:/graph</normalon>
+ </iconset>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Language</string>
+ </property>
+ <property name="icon">
+ <iconset>
+ <normalon>:/advanced</normalon>
+ </iconset>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Network</string>
+ </property>
+ <property name="icon">
+ <iconset>
+ <normalon>:/network</normalon>
+ </iconset>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Facebook</string>
+ </property>
+ <property name="icon">
+ <iconset>
+ <normalon>:/facebook</normalon>
+ </iconset>
+ </property>
+ </item>
+ </widget>
+ </item>
</layout>
</item>
<item>
@@ -1431,12 +1467,13 @@
</connection>
</connections>
<buttongroups>
- <buttongroup name="buttonGroup"/>
+ <buttongroup name="verticalSpeed"/>
<buttongroup name="buttonGroup_2"/>
<buttongroup name="buttonGroup_3"/>
<buttongroup name="buttonGroup_4"/>
<buttongroup name="buttonGroup_5"/>
+ <buttongroup name="buttonGroup"/>
<buttongroup name="buttonGroup_6"/>
- <buttongroup name="verticalSpeed"/>
+ <buttongroup name="buttonGroup_7"/>
</buttongroups>
</ui>
diff --git a/qthelper.cpp b/qthelper.cpp
index 030ed94c9..bbe908e6f 100644
--- a/qthelper.cpp
+++ b/qthelper.cpp
@@ -84,19 +84,23 @@ extern "C" const char *printGPSCoords(int lat, int lon)
if (!lat && !lon)
return strdup("");
- lath = lat >= 0 ? translate("gettextFromC", "N") : translate("gettextFromC", "S");
- lonh = lon >= 0 ? translate("gettextFromC", "E") : translate("gettextFromC", "W");
- lat = abs(lat);
- lon = abs(lon);
- latdeg = lat / 1000000U;
- londeg = lon / 1000000U;
- latmin = (lat % 1000000U) * 60U;
- lonmin = (lon % 1000000U) * 60U;
- latsec = (latmin % 1000000) * 60;
- lonsec = (lonmin % 1000000) * 60;
- result.sprintf("%u%s%02d\'%06.3f\"%s %u%s%02d\'%06.3f\"%s",
- latdeg, UTF8_DEGREE, latmin / 1000000, latsec / 1000000, lath.toUtf8().data(),
- londeg, UTF8_DEGREE, lonmin / 1000000, lonsec / 1000000, lonh.toUtf8().data());
+ if (prefs.coordinates_traditional) {
+ lath = lat >= 0 ? translate("gettextFromC", "N") : translate("gettextFromC", "S");
+ lonh = lon >= 0 ? translate("gettextFromC", "E") : translate("gettextFromC", "W");
+ lat = abs(lat);
+ lon = abs(lon);
+ latdeg = lat / 1000000U;
+ londeg = lon / 1000000U;
+ latmin = (lat % 1000000U) * 60U;
+ lonmin = (lon % 1000000U) * 60U;
+ latsec = (latmin % 1000000) * 60;
+ lonsec = (lonmin % 1000000) * 60;
+ result.sprintf("%u%s%02d\'%06.3f\"%s %u%s%02d\'%06.3f\"%s",
+ latdeg, UTF8_DEGREE, latmin / 1000000, latsec / 1000000, lath.toUtf8().data(),
+ londeg, UTF8_DEGREE, lonmin / 1000000, lonsec / 1000000, lonh.toUtf8().data());
+ } else {
+ result.sprintf("%f %f", (double) lat / 1000000.0, (double) lon / 1000000.0);
+ }
return strdup(result.toUtf8().data());
}
diff --git a/subsurfacestartup.c b/subsurfacestartup.c
index d7a7ede4d..886365a16 100644
--- a/subsurfacestartup.c
+++ b/subsurfacestartup.c
@@ -7,6 +7,7 @@ struct preferences prefs;
struct preferences default_prefs = {
.units = SI_UNITS,
.unit_system = METRIC,
+ .coordinates_traditional = true,
.pp_graphs = {
.po2 = false,
.pn2 = false,