diff options
author | willemferguson <willemferguson@zoology.up.ac.za> | 2019-12-07 20:27:25 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-12-25 02:57:42 +0900 |
commit | 3e853e37a5b0b9509fb92b1ddb3031f117578fb9 (patch) | |
tree | 35281a57f8ca70611c78a85ef3dbfa459d9efacb /desktop-widgets/preferences | |
parent | c121afc96c0135ada550de4504153434fa83feb4 (diff) | |
download | subsurface-3e853e37a5b0b9509fb92b1ddb3031f117578fb9.tar.gz |
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>
Diffstat (limited to 'desktop-widgets/preferences')
9 files changed, 165 insertions, 49 deletions
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 @@ -142,38 +142,6 @@ </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> 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 <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()); +} 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 <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 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 @@ +<?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> 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 @@ </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> 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, |