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 <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
willemferguson 2019-12-07 20:27:25 +02:00 committed by Dirk Hohndel
parent c121afc96c
commit 3e853e37a5
25 changed files with 369 additions and 105 deletions

View file

@ -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

View file

@ -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);

View file

@ -141,38 +141,6 @@
</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">

View file

@ -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 <QApplication>
#include <QMessageBox>
#include <QSortFilterProxyModel>
#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());
}

View file

@ -0,0 +1,25 @@
// SPDX-License-Identifier: GPL-2.0
#ifndef PREFERENCES_EQUIPMENT_H
#define PREFERENCES_EQUIPMENT_H
#include <QMap>
#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

View file

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PreferencesEquipment</class>
<widget class="QWidget" name="PreferencesEquipment">
<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="QLabel" name="label_cylinders">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>CYLINDERS</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_6">
<property name="title">
<string>Default cylinder in the Cylinders table of the Equipment tab</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>Select a 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="QCheckBox" name="display_unused_tanks">
<property name="text">
<string>Show unused cylinders in the Cylinders table of the Equipment tab</string>
</property>
</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>

View file

@ -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);

View file

@ -355,20 +355,13 @@
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" 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="1" column="0" colspan="2">
<widget class="QCheckBox" name="show_average_depth">
<property name="text">
<string>Show mean depth in Profile</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="auto_recalculate_thumbnails">
<property name="text">
<string>Recalculate thumbnails if older than media file</string>

View file

@ -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,