summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/preferences
diff options
context:
space:
mode:
Diffstat (limited to 'desktop-widgets/preferences')
-rw-r--r--desktop-widgets/preferences/CMakeLists.txt27
-rw-r--r--desktop-widgets/preferences/abstractpreferenceswidget.cpp21
-rw-r--r--desktop-widgets/preferences/abstractpreferenceswidget.h27
-rw-r--r--desktop-widgets/preferences/preferences_defaults.cpp103
-rw-r--r--desktop-widgets/preferences/preferences_defaults.h28
-rw-r--r--desktop-widgets/preferences/preferences_defaults.ui251
-rw-r--r--desktop-widgets/preferences/preferences_georeference.cpp45
-rw-r--r--desktop-widgets/preferences/preferences_georeference.h21
-rw-r--r--desktop-widgets/preferences/preferences_graph.cpp77
-rw-r--r--desktop-widgets/preferences/preferences_graph.h27
-rw-r--r--desktop-widgets/preferences/preferences_graph.ui268
-rw-r--r--desktop-widgets/preferences/preferences_language.cpp72
-rw-r--r--desktop-widgets/preferences/preferences_language.h21
-rw-r--r--desktop-widgets/preferences/preferences_network.cpp172
-rw-r--r--desktop-widgets/preferences/preferences_network.h28
-rw-r--r--desktop-widgets/preferences/preferences_network.ui293
-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.cpp140
-rw-r--r--desktop-widgets/preferences/preferencesdialog.h35
-rw-r--r--desktop-widgets/preferences/prefs_georeference.ui123
-rw-r--r--desktop-widgets/preferences/prefs_language.ui260
23 files changed, 2371 insertions, 0 deletions
diff --git a/desktop-widgets/preferences/CMakeLists.txt b/desktop-widgets/preferences/CMakeLists.txt
new file mode 100644
index 000000000..4e506ed73
--- /dev/null
+++ b/desktop-widgets/preferences/CMakeLists.txt
@@ -0,0 +1,27 @@
+# the profile widget
+include_directories(.
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}
+)
+
+file(GLOB SUBSURFACE_PREFERENCES_UI *.ui)
+qt5_wrap_ui(SUBSURFACE_PREFERENCES_UI_HDRS ${SUBSURFACE_PREFERENCES_UI})
+
+source_group("Subsurface Interface Files" FILES ${SUBSURFACE_PREFERENCES_UI})
+
+set(SUBSURFACE_PREFERENCES_LIB_SRCS
+ abstractpreferenceswidget.cpp
+ preferencesdialog.cpp
+ preferences_language.cpp
+ preferences_georeference.cpp
+ preferences_defaults.cpp
+ preferences_units.cpp
+ preferences_graph.cpp
+ preferences_network.cpp
+)
+
+source_group("Subsurface Preferences" FILES ${SUBSURFACE_PREFERENCES_LIB_SRCS})
+
+add_library(subsurface_desktop_preferences STATIC ${SUBSURFACE_PREFERENCES_LIB_SRCS} ${SUBSURFACE_PREFERENCES_UI_HDRS})
+target_link_libraries(subsurface_desktop_preferences ${QT_LIBRARIES})
+
diff --git a/desktop-widgets/preferences/abstractpreferenceswidget.cpp b/desktop-widgets/preferences/abstractpreferenceswidget.cpp
new file mode 100644
index 000000000..9334c74ed
--- /dev/null
+++ b/desktop-widgets/preferences/abstractpreferenceswidget.cpp
@@ -0,0 +1,21 @@
+#include "abstractpreferenceswidget.h"
+
+AbstractPreferencesWidget::AbstractPreferencesWidget(const QString& name, const QIcon& icon, float positionHeight)
+: QWidget(), _name(name), _icon(icon), _positionHeight(positionHeight)
+{
+}
+
+QIcon AbstractPreferencesWidget::icon() const
+{
+ return _icon;
+}
+
+QString AbstractPreferencesWidget::name() const
+{
+ return _name;
+}
+
+float AbstractPreferencesWidget::positionHeight() const
+{
+ return _positionHeight;
+}
diff --git a/desktop-widgets/preferences/abstractpreferenceswidget.h b/desktop-widgets/preferences/abstractpreferenceswidget.h
new file mode 100644
index 000000000..2f607c4c9
--- /dev/null
+++ b/desktop-widgets/preferences/abstractpreferenceswidget.h
@@ -0,0 +1,27 @@
+#ifndef ABSTRACTPREFERENCESWIDGET_H
+#define ABSTRACTPREFERENCESWIDGET_H
+
+#include <QIcon>
+#include <QWidget>
+
+class AbstractPreferencesWidget : public QWidget {
+ Q_OBJECT
+public:
+ AbstractPreferencesWidget(const QString& name, const QIcon& icon, float positionHeight);
+ QIcon icon() const;
+ QString name() const;
+ float positionHeight() const;
+
+ /* gets the values from the preferences and should set the correct values in
+ * the interface */
+ virtual void refreshSettings() = 0;
+
+ /* gets the values from the interface and set in the preferences object. */
+ virtual void syncSettings() = 0;
+
+private:
+ QIcon _icon;
+ QString _name;
+ float _positionHeight;
+};
+#endif \ No newline at end of file
diff --git a/desktop-widgets/preferences/preferences_defaults.cpp b/desktop-widgets/preferences/preferences_defaults.cpp
new file mode 100644
index 000000000..45888ebec
--- /dev/null
+++ b/desktop-widgets/preferences/preferences_defaults.cpp
@@ -0,0 +1,103 @@
+#include "preferences_defaults.h"
+#include "ui_preferences_defaults.h"
+#include "dive.h"
+#include "subsurface-core/prefs-macros.h"
+
+#include <QSettings>
+#include <QFileDialog>
+
+PreferencesDefaults::PreferencesDefaults(): AbstractPreferencesWidget(tr("Defaults"), QIcon(":defaults"), 0 ), ui(new Ui::PreferencesDefaults())
+{
+ ui->setupUi(this);
+}
+
+PreferencesDefaults::~PreferencesDefaults()
+{
+ delete ui;
+}
+
+void PreferencesDefaults::on_chooseFile_clicked()
+{
+ QFileInfo fi(system_default_filename());
+ QString choosenFileName = QFileDialog::getOpenFileName(this, tr("Open default log file"), fi.absolutePath(), tr("Subsurface XML files (*.ssrf *.xml *.XML)"));
+
+ if (!choosenFileName.isEmpty())
+ ui->defaultfilename->setText(choosenFileName);
+}
+
+void PreferencesDefaults::on_btnUseDefaultFile_toggled(bool toggle)
+{
+ if (toggle) {
+ ui->defaultfilename->setText(system_default_filename());
+ ui->defaultfilename->setEnabled(false);
+ } else {
+ ui->defaultfilename->setEnabled(true);
+ }
+}
+
+void PreferencesDefaults::on_localDefaultFile_toggled(bool toggle)
+{
+ ui->defaultfilename->setEnabled(toggle);
+ ui->btnUseDefaultFile->setEnabled(toggle);
+ ui->chooseFile->setEnabled(toggle);
+}
+
+void PreferencesDefaults::refreshSettings()
+{
+ ui->font->setCurrentFont(QString(prefs.divelist_font));
+ ui->fontsize->setValue(prefs.font_size);
+ ui->defaultfilename->setText(prefs.default_filename);
+ ui->noDefaultFile->setChecked(prefs.default_file_behavior == NO_DEFAULT_FILE);
+ ui->cloudDefaultFile->setChecked(prefs.default_file_behavior == CLOUD_DEFAULT_FILE);
+ ui->localDefaultFile->setChecked(prefs.default_file_behavior == LOCAL_DEFAULT_FILE);
+
+ ui->default_cylinder->clear();
+ for (int i = 0; tank_info[i].name != NULL; i++) {
+ ui->default_cylinder->addItem(tank_info[i].name);
+ if (prefs.default_cylinder && strcmp(tank_info[i].name, prefs.default_cylinder) == 0)
+ ui->default_cylinder->setCurrentIndex(i);
+ }
+ ui->displayinvalid->setChecked(prefs.display_invalid_dives);
+ ui->velocitySlider->setValue(prefs.animation_speed);
+ ui->btnUseDefaultFile->setChecked(prefs.use_default_file);
+
+ if (prefs.cloud_verification_status == CS_VERIFIED) {
+ ui->cloudDefaultFile->setEnabled(true);
+ } else {
+ if (ui->cloudDefaultFile->isChecked())
+ ui->noDefaultFile->setChecked(true);
+ ui->cloudDefaultFile->setEnabled(false);
+ }
+
+ ui->defaultfilename->setEnabled(prefs.default_file_behavior == LOCAL_DEFAULT_FILE);
+ ui->btnUseDefaultFile->setEnabled(prefs.default_file_behavior == LOCAL_DEFAULT_FILE);
+ ui->chooseFile->setEnabled(prefs.default_file_behavior == LOCAL_DEFAULT_FILE);
+}
+
+void PreferencesDefaults::syncSettings()
+{
+ QSettings s;
+ s.beginGroup("GeneralSettings");
+ s.setValue("default_filename", ui->defaultfilename->text());
+ s.setValue("default_cylinder", ui->default_cylinder->currentText());
+ s.setValue("use_default_file", ui->btnUseDefaultFile->isChecked());
+ if (ui->noDefaultFile->isChecked())
+ s.setValue("default_file_behavior", NO_DEFAULT_FILE);
+ else if (ui->localDefaultFile->isChecked())
+ s.setValue("default_file_behavior", LOCAL_DEFAULT_FILE);
+ else if (ui->cloudDefaultFile->isChecked())
+ s.setValue("default_file_behavior", CLOUD_DEFAULT_FILE);
+ s.endGroup();
+
+ s.beginGroup("Display");
+ SAVE_OR_REMOVE_SPECIAL("divelist_font", system_divelist_default_font, ui->font->currentFont().toString(), ui->font->currentFont());
+ SAVE_OR_REMOVE("font_size", system_divelist_default_font_size, ui->fontsize->value());
+ s.setValue("displayinvalid", ui->displayinvalid->isChecked());
+ s.endGroup();
+ s.sync();
+
+ // Animation
+ s.beginGroup("Animations");
+ s.setValue("animation_speed", ui->velocitySlider->value());
+ s.endGroup();
+}
diff --git a/desktop-widgets/preferences/preferences_defaults.h b/desktop-widgets/preferences/preferences_defaults.h
new file mode 100644
index 000000000..c72be31a6
--- /dev/null
+++ b/desktop-widgets/preferences/preferences_defaults.h
@@ -0,0 +1,28 @@
+#ifndef PREFERENCES_DEFAULTS_H
+#define PREFERENCES_DEFAULTS_H
+
+#include "abstractpreferenceswidget.h"
+#include "subsurface-core/pref.h"
+
+namespace Ui {
+ class PreferencesDefaults;
+}
+
+class PreferencesDefaults : public AbstractPreferencesWidget {
+ Q_OBJECT
+public:
+ PreferencesDefaults();
+ virtual ~PreferencesDefaults();
+ virtual void refreshSettings();
+ virtual void syncSettings();
+public slots:
+ void on_chooseFile_clicked();
+ void on_btnUseDefaultFile_toggled(bool toggled);
+ void on_localDefaultFile_toggled(bool toggled);
+
+private:
+ Ui::PreferencesDefaults *ui;
+};
+
+
+#endif \ No newline at end of file
diff --git a/desktop-widgets/preferences/preferences_defaults.ui b/desktop-widgets/preferences/preferences_defaults.ui
new file mode 100644
index 000000000..632e82763
--- /dev/null
+++ b/desktop-widgets/preferences/preferences_defaults.ui
@@ -0,0 +1,251 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>PreferencesDefaults</class>
+ <widget class="QWidget" name="PreferencesDefaults">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>555</width>
+ <height>558</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="title">
+ <string>Lists and tables</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_11">
+ <property name="margin">
+ <number>5</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label_7">
+ <property name="text">
+ <string>Font</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QFontComboBox" name="font"/>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_8">
+ <property name="text">
+ <string>Font size</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDoubleSpinBox" name="fontsize"/>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_3">
+ <property name="title">
+ <string>Dives</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <property name="horizontalSpacing">
+ <number>5</number>
+ </property>
+ <property name="verticalSpacing">
+ <number>5</number>
+ </property>
+ <property name="margin">
+ <number>5</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="defaultDiveLogFileLabel">
+ <property name="text">
+ <string>Default dive log file</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <layout class="QHBoxLayout" name="defaultFileBehaviorLayout">
+ <item>
+ <widget class="QRadioButton" name="noDefaultFile">
+ <property name="text">
+ <string>No default file</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="localDefaultFile">
+ <property name="text">
+ <string>&amp;Local default file</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="cloudDefaultFile">
+ <property name="text">
+ <string>Clo&amp;ud storage default file</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_9">
+ <property name="text">
+ <string>Local dive log file</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_3b">
+ <item>
+ <widget class="QLineEdit" name="defaultfilename"/>
+ </item>
+ <item>
+ <widget class="QToolButton" name="btnUseDefaultFile">
+ <property name="text">
+ <string>Use default</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="chooseFile">
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_10">
+ <property name="text">
+ <string>Display invalid</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QCheckBox" name="displayinvalid">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_6">
+ <property name="title">
+ <string>Default cylinder</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout_6">
+ <property name="horizontalSpacing">
+ <number>5</number>
+ </property>
+ <property name="verticalSpacing">
+ <number>5</number>
+ </property>
+ <property name="margin">
+ <number>5</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_11">
+ <property name="text">
+ <string>Use default cylinder</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QComboBox" name="default_cylinder"/>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_7">
+ <property name="title">
+ <string>Animations</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_7">
+ <property name="margin">
+ <number>5</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label_15">
+ <property name="text">
+ <string>Speed</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSlider" name="velocitySlider">
+ <property name="maximum">
+ <number>500</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="velocitySpinBox">
+ <property name="maximum">
+ <number>500</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_9">
+ <property name="title">
+ <string>Clear all settings</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_7b">
+ <property name="spacing">
+ <number>5</number>
+ </property>
+ <property name="margin">
+ <number>5</number>
+ </property>
+ <item>
+ <widget class="QPushButton" name="resetSettings">
+ <property name="text">
+ <string>Reset all settings to their default value</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>0</width>
+ <height>195</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/desktop-widgets/preferences/preferences_georeference.cpp b/desktop-widgets/preferences/preferences_georeference.cpp
new file mode 100644
index 000000000..7e8ccec9d
--- /dev/null
+++ b/desktop-widgets/preferences/preferences_georeference.cpp
@@ -0,0 +1,45 @@
+#include "preferences_georeference.h"
+#include "ui_prefs_georeference.h"
+#include "prefs-macros.h"
+#include "qthelper.h"
+#include "qt-models/divelocationmodel.h"
+
+#include <ctime>
+#include <QSettings>
+
+PreferencesGeoreference::PreferencesGeoreference() : AbstractPreferencesWidget(tr("Georeference"), QIcon(":/georeference"), 9)
+{
+ ui = new Ui::PreferencesGeoreference();
+ ui->setupUi(this);
+ ui->first_item->setModel(GeoReferencingOptionsModel::instance());
+ ui->second_item->setModel(GeoReferencingOptionsModel::instance());
+ ui->third_item->setModel(GeoReferencingOptionsModel::instance());
+}
+
+PreferencesGeoreference::~PreferencesGeoreference()
+{
+ delete ui;
+}
+
+void PreferencesGeoreference::refreshSettings()
+{
+ ui->enable_geocoding->setChecked(prefs.geocoding.enable_geocoding);
+ ui->parse_without_gps->setChecked(prefs.geocoding.parse_dive_without_gps);
+ ui->tag_existing_dives->setChecked(prefs.geocoding.tag_existing_dives);
+ ui->first_item->setCurrentIndex(prefs.geocoding.category[0]);
+ ui->second_item->setCurrentIndex(prefs.geocoding.category[1]);
+ ui->third_item->setCurrentIndex(prefs.geocoding.category[2]);
+}
+
+void PreferencesGeoreference::syncSettings()
+{
+ QSettings s;
+ s.beginGroup("geocoding");
+ s.setValue("enable_geocoding", ui->enable_geocoding->isChecked());
+ s.setValue("parse_dives_without_gps", ui->parse_without_gps->isChecked());
+ s.setValue("tag_existing_dives", ui->tag_existing_dives->isChecked());
+ s.setValue("cat0", ui->first_item->currentIndex());
+ s.setValue("cat1", ui->second_item->currentIndex());
+ s.setValue("cat2", ui->third_item->currentIndex());
+ s.endGroup();
+} \ No newline at end of file
diff --git a/desktop-widgets/preferences/preferences_georeference.h b/desktop-widgets/preferences/preferences_georeference.h
new file mode 100644
index 000000000..5dd4bc445
--- /dev/null
+++ b/desktop-widgets/preferences/preferences_georeference.h
@@ -0,0 +1,21 @@
+#ifndef PREFERENCES_GEOREFERENCE_H
+#define PREFERENCES_GEOREFERENCE_H
+
+#include "abstractpreferenceswidget.h"
+
+namespace Ui {
+ class PreferencesGeoreference;
+}
+
+class PreferencesGeoreference : public AbstractPreferencesWidget {
+ Q_OBJECT
+public:
+ PreferencesGeoreference();
+ virtual ~PreferencesGeoreference();
+ virtual void refreshSettings();
+ virtual void syncSettings();
+private:
+ Ui::PreferencesGeoreference *ui;
+};
+
+#endif \ No newline at end of file
diff --git a/desktop-widgets/preferences/preferences_graph.cpp b/desktop-widgets/preferences/preferences_graph.cpp
new file mode 100644
index 000000000..327557692
--- /dev/null
+++ b/desktop-widgets/preferences/preferences_graph.cpp
@@ -0,0 +1,77 @@
+#include "preferences_graph.h"
+#include "ui_preferences_graph.h"
+#include "subsurface-core/prefs-macros.h"
+
+#include <QSettings>
+#include <QMessageBox>
+
+#include "qt-models/models.h"
+
+PreferencesGraph::PreferencesGraph() : AbstractPreferencesWidget(tr("Graph"), QIcon(":graph"), 5)
+{
+ ui = new Ui::PreferencesGraph();
+ ui->setupUi(this);
+}
+
+PreferencesGraph::~PreferencesGraph()
+{
+ delete ui;
+}
+
+void PreferencesGraph::refreshSettings()
+{
+ 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->maxpo2->setValue(prefs.modpO2);
+ ui->red_ceiling->setChecked(prefs.redceiling);
+
+ ui->gflow->setValue(prefs.gflow);
+ ui->gfhigh->setValue(prefs.gfhigh);
+ ui->gf_low_at_maxdepth->setChecked(prefs.gf_low_at_maxdepth);
+ ui->show_ccr_setpoint->setChecked(prefs.show_ccr_setpoint);
+ ui->show_ccr_sensors->setChecked(prefs.show_ccr_sensors);
+ ui->defaultSetpoint->setValue((double)prefs.defaultsetpoint / 1000.0);
+ ui->psro2rate->setValue(prefs.o2consumption / 1000.0);
+ ui->pscrfactor->setValue(rint(1000.0 / prefs.pscr_ratio));
+
+ ui->display_unused_tanks->setChecked(prefs.display_unused_tanks);
+ ui->show_average_depth->setChecked(prefs.show_average_depth);
+}
+
+void PreferencesGraph::syncSettings()
+{
+ QSettings s;
+
+ s.beginGroup("GeneralSettings");
+ s.setValue("defaultsetpoint", rint(ui->defaultSetpoint->value() * 1000.0));
+ s.setValue("o2consumption", rint(ui->psro2rate->value() *1000.0));
+ s.setValue("pscr_ratio", rint(1000.0 / ui->pscrfactor->value()));
+ s.endGroup();
+
+ s.beginGroup("TecDetails");
+ SAVE_OR_REMOVE("phethreshold", default_prefs.pp_graphs.phe_threshold, ui->pheThreshold->value());
+ SAVE_OR_REMOVE("po2threshold", default_prefs.pp_graphs.po2_threshold, ui->po2Threshold->value());
+ SAVE_OR_REMOVE("pn2threshold", default_prefs.pp_graphs.pn2_threshold, ui->pn2Threshold->value());
+ SAVE_OR_REMOVE("modpO2", default_prefs.modpO2, ui->maxpo2->value());
+ SAVE_OR_REMOVE("redceiling", default_prefs.redceiling, ui->red_ceiling->isChecked());
+ SAVE_OR_REMOVE("gflow", default_prefs.gflow, ui->gflow->value());
+ SAVE_OR_REMOVE("gfhigh", default_prefs.gfhigh, ui->gfhigh->value());
+ SAVE_OR_REMOVE("gf_low_at_maxdepth", default_prefs.gf_low_at_maxdepth, ui->gf_low_at_maxdepth->isChecked());
+ SAVE_OR_REMOVE("show_ccr_setpoint", default_prefs.show_ccr_setpoint, ui->show_ccr_setpoint->isChecked());
+ SAVE_OR_REMOVE("show_ccr_sensors", default_prefs.show_ccr_sensors, ui->show_ccr_sensors->isChecked());
+ SAVE_OR_REMOVE("display_unused_tanks", default_prefs.display_unused_tanks, ui->display_unused_tanks->isChecked());
+ SAVE_OR_REMOVE("show_average_depth", default_prefs.show_average_depth, ui->show_average_depth->isChecked());
+ s.endGroup();
+}
+
+#define DANGER_GF (gf > 100) ? "* { color: red; }" : ""
+void PreferencesGraph::on_gflow_valueChanged(int gf)
+{
+ ui->gflow->setStyleSheet(DANGER_GF);
+}
+void PreferencesGraph::on_gfhigh_valueChanged(int gf)
+{
+ ui->gfhigh->setStyleSheet(DANGER_GF);
+}
+#undef DANGER_GF \ No newline at end of file
diff --git a/desktop-widgets/preferences/preferences_graph.h b/desktop-widgets/preferences/preferences_graph.h
new file mode 100644
index 000000000..ca40c0a92
--- /dev/null
+++ b/desktop-widgets/preferences/preferences_graph.h
@@ -0,0 +1,27 @@
+#ifndef PREFERENCES_GRAPH_H
+#define PREFERENCES_GRAPH_H
+
+#include "abstractpreferenceswidget.h"
+
+namespace Ui {
+ class PreferencesGraph;
+}
+
+class PreferencesGraph : public AbstractPreferencesWidget {
+ Q_OBJECT
+public:
+ PreferencesGraph();
+ virtual ~PreferencesGraph();
+ virtual void refreshSettings();
+ virtual void syncSettings();
+
+private slots:
+ void on_gflow_valueChanged(int gf);
+ void on_gfhigh_valueChanged(int gf);
+
+private:
+ Ui::PreferencesGraph *ui;
+
+};
+
+#endif \ No newline at end of file
diff --git a/desktop-widgets/preferences/preferences_graph.ui b/desktop-widgets/preferences/preferences_graph.ui
new file mode 100644
index 000000000..bdbbc75d3
--- /dev/null
+++ b/desktop-widgets/preferences/preferences_graph.ui
@@ -0,0 +1,268 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>PreferencesGraph</class>
+ <widget class="QWidget" name="PreferencesGraph">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>505</width>
+ <height>623</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QGroupBox" name="groupBox_4">
+ <property name="title">
+ <string>Show</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_12">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Threshold when showing pO₂</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QDoubleSpinBox" name="po2Threshold">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="singleStep">
+ <double>0.100000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_13">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Threshold when showing pN₂</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QDoubleSpinBox" name="pn2Threshold">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="singleStep">
+ <double>0.100000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_17">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Threshold when showing pHe</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QDoubleSpinBox" name="pheThreshold">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="singleStep">
+ <double>0.100000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_18">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Max pO₂ when showing MOD</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QDoubleSpinBox" name="maxpo2">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="singleStep">
+ <double>0.100000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0" colspan="2">
+ <widget class="QCheckBox" name="red_ceiling">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Draw dive computer reported ceiling red</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0" colspan="2">
+ <widget class="QCheckBox" name="display_unused_tanks">
+ <property name="text">
+ <string>Show unused cylinders in Equipment tab</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0" colspan="2">
+ <widget class="QCheckBox" name="show_average_depth">
+ <property name="text">
+ <string>Show average depth</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_5">
+ <property name="title">
+ <string>Misc</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="1">
+ <widget class="QSpinBox" name="gflow">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>150</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QDoubleSpinBox" name="defaultSetpoint">
+ <property name="suffix">
+ <string>bar</string>
+ </property>
+ <property name="decimals">
+ <number>2</number>
+ </property>
+ <property name="maximum">
+ <double>10.000000000000000</double>
+ </property>
+ <property name="singleStep">
+ <double>0.100000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_26">
+ <property name="text">
+ <string>Default CCR set-point for dive planning</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="pSCR">
+ <property name="text">
+ <string>pSCR O₂ metabolism rate</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_19">
+ <property name="text">
+ <string>GFLow</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_20">
+ <property name="text">
+ <string>GFHigh</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QSpinBox" name="gfhigh">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>150</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QDoubleSpinBox" name="psro2rate">
+ <property name="suffix">
+ <string>ℓ/min</string>
+ </property>
+ <property name="decimals">
+ <number>3</number>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="label_28">
+ <property name="text">
+ <string>pSCR ratio</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QSpinBox" name="pscrfactor">
+ <property name="suffix">
+ <string/>
+ </property>
+ <property name="prefix">
+ <string>1:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="0" colspan="2">
+ <widget class="QCheckBox" name="show_ccr_sensors">
+ <property name="text">
+ <string>CCR: show individual O₂ sensor values when viewing pO₂</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0" colspan="2">
+ <widget class="QCheckBox" name="show_ccr_setpoint">
+ <property name="text">
+ <string>CCR: show setpoints when viewing pO₂</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0" colspan="2">
+ <widget class="QCheckBox" name="gf_low_at_maxdepth">
+ <property name="text">
+ <string>GFLow at max depth</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>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/desktop-widgets/preferences/preferences_language.cpp b/desktop-widgets/preferences/preferences_language.cpp
new file mode 100644
index 000000000..31bbd1c20
--- /dev/null
+++ b/desktop-widgets/preferences/preferences_language.cpp
@@ -0,0 +1,72 @@
+#include "preferences_language.h"
+#include "ui_prefs_language.h"
+#include "subsurface-core/helpers.h"
+
+#include <QApplication>
+#include <QSettings>
+#include <QMessageBox>
+#include <QSortFilterProxyModel>
+
+#include "qt-models/models.h"
+
+PreferencesLanguage::PreferencesLanguage() : AbstractPreferencesWidget(tr("Language"), QIcon(":/language"), 4)
+{
+ ui = new Ui::PreferencesLanguage();
+ ui->setupUi(this);
+
+ QSortFilterProxyModel *filterModel = new QSortFilterProxyModel();
+ filterModel->setSourceModel(LanguageModel::instance());
+ filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
+ ui->languageDropdown->setModel(filterModel);
+ filterModel->sort(0);
+ connect(ui->languageFilter, &QLineEdit::textChanged,
+ filterModel, &QSortFilterProxyModel::setFilterFixedString);
+}
+
+PreferencesLanguage::~PreferencesLanguage()
+{
+ delete ui;
+}
+
+void PreferencesLanguage::refreshSettings()
+{
+ QSettings s;
+ s.beginGroup("Language");
+ ui->languageSystemDefault->setChecked(s.value("UseSystemLanguage", true).toBool());
+ ui->timeFormatSystemDefault->setChecked(!s.value("time_format_override", false).toBool());
+ ui->dateFormatSystemDefault->setChecked(!s.value("date_format_override", false).toBool());
+ ui->timeFormatEntry->setText(s.value("time_format").toString());
+ ui->dateFormatEntry->setText(s.value("date_format").toString());
+ ui->shortDateFormatEntry->setText(s.value("date_format_short").toString());
+ QAbstractItemModel *m = ui->languageDropdown->model();
+ QModelIndexList languages = m->match(m->index(0, 0), Qt::UserRole, s.value("UiLanguage").toString());
+ if (languages.count())
+ ui->languageDropdown->setCurrentIndex(languages.first().row());
+ s.endGroup();
+}
+
+void PreferencesLanguage::syncSettings()
+{
+ QSettings s;
+ s.beginGroup("Language");
+ bool useSystemLang = s.value("UseSystemLanguage", true).toBool();
+ QAbstractItemModel *m = ui->languageDropdown->model();
+ QString currentText = m->data(m->index(ui->languageDropdown->currentIndex(),0), Qt::UserRole).toString();
+ if (useSystemLang != ui->languageSystemDefault->isChecked() ||
+ (!useSystemLang && s.value("UiLanguage").toString() != currentText)) {
+ QMessageBox::warning(this, tr("Restart required"),
+ tr("To correctly load a new language you must restart Subsurface."));
+ }
+ s.setValue("UiLanguage", currentText);
+ s.setValue("UseSystemLanguage", ui->languageSystemDefault->isChecked());
+ s.setValue("time_format_override", !ui->timeFormatSystemDefault->isChecked());
+ s.setValue("date_format_override", !ui->dateFormatSystemDefault->isChecked());
+ if (!ui->timeFormatSystemDefault->isChecked())
+ s.setValue("time_format", ui->timeFormatEntry->text());
+ if (!ui->dateFormatSystemDefault->isChecked()) {
+ s.setValue("date_format", ui->dateFormatEntry->text());
+ s.setValue("date_format_short", ui->shortDateFormatEntry->text());
+ }
+ s.endGroup();
+ uiLanguage(NULL);
+}
diff --git a/desktop-widgets/preferences/preferences_language.h b/desktop-widgets/preferences/preferences_language.h
new file mode 100644
index 000000000..43014c0fd
--- /dev/null
+++ b/desktop-widgets/preferences/preferences_language.h
@@ -0,0 +1,21 @@
+#ifndef PREFERENCES_LANGUAGE_H
+#define PREFERENCES_LANGUAGE_H
+
+#include "abstractpreferenceswidget.h"
+
+namespace Ui {
+ class PreferencesLanguage;
+}
+
+class PreferencesLanguage : public AbstractPreferencesWidget {
+ Q_OBJECT
+public:
+ PreferencesLanguage();
+ virtual ~PreferencesLanguage();
+ virtual void refreshSettings();
+ virtual void syncSettings();
+private:
+ Ui::PreferencesLanguage *ui;
+};
+
+#endif \ No newline at end of file
diff --git a/desktop-widgets/preferences/preferences_network.cpp b/desktop-widgets/preferences/preferences_network.cpp
new file mode 100644
index 000000000..3780a6c91
--- /dev/null
+++ b/desktop-widgets/preferences/preferences_network.cpp
@@ -0,0 +1,172 @@
+#include "preferences_network.h"
+#include "ui_preferences_network.h"
+#include "dive.h"
+#include "subsurfacewebservices.h"
+#include "subsurface-core/prefs-macros.h"
+
+#include <QNetworkProxy>
+#include <QSettings>
+
+PreferencesNetwork::PreferencesNetwork() : AbstractPreferencesWidget(tr("Network"),QIcon(":network"), 9), ui(new Ui::PreferencesNetwork())
+{
+ ui->setupUi(this);
+
+ ui->proxyType->clear();
+ ui->proxyType->addItem(tr("No proxy"), QNetworkProxy::NoProxy);
+ ui->proxyType->addItem(tr("System proxy"), QNetworkProxy::DefaultProxy);
+ ui->proxyType->addItem(tr("HTTP proxy"), QNetworkProxy::HttpProxy);
+ ui->proxyType->addItem(tr("SOCKS proxy"), QNetworkProxy::Socks5Proxy);
+ ui->proxyType->setCurrentIndex(-1);
+
+ connect(ui->proxyType, SIGNAL(currentIndexChanged(int)), this, SLOT(proxyType_changed(int)));
+}
+
+PreferencesNetwork::~PreferencesNetwork()
+{
+ delete ui;
+}
+
+void PreferencesNetwork::refreshSettings()
+{
+ QSettings s;
+
+ ui->proxyHost->setText(prefs.proxy_host);
+ ui->proxyPort->setValue(prefs.proxy_port);
+ ui->proxyAuthRequired->setChecked(prefs.proxy_auth);
+ ui->proxyUsername->setText(prefs.proxy_user);
+ ui->proxyPassword->setText(prefs.proxy_pass);
+ ui->proxyType->setCurrentIndex(ui->proxyType->findData(prefs.proxy_type));
+ ui->cloud_storage_email->setText(prefs.cloud_storage_email);
+ ui->cloud_storage_password->setText(prefs.cloud_storage_password);
+ ui->save_password_local->setChecked(prefs.save_password_local);
+ ui->cloud_background_sync->setChecked(prefs.cloud_background_sync);
+ ui->save_uid_local->setChecked(prefs.save_userid_local);
+ ui->default_uid->setText(s.value("subsurface_webservice_uid").toString().toUpper());
+
+ cloudPinNeeded();
+}
+
+void PreferencesNetwork::syncSettings()
+{
+ QSettings s;
+ s.setValue("subsurface_webservice_uid", ui->default_uid->text().toUpper());
+ set_save_userid_local(ui->save_uid_local->checkState());
+
+ s.beginGroup("Network");
+ s.setValue("proxy_type", ui->proxyType->itemData(ui->proxyType->currentIndex()).toInt());
+ s.setValue("proxy_host", ui->proxyHost->text());
+ s.setValue("proxy_port", ui->proxyPort->value());
+ SB("proxy_auth", ui->proxyAuthRequired);
+ s.setValue("proxy_user", ui->proxyUsername->text());
+ s.setValue("proxy_pass", ui->proxyPassword->text());
+ s.endGroup();
+
+ s.beginGroup("CloudStorage");
+ QString email = ui->cloud_storage_email->text();
+ QString password = ui->cloud_storage_password->text();
+ QString newpassword = ui->cloud_storage_new_passwd->text();
+ if (prefs.cloud_verification_status == CS_VERIFIED && !newpassword.isEmpty()) {
+ // deal with password change
+ if (!email.isEmpty() && !password.isEmpty()) {
+ // connect to backend server to check / create credentials
+ QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$");
+ if (!reg.match(email).hasMatch() || (!password.isEmpty() && !reg.match(password).hasMatch())) {
+ report_error(qPrintable(tr("Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'.")));
+ } else {
+ CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
+ connect(cloudAuth, SIGNAL(finishedAuthenticate()), this, SLOT(cloudPinNeeded()));
+ connect(cloudAuth, SIGNAL(passwordChangeSuccessful()), this, SLOT(passwordUpdateSuccessfull()));
+ QNetworkReply *reply = cloudAuth->backend(email, password, "", newpassword);
+ ui->cloud_storage_new_passwd->setText("");
+ free(prefs.cloud_storage_newpassword);
+ prefs.cloud_storage_newpassword = strdup(qPrintable(newpassword));
+ }
+ }
+ } else if (prefs.cloud_verification_status == CS_UNKNOWN ||
+ prefs.cloud_verification_status == CS_INCORRECT_USER_PASSWD ||
+ email != prefs.cloud_storage_email ||
+ password != prefs.cloud_storage_password) {
+
+ // different credentials - reset verification status
+ prefs.cloud_verification_status = CS_UNKNOWN;
+ if (!email.isEmpty() && !password.isEmpty()) {
+ // connect to backend server to check / create credentials
+ QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$");
+ if (!reg.match(email).hasMatch() || (!password.isEmpty() && !reg.match(password).hasMatch())) {
+ report_error(qPrintable(tr("Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'.")));
+ } else {
+ CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
+ connect(cloudAuth, SIGNAL(finishedAuthenticate()), this, SLOT(cloudPinNeeded()));
+ QNetworkReply *reply = cloudAuth->backend(email, password);
+ }
+ }
+ } else if (prefs.cloud_verification_status == CS_NEED_TO_VERIFY) {
+ QString pin = ui->cloud_storage_pin->text();
+ if (!pin.isEmpty()) {
+ // connect to backend server to check / create credentials
+ QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$");
+ if (!reg.match(email).hasMatch() || !reg.match(password).hasMatch()) {
+ report_error(qPrintable(tr("Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'.")));
+ }
+ CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
+ connect(cloudAuth, SIGNAL(finishedAuthenticate()), this, SLOT(cloudPinNeeded()));
+ QNetworkReply *reply = cloudAuth->backend(email, password, pin);
+ }
+ }
+ SAVE_OR_REMOVE("email", default_prefs.cloud_storage_email, email);
+ SAVE_OR_REMOVE("save_password_local", default_prefs.save_password_local, ui->save_password_local->isChecked());
+ if (ui->save_password_local->isChecked()) {
+ SAVE_OR_REMOVE("password", default_prefs.cloud_storage_password, password);
+ } else {
+ s.remove("password");
+ free(prefs.cloud_storage_password);
+ prefs.cloud_storage_password = strdup(qPrintable(password));
+ }
+ SAVE_OR_REMOVE("cloud_verification_status", default_prefs.cloud_verification_status, prefs.cloud_verification_status);
+ SAVE_OR_REMOVE("cloud_background_sync", default_prefs.cloud_background_sync, ui->cloud_background_sync->isChecked());
+
+ // at this point we intentionally do not have a UI for changing this
+ // it could go into some sort of "advanced setup" or something
+ SAVE_OR_REMOVE("cloud_base_url", default_prefs.cloud_base_url, prefs.cloud_base_url);
+ s.endGroup();
+}
+
+void PreferencesNetwork::cloudPinNeeded()
+{
+ ui->cloud_storage_pin->setEnabled(prefs.cloud_verification_status == CS_NEED_TO_VERIFY);
+ ui->cloud_storage_pin->setVisible(prefs.cloud_verification_status == CS_NEED_TO_VERIFY);
+ ui->cloud_storage_pin_label->setEnabled(prefs.cloud_verification_status == CS_NEED_TO_VERIFY);
+ ui->cloud_storage_pin_label->setVisible(prefs.cloud_verification_status == CS_NEED_TO_VERIFY);
+ ui->cloud_storage_new_passwd->setEnabled(prefs.cloud_verification_status == CS_VERIFIED);
+ ui->cloud_storage_new_passwd->setVisible(prefs.cloud_verification_status == CS_VERIFIED);
+ ui->cloud_storage_new_passwd_label->setEnabled(prefs.cloud_verification_status == CS_VERIFIED);
+ ui->cloud_storage_new_passwd_label->setVisible(prefs.cloud_verification_status == CS_VERIFIED);
+ if (prefs.cloud_verification_status == CS_VERIFIED) {
+ ui->cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage (credentials verified)"));
+ } else {
+ ui->cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage"));
+ }
+ //TODO: Do not call mainWindow here. Verify things on SettingsChanged.
+ //MainWindow::instance()->enableDisableCloudActions();
+}
+
+void PreferencesNetwork::proxyType_changed(int idx)
+{
+ if (idx == -1) {
+ return;
+ }
+
+ int proxyType = ui->proxyType->itemData(idx).toInt();
+ bool hpEnabled = (proxyType == QNetworkProxy::Socks5Proxy || proxyType == QNetworkProxy::HttpProxy);
+ ui->proxyHost->setEnabled(hpEnabled);
+ ui->proxyPort->setEnabled(hpEnabled);
+ ui->proxyAuthRequired->setEnabled(hpEnabled);
+ ui->proxyUsername->setEnabled(hpEnabled & ui->proxyAuthRequired->isChecked());
+ ui->proxyPassword->setEnabled(hpEnabled & ui->proxyAuthRequired->isChecked());
+ ui->proxyAuthRequired->setChecked(ui->proxyAuthRequired->isChecked());
+}
+
+void PreferencesNetwork::passwordUpdateSuccessfull()
+{
+ ui->cloud_storage_password->setText(prefs.cloud_storage_password);
+} \ No newline at end of file
diff --git a/desktop-widgets/preferences/preferences_network.h b/desktop-widgets/preferences/preferences_network.h
new file mode 100644
index 000000000..3e17d51b0
--- /dev/null
+++ b/desktop-widgets/preferences/preferences_network.h
@@ -0,0 +1,28 @@
+#ifndef PREFERENCES_NETWORK_H
+#define PREFERENCES_NETWORK_H
+
+#include "abstractpreferenceswidget.h"
+
+namespace Ui {
+ class PreferencesNetwork;
+}
+
+class PreferencesNetwork : public AbstractPreferencesWidget {
+ Q_OBJECT
+
+public:
+ PreferencesNetwork();
+ virtual ~PreferencesNetwork();
+ virtual void refreshSettings();
+ virtual void syncSettings();
+
+public slots:
+ void proxyType_changed(int i);
+
+private:
+ Ui::PreferencesNetwork *ui;
+ void cloudPinNeeded();
+ void passwordUpdateSuccessfull();
+};
+
+#endif \ No newline at end of file
diff --git a/desktop-widgets/preferences/preferences_network.ui b/desktop-widgets/preferences/preferences_network.ui
new file mode 100644
index 000000000..8bb9bf9a0
--- /dev/null
+++ b/desktop-widgets/preferences/preferences_network.ui
@@ -0,0 +1,293 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>PreferencesNetwork</class>
+ <widget class="QWidget" name="PreferencesNetwork">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>713</width>
+ <height>558</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QGroupBox" name="groupBox_10">
+ <property name="title">
+ <string>Proxy</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="1" column="2">
+ <widget class="QLabel" name="label_23">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Port</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_22">
+ <property name="text">
+ <string>Host</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_21">
+ <property name="text">
+ <string>Proxy type</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_24">
+ <property name="text">
+ <string>Username</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <widget class="QSpinBox" name="proxyPort">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximum">
+ <number>65535</number>
+ </property>
+ <property name="value">
+ <number>80</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="proxyHost">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>2</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maxLength">
+ <number>64</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" colspan="3">
+ <widget class="QComboBox" name="proxyType"/>
+ </item>
+ <item row="2" column="1" colspan="3">
+ <widget class="QCheckBox" name="proxyAuthRequired">
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="text">
+ <string>Requires authentication</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QLineEdit" name="proxyUsername">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maxLength">
+ <number>32</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="2">
+ <widget class="QLabel" name="label_25">
+ <property name="text">
+ <string>Password</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="3">
+ <widget class="QLineEdit" name="proxyPassword">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maxLength">
+ <number>32</number>
+ </property>
+ <property name="echoMode">
+ <enum>QLineEdit::Password</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="cloudStorageGroupBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>129</height>
+ </size>
+ </property>
+ <property name="title">
+ <string>Subsurface cloud storage</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_16b">
+ <property name="toolTip">
+ <string extracomment="Email address used for the Subsurface cloud storage infrastructure"/>
+ </property>
+ <property name="text">
+ <string>Email address</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="label_16c">
+ <property name="text">
+ <string>Password</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QLabel" name="cloud_storage_pin_label">
+ <property name="text">
+ <string>Verification PIN</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <widget class="QLabel" name="cloud_storage_new_passwd_label">
+ <property name="text">
+ <string>New password</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLineEdit" name="cloud_storage_email">
+ <property name="toolTip">
+ <string extracomment="Email address used for the Subsurface cloud storage infrastructure"/>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="cloud_storage_password">
+ <property name="echoMode">
+ <enum>QLineEdit::Password</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QLineEdit" name="cloud_storage_pin">
+ <property name="toolTip">
+ <string extracomment="One time verification PIN for Subsurface cloud storage infrastructure"/>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <widget class="QLineEdit" name="cloud_storage_new_passwd">
+ <property name="echoMode">
+ <enum>QLineEdit::Password</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QCheckBox" name="cloud_background_sync">
+ <property name="text">
+ <string>Sync to cloud in the background?</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QCheckBox" name="save_password_local">
+ <property name="text">
+ <string>Save Password locally?</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_8">
+ <property name="title">
+ <string>Subsurface web service</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_7">
+ <property name="spacing">
+ <number>5</number>
+ </property>
+ <property name="leftMargin">
+ <number>5</number>
+ </property>
+ <property name="topMargin">
+ <number>5</number>
+ </property>
+ <property name="rightMargin">
+ <number>5</number>
+ </property>
+ <property name="bottomMargin">
+ <number>5</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label_16">
+ <property name="text">
+ <string>Default user ID</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="default_uid"/>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="save_uid_local">
+ <property name="text">
+ <string>Save user ID locally?</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>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/desktop-widgets/preferences/preferences_units.cpp b/desktop-widgets/preferences/preferences_units.cpp
new file mode 100644
index 000000000..cc77e51bb
--- /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()
+{
+ 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);
+}
+
+void PreferencesUnits::syncSettings()
+{
+ 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();
+}
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
new file mode 100644
index 000000000..d8798879a
--- /dev/null
+++ b/desktop-widgets/preferences/preferencesdialog.cpp
@@ -0,0 +1,140 @@
+#include "preferencesdialog.h"
+
+#include "abstractpreferenceswidget.h"
+#include "preferences_language.h"
+#include "preferences_georeference.h"
+#include "preferences_defaults.h"
+#include "preferences_units.h"
+#include "preferences_graph.h"
+#include "preferences_network.h"
+
+#include "subsurface-core/qthelper.h"
+
+#include <QVBoxLayout>
+#include <QHBoxLayout>
+#include <QListWidget>
+#include <QStackedWidget>
+#include <QDialogButtonBox>
+#include <QAbstractButton>
+#include <QDebug>
+
+PreferencesDialog* PreferencesDialog::instance()
+{
+ static PreferencesDialog *self = new PreferencesDialog();
+ return self;
+}
+
+void PreferencesDialog::emitSettingsChanged()
+{
+ emit settingsChanged();
+}
+
+PreferencesDialog::PreferencesDialog()
+{
+ loadPreferences(); //TODO: Move this code out of the qthelper.cpp
+
+ pagesList = new QListWidget();
+ pagesStack = new QStackedWidget();
+ buttonBox = new QDialogButtonBox(
+ QDialogButtonBox::Save |
+ QDialogButtonBox::Apply |
+ QDialogButtonBox::Cancel);
+
+ pagesList->setMinimumWidth(120);
+ pagesList->setMaximumWidth(120);
+
+ QHBoxLayout *h = new QHBoxLayout();
+ h->addWidget(pagesList);
+ h->addWidget(pagesStack);
+ QVBoxLayout *v = new QVBoxLayout();
+ v->addLayout(h);
+ v->addWidget(buttonBox);
+
+ setLayout(v);
+
+ addPreferencePage(new PreferencesLanguage());
+ addPreferencePage(new PreferencesGeoreference());
+ addPreferencePage(new PreferencesDefaults());
+ addPreferencePage(new PreferencesUnits());
+ addPreferencePage(new PreferencesGraph());
+ addPreferencePage(new PreferencesNetwork());
+ refreshPages();
+
+ connect(pagesList, &QListWidget::currentRowChanged,
+ pagesStack, &QStackedWidget::setCurrentIndex);
+ connect(buttonBox, &QDialogButtonBox::clicked,
+ this, &PreferencesDialog::buttonClicked);
+}
+
+PreferencesDialog::~PreferencesDialog()
+{
+}
+
+void PreferencesDialog::buttonClicked(QAbstractButton* btn)
+{
+ QDialogButtonBox::ButtonRole role = buttonBox->buttonRole(btn);
+ switch(role) {
+ case QDialogButtonBox::ApplyRole : applyRequested(false); return;
+ case QDialogButtonBox::AcceptRole : applyRequested(true); return;
+ case QDialogButtonBox::RejectRole : cancelRequested(); return;
+ case QDialogButtonBox::ResetRole : defaultsRequested(); return;
+ }
+}
+
+bool abstractpreferenceswidget_lessthan(AbstractPreferencesWidget *p1, AbstractPreferencesWidget *p2)
+{
+ return p1->positionHeight() <= p2->positionHeight();
+}
+
+void PreferencesDialog::addPreferencePage(AbstractPreferencesWidget *page)
+{
+ pages.push_back(page);
+ qSort(pages.begin(), pages.end(), abstractpreferenceswidget_lessthan);
+}
+
+void PreferencesDialog::refreshPages()
+{
+ // Remove things
+ pagesList->clear();
+ while(pagesStack->count()) {
+ QWidget *curr = pagesStack->widget(0);
+ pagesStack->removeWidget(curr);
+ curr->setParent(0);
+ }
+
+ // Readd things.
+ Q_FOREACH(AbstractPreferencesWidget *page, pages) {
+ QListWidgetItem *item = new QListWidgetItem(page->icon(), page->name());
+ pagesList->addItem(item);
+ pagesStack->addWidget(page);
+ page->refreshSettings();
+ }
+}
+
+void PreferencesDialog::applyRequested(bool closeIt)
+{
+ Q_FOREACH(AbstractPreferencesWidget *page, pages) {
+ page->syncSettings();
+ }
+ emit settingsChanged();
+ if (closeIt)
+ accept();
+}
+
+void PreferencesDialog::cancelRequested()
+{
+ Q_FOREACH(AbstractPreferencesWidget *page, pages) {
+ page->refreshSettings();
+ }
+ reject();
+}
+
+void PreferencesDialog::defaultsRequested()
+{
+ prefs = default_prefs;
+ Q_FOREACH(AbstractPreferencesWidget *page, pages) {
+ page->refreshSettings();
+ }
+ emit settingsChanged();
+ accept();
+}
diff --git a/desktop-widgets/preferences/preferencesdialog.h b/desktop-widgets/preferences/preferencesdialog.h
new file mode 100644
index 000000000..5f7f5f979
--- /dev/null
+++ b/desktop-widgets/preferences/preferencesdialog.h
@@ -0,0 +1,35 @@
+#ifndef PREFERENCES_WIDGET_H
+#define PREFERENCES_WIDGET_H
+
+#include <QDialog>
+#include "pref.h"
+
+class AbstractPreferencesWidget;
+class QListWidget;
+class QStackedWidget;
+class QDialogButtonBox;
+class QAbstractButton;
+
+class PreferencesDialog : public QDialog {
+ Q_OBJECT
+public:
+ static PreferencesDialog* instance();
+ virtual ~PreferencesDialog();
+ void addPreferencePage(AbstractPreferencesWidget *page);
+ void refreshPages();
+ void emitSettingsChanged();
+signals:
+ void settingsChanged();
+private:
+ PreferencesDialog();
+ void cancelRequested();
+ void applyRequested(bool closeIt);
+ void defaultsRequested();
+ void buttonClicked(QAbstractButton *btn);
+ QList<AbstractPreferencesWidget*> pages;
+ QListWidget *pagesList;
+ QStackedWidget *pagesStack;
+ QDialogButtonBox *buttonBox;
+};
+
+#endif
diff --git a/desktop-widgets/preferences/prefs_georeference.ui b/desktop-widgets/preferences/prefs_georeference.ui
new file mode 100644
index 000000000..7d4f0907e
--- /dev/null
+++ b/desktop-widgets/preferences/prefs_georeference.ui
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>PreferencesGeoreference</class>
+ <widget class="QWidget" name="PreferencesGeoreference">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QGroupBox" name="groupBox_Geocoding">
+ <property name="title">
+ <string>Dive site geo lookup</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_8">
+ <item>
+ <widget class="QCheckBox" name="enable_geocoding">
+ <property name="text">
+ <string>Enable geocoding for dive site management</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="parse_without_gps">
+ <property name="text">
+ <string>Parse site without GPS data</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="tag_existing_dives">
+ <property name="text">
+ <string>Same format for existing dives</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_12">
+ <property name="title">
+ <string>Dive Site Layout</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_10">
+ <item>
+ <widget class="QComboBox" name="first_item">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_29">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>/</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="second_item">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_30">
+ <property name="text">
+ <string>/</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="third_item">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_6">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>109</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/desktop-widgets/preferences/prefs_language.ui b/desktop-widgets/preferences/prefs_language.ui
new file mode 100644
index 000000000..af3a0ad87
--- /dev/null
+++ b/desktop-widgets/preferences/prefs_language.ui
@@ -0,0 +1,260 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>PreferencesLanguage</class>
+ <widget class="QWidget" name="PreferencesLanguage">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>621</width>
+ <height>523</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QGroupBox" name="language_group">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>UI language</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QCheckBox" name="languageSystemDefault">
+ <property name="text">
+ <string>Use system default</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="languageDropdown"/>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>203</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_14">
+ <property name="text">
+ <string>Filter</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="languageFilter"/>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="dateformat_group">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Date format</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="dateFormatEntry">
+ <property name="toolTip">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Preferred date format. Commonly used fields are&lt;/p&gt;&lt;p&gt;d (day of month)&lt;/p&gt;&lt;p&gt;ddd (abbr. day name)&lt;/p&gt;&lt;p&gt;M (month number)&lt;/p&gt;&lt;p&gt;MMM (abbr. month name)&lt;/p&gt;&lt;p&gt;yy/yyyy (2/4 digit year)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QCheckBox" name="dateFormatSystemDefault">
+ <property name="text">
+ <string>Use UI language default</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="shortDateFormatEntry"/>
+ </item>
+ <item row="1" column="3">
+ <widget class="QLabel" name="label">
+ <property name="toolTip">
+ <string>This is used in places where there is less space to show the full date</string>
+ </property>
+ <property name="text">
+ <string>Short format</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <spacer name="horizontalSpacer2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>203</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="timeformat_group">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Time format</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout3">
+ <item>
+ <widget class="QCheckBox" name="timeFormatSystemDefault">
+ <property name="text">
+ <string>Use UI language default</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="timeFormatEntry">
+ <property name="toolTip">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Preferred time format&lt;/p&gt;&lt;p&gt;Commonly used format specifiers are&lt;/p&gt;&lt;p&gt;h (hours in 12h format)&lt;/p&gt;&lt;p&gt;H (hours in 24h format)&lt;/p&gt;&lt;p&gt;mm (2 digit minutes)&lt;/p&gt;&lt;p&gt;ss (2 digit seconds)&lt;/p&gt;&lt;p&gt;t/tt (a/p or am/pm)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>203</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>languageSystemDefault</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>languageDropdown</receiver>
+ <slot>setDisabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>73</x>
+ <y>273</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>179</x>
+ <y>273</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>languageSystemDefault</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>languageFilter</receiver>
+ <slot>setDisabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>73</x>
+ <y>273</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>539</x>
+ <y>273</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>dateFormatSystemDefault</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>dateFormatEntry</receiver>
+ <slot>setDisabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>79</x>
+ <y>132</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>264</x>
+ <y>132</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>timeFormatSystemDefault</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>timeFormatEntry</receiver>
+ <slot>setDisabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>79</x>
+ <y>210</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>264</x>
+ <y>210</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>dateFormatSystemDefault</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>shortDateFormatEntry</receiver>
+ <slot>setDisabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>99</x>
+ <y>132</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>293</x>
+ <y>169</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>