From b6c3cdb20cbcb1654c83d555d278476f55d3d103 Mon Sep 17 00:00:00 2001 From: willemferguson Date: Mon, 9 Dec 2019 20:58:20 +0200 Subject: Preferences UI: add dive log tab This adds a tab for dive log - related preferences. A suitable test programs is still required. Signed-off-by: willemferguson Signed-off-by: Dirk Hohndel --- desktop-widgets/preferences/CMakeLists.txt | 3 + desktop-widgets/preferences/preferences_dc.cpp | 2 +- .../preferences/preferences_defaults.cpp | 66 +------ desktop-widgets/preferences/preferences_defaults.h | 4 - .../preferences/preferences_defaults.ui | 114 +----------- .../preferences/preferences_equipment.cpp | 2 +- .../preferences/preferences_georeference.cpp | 2 +- desktop-widgets/preferences/preferences_graph.cpp | 4 +- desktop-widgets/preferences/preferences_graph.ui | 18 -- .../preferences/preferences_language.cpp | 2 +- desktop-widgets/preferences/preferences_log.cpp | 90 ++++++++++ desktop-widgets/preferences/preferences_log.h | 29 +++ desktop-widgets/preferences/preferences_log.ui | 199 +++++++++++++++++++++ desktop-widgets/preferences/preferences_media.cpp | 2 +- .../preferences/preferences_network.cpp | 2 +- desktop-widgets/preferences/preferences_units.cpp | 2 +- desktop-widgets/preferences/preferencesdialog.cpp | 2 + 17 files changed, 335 insertions(+), 208 deletions(-) create mode 100644 desktop-widgets/preferences/preferences_log.cpp create mode 100644 desktop-widgets/preferences/preferences_log.h create mode 100644 desktop-widgets/preferences/preferences_log.ui (limited to 'desktop-widgets/preferences') diff --git a/desktop-widgets/preferences/CMakeLists.txt b/desktop-widgets/preferences/CMakeLists.txt index cec31e6f3..2298db6b9 100644 --- a/desktop-widgets/preferences/CMakeLists.txt +++ b/desktop-widgets/preferences/CMakeLists.txt @@ -15,6 +15,7 @@ set(SUBSURFACE_PREFERENCES_UI preferences_media.ui preferences_equipment.ui preferences_dc.ui + preferences_log.ui ) qt5_wrap_ui(SUBSURFACE_PREFERENCES_UI_HDRS ${SUBSURFACE_PREFERENCES_UI}) @@ -38,6 +39,8 @@ set(SUBSURFACE_PREFERENCES_LIB_SRCS preferences_graph.h preferences_language.cpp preferences_language.h + preferences_log.cpp + preferences_log.h preferences_media.cpp preferences_media.h preferences_network.cpp diff --git a/desktop-widgets/preferences/preferences_dc.cpp b/desktop-widgets/preferences/preferences_dc.cpp index b88881bd8..c39754497 100644 --- a/desktop-widgets/preferences/preferences_dc.cpp +++ b/desktop-widgets/preferences/preferences_dc.cpp @@ -10,7 +10,7 @@ #include #include -PreferencesDc::PreferencesDc(): AbstractPreferencesWidget(tr("Dive download"), QIcon(":preferences-dc-icon"), 0 ), ui(new Ui::PreferencesDc()) +PreferencesDc::PreferencesDc(): AbstractPreferencesWidget(tr("Dive download"), QIcon(":preferences-dc-icon"), 3 ), ui(new Ui::PreferencesDc()) { ui->setupUi(this); const QSize BUTTON_SIZE = QSize(200, 22); diff --git a/desktop-widgets/preferences/preferences_defaults.cpp b/desktop-widgets/preferences/preferences_defaults.cpp index 2a76fe662..dbf1091e4 100644 --- a/desktop-widgets/preferences/preferences_defaults.cpp +++ b/desktop-widgets/preferences/preferences_defaults.cpp @@ -11,7 +11,7 @@ #include #include -PreferencesDefaults::PreferencesDefaults(): AbstractPreferencesWidget(tr("General"), QIcon(":preferences-other-icon"), 0 ), ui(new Ui::PreferencesDefaults()) +PreferencesDefaults::PreferencesDefaults(): AbstractPreferencesWidget(tr("Display"), QIcon(":preferences-display-icon"), 0 ), ui(new Ui::PreferencesDefaults()) { ui->setupUi(this); } @@ -21,80 +21,16 @@ 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 files") + " (*.ssrf *.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::on_resetSettings_clicked() -{ - // apparently this button was never hooked up? -} - void PreferencesDefaults::refreshSettings() { ui->font->setCurrentFont(qPrefDisplay::divelist_font()); ui->fontsize->setValue(qPrefDisplay::font_size()); - ui->defaultfilename->setText(qPrefGeneral::default_filename()); - ui->noDefaultFile->setChecked(qPrefGeneral::default_file_behavior() == NO_DEFAULT_FILE); - ui->cloudDefaultFile->setChecked(qPrefGeneral::default_file_behavior() == CLOUD_DEFAULT_FILE); - ui->localDefaultFile->setChecked(qPrefGeneral::default_file_behavior() == LOCAL_DEFAULT_FILE); - - ui->displayinvalid->setChecked(qPrefDisplay::display_invalid_dives()); ui->velocitySlider->setValue(qPrefDisplay::animation_speed()); - ui->btnUseDefaultFile->setChecked(qPrefGeneral::use_default_file()); - - if (qPrefCloudStorage::cloud_verification_status() == qPrefCloudStorage::CS_VERIFIED) { - ui->cloudDefaultFile->setEnabled(true); - } else { - if (ui->cloudDefaultFile->isChecked()) - ui->noDefaultFile->setChecked(true); - ui->cloudDefaultFile->setEnabled(false); - } - - ui->defaultfilename->setEnabled(qPrefGeneral::default_file_behavior() == LOCAL_DEFAULT_FILE); - ui->btnUseDefaultFile->setEnabled(qPrefGeneral::default_file_behavior() == LOCAL_DEFAULT_FILE); - ui->chooseFile->setEnabled(qPrefGeneral::default_file_behavior() == LOCAL_DEFAULT_FILE); - - ui->extraEnvironmentalDefault->setChecked(prefs.extraEnvironmentalDefault); } void PreferencesDefaults::syncSettings() { - auto general = qPrefGeneral::instance(); - general->set_default_filename(ui->defaultfilename->text()); - general->set_use_default_file(ui->btnUseDefaultFile->isChecked()); - if (ui->noDefaultFile->isChecked()) - general->set_default_file_behavior(NO_DEFAULT_FILE); - else if (ui->localDefaultFile->isChecked()) - general->set_default_file_behavior(LOCAL_DEFAULT_FILE); - else if (ui->cloudDefaultFile->isChecked()) - general->set_default_file_behavior(CLOUD_DEFAULT_FILE); - qPrefDisplay::set_divelist_font(ui->font->currentFont().toString()); qPrefDisplay::set_font_size(ui->fontsize->value()); - qPrefDisplay::set_display_invalid_dives(ui->displayinvalid->isChecked()); qPrefDisplay::set_animation_speed(ui->velocitySlider->value()); - qPrefGeneral::set_extraEnvironmentalDefault(ui->extraEnvironmentalDefault->isChecked()); } diff --git a/desktop-widgets/preferences/preferences_defaults.h b/desktop-widgets/preferences/preferences_defaults.h index ce0a8e2e1..cc92ade40 100644 --- a/desktop-widgets/preferences/preferences_defaults.h +++ b/desktop-widgets/preferences/preferences_defaults.h @@ -17,10 +17,6 @@ public: void refreshSettings() override; void syncSettings() override; public slots: - void on_chooseFile_clicked(); - void on_btnUseDefaultFile_toggled(bool toggled); - void on_localDefaultFile_toggled(bool toggled); - void on_resetSettings_clicked(); private: Ui::PreferencesDefaults *ui; diff --git a/desktop-widgets/preferences/preferences_defaults.ui b/desktop-widgets/preferences/preferences_defaults.ui index f33cd099f..3d9e45c98 100644 --- a/desktop-widgets/preferences/preferences_defaults.ui +++ b/desktop-widgets/preferences/preferences_defaults.ui @@ -46,101 +46,7 @@ - - - - Default file - - - - 5 - - - 5 - - - 5 - - - - - Default dive log file - - - - - - - - - &No default file - - - - - - - &Local default file - - - - - - - Clo&ud storage default file - - - - - - - - - Local dive log file - - - - - - - - - - - - Use default - - - true - - - - - - - ... - - - - - - - - - Display invalid - - - - - - - - - - - - - + @@ -177,6 +83,7 @@ + @@ -184,22 +91,7 @@ - - - - Environmental parameters in Information tab - - - - - - Show extended range of environmental paramaters - - - - - - + diff --git a/desktop-widgets/preferences/preferences_equipment.cpp b/desktop-widgets/preferences/preferences_equipment.cpp index a446a279b..bd5ac4158 100644 --- a/desktop-widgets/preferences/preferences_equipment.cpp +++ b/desktop-widgets/preferences/preferences_equipment.cpp @@ -11,7 +11,7 @@ #include "qt-models/models.h" -PreferencesEquipment::PreferencesEquipment() : AbstractPreferencesWidget(tr("Equipment"), QIcon(":preferences-equipment-icon"), 4) +PreferencesEquipment::PreferencesEquipment() : AbstractPreferencesWidget(tr("Equipment"), QIcon(":preferences-equipment-icon"), 5) { ui = new Ui::PreferencesEquipment(); ui->setupUi(this); diff --git a/desktop-widgets/preferences/preferences_georeference.cpp b/desktop-widgets/preferences/preferences_georeference.cpp index 40196e44f..25433964f 100644 --- a/desktop-widgets/preferences/preferences_georeference.cpp +++ b/desktop-widgets/preferences/preferences_georeference.cpp @@ -7,7 +7,7 @@ #include -PreferencesGeoreference::PreferencesGeoreference() : AbstractPreferencesWidget(tr("Georeference"), QIcon(":geotag-icon"), 9) +PreferencesGeoreference::PreferencesGeoreference() : AbstractPreferencesWidget(tr("Georeference"), QIcon(":geotag-icon"), 8) { ui = new Ui::PreferencesGeoreference(); ui->setupUi(this); diff --git a/desktop-widgets/preferences/preferences_graph.cpp b/desktop-widgets/preferences/preferences_graph.cpp index cdead91e0..b7fd5b4b9 100644 --- a/desktop-widgets/preferences/preferences_graph.cpp +++ b/desktop-widgets/preferences/preferences_graph.cpp @@ -9,7 +9,7 @@ #include "qt-models/models.h" #include "core/deco.h" -PreferencesGraph::PreferencesGraph() : AbstractPreferencesWidget(tr("Profile"), QIcon(":graph-icon"), 5) +PreferencesGraph::PreferencesGraph() : AbstractPreferencesWidget(tr("Tech setup"), QIcon(":graph-icon"), 7) { ui = new Ui::PreferencesGraph(); ui->setupUi(this); @@ -49,7 +49,6 @@ void PreferencesGraph::refreshSettings() ui->psro2rate->setValue(prefs.o2consumption / 1000.0); ui->pscrfactor->setValue(lrint(1000.0 / prefs.pscr_ratio)); - ui->show_average_depth->setChecked(prefs.show_average_depth); ui->show_icd->setChecked(prefs.show_icd); } @@ -75,7 +74,6 @@ void PreferencesGraph::syncSettings() qPrefTechnicalDetails::set_show_ccr_setpoint(ui->show_ccr_setpoint->isChecked()); qPrefTechnicalDetails::set_show_ccr_sensors(ui->show_ccr_sensors->isChecked()); qPrefTechnicalDetails::set_show_scr_ocpo2(ui->show_scr_ocpo2->isChecked()); - qPrefTechnicalDetails::set_show_average_depth(ui->show_average_depth->isChecked()); qPrefTechnicalDetails::set_show_icd(ui->show_icd->isChecked()); qPrefTechnicalDetails::set_display_deco_mode(ui->vpmb->isChecked() ? VPMB : BUEHLMANN); } diff --git a/desktop-widgets/preferences/preferences_graph.ui b/desktop-widgets/preferences/preferences_graph.ui index 9fd3a11c7..d2633ff6b 100644 --- a/desktop-widgets/preferences/preferences_graph.ui +++ b/desktop-widgets/preferences/preferences_graph.ui @@ -348,22 +348,6 @@ - - - - Misc - - - - - - Show mean depth in Profile - - - - - - @@ -398,8 +382,6 @@ buehlmann gflow gfhigh - display_unused_tanks - show_average_depth diff --git a/desktop-widgets/preferences/preferences_language.cpp b/desktop-widgets/preferences/preferences_language.cpp index 76763be14..9de6efb8f 100644 --- a/desktop-widgets/preferences/preferences_language.cpp +++ b/desktop-widgets/preferences/preferences_language.cpp @@ -10,7 +10,7 @@ #include "qt-models/models.h" -PreferencesLanguage::PreferencesLanguage() : AbstractPreferencesWidget(tr("Language"), QIcon(":preferences-desktop-locale-icon"), 4) +PreferencesLanguage::PreferencesLanguage() : AbstractPreferencesWidget(tr("Language"), QIcon(":preferences-desktop-locale-icon"), 1) { ui = new Ui::PreferencesLanguage(); ui->setupUi(this); diff --git a/desktop-widgets/preferences/preferences_log.cpp b/desktop-widgets/preferences/preferences_log.cpp new file mode 100644 index 000000000..9025945e3 --- /dev/null +++ b/desktop-widgets/preferences/preferences_log.cpp @@ -0,0 +1,90 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "preferences_log.h" +#include "ui_preferences_log.h" +#include "core/dive.h" +#include "core/settings/qPrefLog.h" +#include "core/settings/qPrefDisplay.h" +#include "core/settings/qPrefCloudStorage.h" +#include "core/settings/qPrefDiveComputer.h" + +#include +#include +#include + +PreferencesLog::PreferencesLog(): AbstractPreferencesWidget(tr(" Dive log"), QIcon(":preferences-log-icon"), 4 ), ui(new Ui::PreferencesLog()) +{ + ui->setupUi(this); +} + +PreferencesLog::~PreferencesLog() +{ + delete ui; +} + +void PreferencesLog::on_chooseFile_clicked() +{ + QFileInfo fi(system_default_filename()); + QString choosenFileName = QFileDialog::getOpenFileName(this, tr("Open default log file"), fi.absolutePath(), tr("Subsurface files") + " (*.ssrf *.xml)"); + + if (!choosenFileName.isEmpty()) + ui->defaultfilename->setText(choosenFileName); +} + +void PreferencesLog::on_btnUseDefaultFile_toggled(bool toggle) +{ + if (toggle) { + ui->defaultfilename->setText(system_default_filename()); + ui->defaultfilename->setEnabled(false); + } else { + ui->defaultfilename->setEnabled(true); + } +} + +void PreferencesLog::on_localDefaultFile_toggled(bool toggle) +{ + ui->defaultfilename->setEnabled(toggle); + ui->btnUseDefaultFile->setEnabled(toggle); + ui->chooseFile->setEnabled(toggle); +} + +void PreferencesLog::refreshSettings() +{ + ui->defaultfilename->setText(qPrefLog::default_filename()); + ui->noDefaultFile->setChecked(qPrefLog::default_file_behavior() == NO_DEFAULT_FILE); + ui->cloudDefaultFile->setChecked(qPrefLog::default_file_behavior() == CLOUD_DEFAULT_FILE); + ui->localDefaultFile->setChecked(qPrefLog::default_file_behavior() == LOCAL_DEFAULT_FILE); + + ui->btnUseDefaultFile->setChecked(qPrefLog::use_default_file()); + + if (qPrefCloudStorage::cloud_verification_status() == qPrefCloudStorage::CS_VERIFIED) { + ui->cloudDefaultFile->setEnabled(true); + } else { + if (ui->cloudDefaultFile->isChecked()) + ui->noDefaultFile->setChecked(true); + ui->cloudDefaultFile->setEnabled(false); + } + + ui->defaultfilename->setEnabled(qPrefLog::default_file_behavior() == LOCAL_DEFAULT_FILE); + ui->btnUseDefaultFile->setEnabled(qPrefLog::default_file_behavior() == LOCAL_DEFAULT_FILE); + ui->chooseFile->setEnabled(qPrefLog::default_file_behavior() == LOCAL_DEFAULT_FILE); + ui->show_average_depth->setChecked(prefs.show_average_depth); + ui->displayinvalid->setChecked(qPrefDisplay::display_invalid_dives()); + ui->extraEnvironmentalDefault->setChecked(prefs.extraEnvironmentalDefault); +} + +void PreferencesLog::syncSettings() +{ + auto log = qPrefLog::instance(); + log->set_default_filename(ui->defaultfilename->text()); + log->set_use_default_file(ui->btnUseDefaultFile->isChecked()); + if (ui->noDefaultFile->isChecked()) + log->set_default_file_behavior(NO_DEFAULT_FILE); + else if (ui->localDefaultFile->isChecked()) + log->set_default_file_behavior(LOCAL_DEFAULT_FILE); + else if (ui->cloudDefaultFile->isChecked()) + log->set_default_file_behavior(CLOUD_DEFAULT_FILE); + + qPrefLog::set_show_average_depth(ui->show_average_depth->isChecked()); + qPrefDisplay::set_display_invalid_dives(ui->displayinvalid->isChecked()); + qPrefLog::set_extraEnvironmentalDefault(ui->extraEnvironmentalDefault->isChecked()); +} diff --git a/desktop-widgets/preferences/preferences_log.h b/desktop-widgets/preferences/preferences_log.h new file mode 100644 index 000000000..7382aae2b --- /dev/null +++ b/desktop-widgets/preferences/preferences_log.h @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0 +#ifndef PREFERENCES_LOG_H +#define PREFERENCES_LOG_H + +#include "abstractpreferenceswidget.h" +#include "core/pref.h" + +namespace Ui { + class PreferencesLog; +} + +class PreferencesLog : public AbstractPreferencesWidget { + Q_OBJECT +public: + PreferencesLog(); + ~PreferencesLog(); + void refreshSettings() override; + void syncSettings() override; +public slots: + void on_chooseFile_clicked(); + void on_btnUseDefaultFile_toggled(bool toggled); + void on_localDefaultFile_toggled(bool toggled); + +private: + Ui::PreferencesLog *ui; +}; + + +#endif diff --git a/desktop-widgets/preferences/preferences_log.ui b/desktop-widgets/preferences/preferences_log.ui new file mode 100644 index 000000000..8dd76ad4c --- /dev/null +++ b/desktop-widgets/preferences/preferences_log.ui @@ -0,0 +1,199 @@ + + + PreferencesLog + + + + 0 + 0 + 561 + 558 + + + + Form + + + + + + + DIVE LOG + + + + + + + + + + + + 5 + + + 5 + + + 5 + + + + + Default dive log file + + + + + + + + + &No default file + + + + + + + &Local default file + + + + + + + Clo&ud storage default file + + + + + + + + + Local dive log file + + + + + + + + + + + + Use default + + + true + + + + + + + ... + + + + + + + + + + + + + In the Dive List, show dives that you have marked as invalid, e.g. pool dives + + + + + + + + In the Information tab, show tools for recording wave height, surge and chill during a dive + + + + + + + + In the Dive Profile, show mean depth + + + + + + + + Qt::Vertical + + + + 0 + 195 + + + + + + + + + + + btnUseDefaultFile + toggled(bool) + chooseFile + setHidden(bool) + + + 462 + 136 + + + 528 + 145 + + + + + velocitySlider + valueChanged(int) + velocitySpinBox + setValue(int) + + + 437 + 299 + + + 531 + 301 + + + + + velocitySpinBox + valueChanged(int) + velocitySlider + setValue(int) + + + 547 + 274 + + + 482 + 276 + + + + + diff --git a/desktop-widgets/preferences/preferences_media.cpp b/desktop-widgets/preferences/preferences_media.cpp index 47a6285dd..14cdfe49c 100644 --- a/desktop-widgets/preferences/preferences_media.cpp +++ b/desktop-widgets/preferences/preferences_media.cpp @@ -12,7 +12,7 @@ #include "qt-models/models.h" -PreferencesMedia::PreferencesMedia() : AbstractPreferencesWidget(tr("Media"), QIcon(":preferences-media-icon"), 8) +PreferencesMedia::PreferencesMedia() : AbstractPreferencesWidget(tr("Media"), QIcon(":preferences-media-icon"), 6) { ui = new Ui::PreferencesMedia(); ui->setupUi(this); diff --git a/desktop-widgets/preferences/preferences_network.cpp b/desktop-widgets/preferences/preferences_network.cpp index 8a48b5a25..2b2f13ed1 100644 --- a/desktop-widgets/preferences/preferences_network.cpp +++ b/desktop-widgets/preferences/preferences_network.cpp @@ -6,7 +6,7 @@ #include "core/settings/qPrefProxy.h" #include -PreferencesNetwork::PreferencesNetwork() : AbstractPreferencesWidget(tr("Network"),QIcon(":preferences-system-network-icon"), 9), ui(new Ui::PreferencesNetwork()) +PreferencesNetwork::PreferencesNetwork() : AbstractPreferencesWidget(tr("Network"),QIcon(":preferences-system-network-icon"), 10), ui(new Ui::PreferencesNetwork()) { ui->setupUi(this); diff --git a/desktop-widgets/preferences/preferences_units.cpp b/desktop-widgets/preferences/preferences_units.cpp index eaef36b39..db23efd37 100644 --- a/desktop-widgets/preferences/preferences_units.cpp +++ b/desktop-widgets/preferences/preferences_units.cpp @@ -4,7 +4,7 @@ #include "core/qthelper.h" #include "core/settings/qPrefUnit.h" -PreferencesUnits::PreferencesUnits(): AbstractPreferencesWidget(tr("Units"),QIcon(":units-icon"),1), ui(new Ui::PreferencesUnits()) +PreferencesUnits::PreferencesUnits(): AbstractPreferencesWidget(tr("Units"), QIcon(":units-icon"), 2), ui(new Ui::PreferencesUnits()) { ui->setupUi(this); } diff --git a/desktop-widgets/preferences/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp index f58829cc6..7602a3817 100644 --- a/desktop-widgets/preferences/preferencesdialog.cpp +++ b/desktop-widgets/preferences/preferencesdialog.cpp @@ -12,6 +12,7 @@ #include "preferences_equipment.h" #include "preferences_media.h" #include "preferences_dc.h" +#include "preferences_log.h" #include "core/qthelper.h" @@ -73,6 +74,7 @@ PreferencesDialog::PreferencesDialog() addPreferencePage(new PreferencesEquipment()); addPreferencePage(new PreferencesMedia()); addPreferencePage(new PreferencesDc()); + addPreferencePage(new PreferencesLog()); refreshPages(); -- cgit v1.2.3-70-g09d2