From 3e853e37a5b0b9509fb92b1ddb3031f117578fb9 Mon Sep 17 00:00:00 2001 From: willemferguson Date: Sat, 7 Dec 2019 20:27:25 +0200 Subject: Preferences UI: create new equipment tab Remove the "Show unused cylinders" checkbox (Profile tab) and the "Set default cylinder" qTextEdit box (General tab) and put them in a separate and new Equipment tab. This sounds like a simple task but, as can be seen from the files changed, was actually a complex matter. Adapt the existing test programs (General and TechDetails) for creating a test program that tests parts of the Equipment tab. Signed-off-by: willemferguson Signed-off-by: Dirk Hohndel --- desktop-widgets/preferences/CMakeLists.txt | 3 + .../preferences/preferences_defaults.cpp | 7 -- .../preferences/preferences_defaults.ui | 32 -------- .../preferences/preferences_equipment.cpp | 41 ++++++++++ .../preferences/preferences_equipment.h | 25 ++++++ .../preferences/preferences_equipment.ui | 93 ++++++++++++++++++++++ desktop-widgets/preferences/preferences_graph.cpp | 2 - desktop-widgets/preferences/preferences_graph.ui | 9 +-- desktop-widgets/preferences/preferencesdialog.cpp | 2 + 9 files changed, 165 insertions(+), 49 deletions(-) create mode 100644 desktop-widgets/preferences/preferences_equipment.cpp create mode 100644 desktop-widgets/preferences/preferences_equipment.h create mode 100644 desktop-widgets/preferences/preferences_equipment.ui (limited to 'desktop-widgets/preferences') diff --git a/desktop-widgets/preferences/CMakeLists.txt b/desktop-widgets/preferences/CMakeLists.txt index 6f7f657cb..af6071934 100644 --- a/desktop-widgets/preferences/CMakeLists.txt +++ b/desktop-widgets/preferences/CMakeLists.txt @@ -12,6 +12,7 @@ set(SUBSURFACE_PREFERENCES_UI preferences_units.ui preferences_georeference.ui preferences_language.ui + preferences_equipment.ui ) qt5_wrap_ui(SUBSURFACE_PREFERENCES_UI_HDRS ${SUBSURFACE_PREFERENCES_UI}) @@ -23,6 +24,8 @@ set(SUBSURFACE_PREFERENCES_LIB_SRCS abstractpreferenceswidget.h preferences_defaults.cpp preferences_defaults.h + preferences_equipment.cpp + preferences_equipment.h preferences_georeference.cpp preferences_georeference.h preferences_graph.cpp diff --git a/desktop-widgets/preferences/preferences_defaults.cpp b/desktop-widgets/preferences/preferences_defaults.cpp index f439b0702..e0df807b0 100644 --- a/desktop-widgets/preferences/preferences_defaults.cpp +++ b/desktop-widgets/preferences/preferences_defaults.cpp @@ -109,12 +109,6 @@ void PreferencesDefaults::refreshSettings() ui->cloudDefaultFile->setChecked(qPrefGeneral::default_file_behavior() == CLOUD_DEFAULT_FILE); ui->localDefaultFile->setChecked(qPrefGeneral::default_file_behavior() == LOCAL_DEFAULT_FILE); - ui->default_cylinder->clear(); - for (int i = 0; i < MAX_TANK_INFO && tank_info[i].name != NULL; i++) { - ui->default_cylinder->addItem(tank_info[i].name); - if (qPrefGeneral::default_cylinder() == tank_info[i].name) - ui->default_cylinder->setCurrentIndex(i); - } ui->displayinvalid->setChecked(qPrefDisplay::display_invalid_dives()); ui->velocitySlider->setValue(qPrefDisplay::animation_speed()); ui->btnUseDefaultFile->setChecked(qPrefGeneral::use_default_file()); @@ -145,7 +139,6 @@ void PreferencesDefaults::syncSettings() { auto general = qPrefGeneral::instance(); general->set_default_filename(ui->defaultfilename->text()); - general->set_default_cylinder(ui->default_cylinder->currentText()); general->set_use_default_file(ui->btnUseDefaultFile->isChecked()); if (ui->noDefaultFile->isChecked()) general->set_default_file_behavior(NO_DEFAULT_FILE); diff --git a/desktop-widgets/preferences/preferences_defaults.ui b/desktop-widgets/preferences/preferences_defaults.ui index b1538f33d..60b478206 100644 --- a/desktop-widgets/preferences/preferences_defaults.ui +++ b/desktop-widgets/preferences/preferences_defaults.ui @@ -141,38 +141,6 @@ - - - - Default cylinder - - - - 5 - - - 5 - - - 5 - - - - - Use default cylinder - - - - - - - - - - - - - diff --git a/desktop-widgets/preferences/preferences_equipment.cpp b/desktop-widgets/preferences/preferences_equipment.cpp new file mode 100644 index 000000000..a446a279b --- /dev/null +++ b/desktop-widgets/preferences/preferences_equipment.cpp @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "preferences_equipment.h" +#include "ui_preferences_equipment.h" +#include "core/settings/qPrefEquipment.h" +#include "core/qthelper.h" +#include "core/dive.h" + +#include +#include +#include + +#include "qt-models/models.h" + +PreferencesEquipment::PreferencesEquipment() : AbstractPreferencesWidget(tr("Equipment"), QIcon(":preferences-equipment-icon"), 4) +{ + ui = new Ui::PreferencesEquipment(); + ui->setupUi(this); +} + +PreferencesEquipment::~PreferencesEquipment() +{ + delete ui; +} + +void PreferencesEquipment::refreshSettings() +{ + ui->display_unused_tanks->setChecked(prefs.display_unused_tanks); + ui->default_cylinder->clear(); + for (int i = 0; i < MAX_TANK_INFO && tank_info[i].name != NULL; i++) { + ui->default_cylinder->addItem(tank_info[i].name); + if (qPrefEquipment::default_cylinder() == tank_info[i].name) + ui->default_cylinder->setCurrentIndex(i); + } +} + +void PreferencesEquipment::syncSettings() +{ + auto equipment = qPrefEquipment::instance(); + qPrefEquipment::set_display_unused_tanks(ui->display_unused_tanks->isChecked()); + equipment->set_default_cylinder(ui->default_cylinder->currentText()); +} diff --git a/desktop-widgets/preferences/preferences_equipment.h b/desktop-widgets/preferences/preferences_equipment.h new file mode 100644 index 000000000..09402aa00 --- /dev/null +++ b/desktop-widgets/preferences/preferences_equipment.h @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0 +#ifndef PREFERENCES_EQUIPMENT_H +#define PREFERENCES_EQUIPMENT_H + +#include +#include "abstractpreferenceswidget.h" + +namespace Ui { + class PreferencesEquipment; +} + +class PreferencesEquipment : public AbstractPreferencesWidget { + Q_OBJECT +public: + PreferencesEquipment(); + ~PreferencesEquipment(); + void refreshSettings() override; + void syncSettings() override; +private: + Ui::PreferencesEquipment *ui; +public slots: + +}; + +#endif diff --git a/desktop-widgets/preferences/preferences_equipment.ui b/desktop-widgets/preferences/preferences_equipment.ui new file mode 100644 index 000000000..4526f9618 --- /dev/null +++ b/desktop-widgets/preferences/preferences_equipment.ui @@ -0,0 +1,93 @@ + + + PreferencesEquipment + + + + 0 + 0 + 621 + 523 + + + + Form + + + + + + + true + + + CYLINDERS + + + + + + + + Default cylinder in the Cylinders table of the Equipment tab + + + + 5 + + + 5 + + + 5 + + + + + + Select a default cylinder + + + + + + + + + + + + + + + + + + + + Show unused cylinders in the Cylinders table of the Equipment tab + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + diff --git a/desktop-widgets/preferences/preferences_graph.cpp b/desktop-widgets/preferences/preferences_graph.cpp index 74c248dc4..54a63fd71 100644 --- a/desktop-widgets/preferences/preferences_graph.cpp +++ b/desktop-widgets/preferences/preferences_graph.cpp @@ -49,7 +49,6 @@ void PreferencesGraph::refreshSettings() ui->psro2rate->setValue(prefs.o2consumption / 1000.0); ui->pscrfactor->setValue(lrint(1000.0 / prefs.pscr_ratio)); - ui->display_unused_tanks->setChecked(prefs.display_unused_tanks); ui->show_average_depth->setChecked(prefs.show_average_depth); ui->auto_recalculate_thumbnails->setChecked(prefs.auto_recalculate_thumbnails); ui->show_icd->setChecked(prefs.show_icd); @@ -78,7 +77,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_display_unused_tanks(ui->display_unused_tanks->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 b70a5ff29..ab7e12f87 100644 --- a/desktop-widgets/preferences/preferences_graph.ui +++ b/desktop-widgets/preferences/preferences_graph.ui @@ -355,20 +355,13 @@ - - - Show unused cylinders in Equipment tab - - - - Show mean depth in Profile - + Recalculate thumbnails if older than media file diff --git a/desktop-widgets/preferences/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp index 9e1e6a7bf..508321ac5 100644 --- a/desktop-widgets/preferences/preferencesdialog.cpp +++ b/desktop-widgets/preferences/preferencesdialog.cpp @@ -9,6 +9,7 @@ #include "preferences_graph.h" #include "preferences_network.h" #include "preferences_cloud.h" +#include "preferences_equipment.h" #include "core/qthelper.h" @@ -67,6 +68,7 @@ PreferencesDialog::PreferencesDialog() addPreferencePage(new PreferencesGraph()); addPreferencePage(new PreferencesNetwork()); addPreferencePage(new PreferencesCloud()); + addPreferencePage(new PreferencesEquipment()); refreshPages(); connect(pagesList, &QListWidget::currentRowChanged, -- cgit v1.2.3-70-g09d2