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 <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
willemferguson 2019-12-09 20:58:20 +02:00 committed by Dirk Hohndel
parent b24caa4e2d
commit b6c3cdb20c
35 changed files with 467 additions and 357 deletions

View file

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

View file

@ -10,7 +10,7 @@
#include <QProcess>
#include <QMessageBox>
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);

View file

@ -11,7 +11,7 @@
#include <QProcess>
#include <QMessageBox>
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());
}

View file

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

View file

@ -46,101 +46,7 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Default file</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<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>&amp;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_2">
<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_7">
<property name="title">
@ -177,6 +83,7 @@
</layout>
</widget>
</item>
<item>
<widget class="QPushButton" name="resetSettings">
<property name="text">
@ -184,22 +91,7 @@
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_extra_star_widgets">
<property name="title">
<string>Environmental parameters in Information tab</string>
</property>
<layout class="QHBoxLayout" name="extraWidgetLayout">
<item>
<widget class="QCheckBox" name="extraEnvironmentalDefault">
<property name="text">
<string>Show extended range of environmental paramaters</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">

View file

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

View file

@ -7,7 +7,7 @@
#include <ctime>
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);

View file

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

View file

@ -348,22 +348,6 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_6">
<property name="title">
<string>Misc</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="show_average_depth">
<property name="text">
<string>Show mean depth in Profile</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
@ -398,8 +382,6 @@
<tabstop>buehlmann</tabstop>
<tabstop>gflow</tabstop>
<tabstop>gfhigh</tabstop>
<tabstop>display_unused_tanks</tabstop>
<tabstop>show_average_depth</tabstop>
</tabstops>
<resources/>
<connections/>

View file

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

View file

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

View file

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

View file

@ -0,0 +1,199 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PreferencesLog</class>
<widget class="QWidget" name="PreferencesLog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>561</width>
<height>558</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>DIVE LOG</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string></string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<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>&amp;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_2">
<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>
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="displayinvalid">
<property name="text">
<string>In the Dive List, show dives that you have marked as invalid, e.g. pool dives</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="extraEnvironmentalDefault">
<property name="text">
<string>In the Information tab, show tools for recording wave height, surge and chill during a dive</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="show_average_depth">
<property name="text">
<string>In the Dive Profile, show mean depth</string>
</property>
</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>
<connection>
<sender>btnUseDefaultFile</sender>
<signal>toggled(bool)</signal>
<receiver>chooseFile</receiver>
<slot>setHidden(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>462</x>
<y>136</y>
</hint>
<hint type="destinationlabel">
<x>528</x>
<y>145</y>
</hint>
</hints>
</connection>
<connection>
<sender>velocitySlider</sender>
<signal>valueChanged(int)</signal>
<receiver>velocitySpinBox</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel">
<x>437</x>
<y>299</y>
</hint>
<hint type="destinationlabel">
<x>531</x>
<y>301</y>
</hint>
</hints>
</connection>
<connection>
<sender>velocitySpinBox</sender>
<signal>valueChanged(int)</signal>
<receiver>velocitySlider</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel">
<x>547</x>
<y>274</y>
</hint>
<hint type="destinationlabel">
<x>482</x>
<y>276</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View file

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

View file

@ -6,7 +6,7 @@
#include "core/settings/qPrefProxy.h"
#include <QNetworkProxy>
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);

View file

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

View file

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