aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets/preferences
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2015-09-25 17:07:04 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-10-30 10:36:50 -0700
commit57d7b59bdc62a5b01fa420bc420dbdcf1414a23a (patch)
tree779d151e52950f882713fd17ab93042639dd7f5d /desktop-widgets/preferences
parentc53615315e151a2790218c13898f128d561df1b9 (diff)
downloadsubsurface-57d7b59bdc62a5b01fa420bc420dbdcf1414a23a.tar.gz
Preferences: move units to the new dialog
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets/preferences')
-rw-r--r--desktop-widgets/preferences/CMakeLists.txt1
-rw-r--r--desktop-widgets/preferences/preferences_units.cpp60
-rw-r--r--desktop-widgets/preferences/preferences_units.h21
-rw-r--r--desktop-widgets/preferences/preferences_units.ui251
-rw-r--r--desktop-widgets/preferences/preferencesdialog.cpp2
5 files changed, 335 insertions, 0 deletions
diff --git a/desktop-widgets/preferences/CMakeLists.txt b/desktop-widgets/preferences/CMakeLists.txt
index c55d7b881..8ea4bd79c 100644
--- a/desktop-widgets/preferences/CMakeLists.txt
+++ b/desktop-widgets/preferences/CMakeLists.txt
@@ -15,6 +15,7 @@ set(SUBSURFACE_PREFERENCES_LIB_SRCS
preferences_language.cpp
preferences_georeference.cpp
preferences_defaults.cpp
+ preferences_units.cpp
)
source_group("Subsurface Preferences" FILES ${SUBSURFACE_PREFERENCES_LIB_SRCS})
diff --git a/desktop-widgets/preferences/preferences_units.cpp b/desktop-widgets/preferences/preferences_units.cpp
new file mode 100644
index 000000000..76f2078d7
--- /dev/null
+++ b/desktop-widgets/preferences/preferences_units.cpp
@@ -0,0 +1,60 @@
+#include "preferences_units.h"
+#include "ui_preferences_units.h"
+#include "prefs-macros.h"
+#include "qthelper.h"
+
+#include <QSettings>
+
+PreferencesUnits::PreferencesUnits(): AbstractPreferencesWidget(tr("Units"),QIcon(":units"),1), ui(new Ui::PreferencesUnits())
+{
+ ui->setupUi(this);
+}
+
+PreferencesUnits::~PreferencesUnits()
+{
+
+}
+
+void PreferencesUnits::refreshSettings()
+{
+ QSettings s;
+ s.beginGroup("Units");
+ QString unitSystem[] = {"metric", "imperial", "personal"};
+ short unitValue = ui->metric->isChecked() ? METRIC : (ui->imperial->isChecked() ? IMPERIAL : PERSONALIZE);
+ SAVE_OR_REMOVE_SPECIAL("unit_system", default_prefs.unit_system, unitValue, unitSystem[unitValue]);
+ s.setValue("temperature", ui->fahrenheit->isChecked() ? units::FAHRENHEIT : units::CELSIUS);
+ s.setValue("length", ui->feet->isChecked() ? units::FEET : units::METERS);
+ s.setValue("pressure", ui->psi->isChecked() ? units::PSI : units::BAR);
+ 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();
+}
+
+void PreferencesUnits::syncSettings()
+{
+ switch(prefs.unit_system) {
+ case METRIC: ui->metric->setChecked(true); break;
+ case IMPERIAL: ui->imperial->setChecked(true); break;
+ default: ui->personalize->setChecked(true); break;
+ }
+
+ 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);
+ ui->meter->setChecked(prefs.units.length == units::METERS);
+ ui->feet->setChecked(prefs.units.length == units::FEET);
+ ui->bar->setChecked(prefs.units.pressure == units::BAR);
+ ui->psi->setChecked(prefs.units.pressure == units::PSI);
+ ui->liter->setChecked(prefs.units.volume == units::LITER);
+ ui->cuft->setChecked(prefs.units.volume == units::CUFT);
+ ui->kg->setChecked(prefs.units.weight == units::KG);
+ ui->lbs->setChecked(prefs.units.weight == units::LBS);
+ ui->units_group->setEnabled(ui->personalize->isChecked());
+
+ ui->vertical_speed_minutes->setChecked(prefs.units.vertical_speed_time == units::MINUTES);
+ ui->vertical_speed_seconds->setChecked(prefs.units.vertical_speed_time == units::SECONDS);
+}
diff --git a/desktop-widgets/preferences/preferences_units.h b/desktop-widgets/preferences/preferences_units.h
new file mode 100644
index 000000000..21a7f4404
--- /dev/null
+++ b/desktop-widgets/preferences/preferences_units.h
@@ -0,0 +1,21 @@
+#ifndef PREFERENCES_UNITS_H
+#define PREFERENCES_UNITS_H
+
+#include "abstractpreferenceswidget.h"
+
+namespace Ui {
+ class PreferencesUnits;
+}
+
+class PreferencesUnits : public AbstractPreferencesWidget {
+ Q_OBJECT
+public:
+ PreferencesUnits();
+ virtual ~PreferencesUnits();
+ virtual void refreshSettings();
+ virtual void syncSettings();
+private:
+ Ui::PreferencesUnits *ui;
+};
+
+#endif \ No newline at end of file
diff --git a/desktop-widgets/preferences/preferences_units.ui b/desktop-widgets/preferences/preferences_units.ui
new file mode 100644
index 000000000..bb1ffba66
--- /dev/null
+++ b/desktop-widgets/preferences/preferences_units.ui
@@ -0,0 +1,251 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>PreferencesUnits</class>
+ <widget class="QWidget" name="PreferencesUnits">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>374</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QGroupBox" name="groupBox_units">
+ <property name="title">
+ <string>Unit system</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="label_6">
+ <property name="text">
+ <string>System</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="metric">
+ <property name="text">
+ <string>&amp;Metric</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="imperial">
+ <property name="text">
+ <string>Imperial</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="personalize">
+ <property name="text">
+ <string>Personali&amp;ze</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="units_group">
+ <property name="title">
+ <string>Individual settings</string>
+ </property>
+ <property name="checkable">
+ <bool>false</bool>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Depth</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QRadioButton" name="meter">
+ <property name="text">
+ <string>meter</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QRadioButton" name="feet">
+ <property name="text">
+ <string>feet</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Pressure</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QRadioButton" name="bar">
+ <property name="text">
+ <string>bar</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QRadioButton" name="psi">
+ <property name="text">
+ <string>psi</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Volume</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QRadioButton" name="liter">
+ <property name="text">
+ <string>&amp;liter</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="QRadioButton" name="cuft">
+ <property name="text">
+ <string>cu ft</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Temperature</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QRadioButton" name="celsius">
+ <property name="text">
+ <string>celsius</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="2">
+ <widget class="QRadioButton" name="fahrenheit">
+ <property name="text">
+ <string>fahrenheit</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Weight</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QRadioButton" name="kg">
+ <property name="text">
+ <string>kg</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="2">
+ <widget class="QRadioButton" name="lbs">
+ <property name="text">
+ <string>lbs</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Time units</string>
+ </property>
+ <layout class="QGridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label13">
+ <property name="text">
+ <string>Ascent/descent speed denominator</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QRadioButton" name="vertical_speed_minutes">
+ <property name="text">
+ <string>Minutes</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QRadioButton" name="vertical_speed_seconds">
+ <property name="text">
+ <string>Seconds</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </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>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="gpsDecimal">
+ <property name="text">
+ <string>decimal</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/desktop-widgets/preferences/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp
index 6f66d856d..7d9e17d7e 100644
--- a/desktop-widgets/preferences/preferencesdialog.cpp
+++ b/desktop-widgets/preferences/preferencesdialog.cpp
@@ -4,6 +4,7 @@
#include "preferences_language.h"
#include "preferences_georeference.h"
#include "preferences_defaults.h"
+#include "preferences_units.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
@@ -37,6 +38,7 @@ PreferencesDialogV2::PreferencesDialogV2()
addPreferencePage(new PreferencesLanguage());
addPreferencePage(new PreferencesGeoreference());
addPreferencePage(new PreferencesDefaults());
+ addPreferencePage(new PreferencesUnits());
refreshPages();
connect(pagesList, &QListWidget::currentRowChanged,