From eac87f64817568cf38c76169fc896450f1131b37 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 4 Jan 2020 16:12:59 -0800 Subject: desktop UI: correctly show the salinity data overwritten warning We need to show this whenever the value in the dive (which could have been entered by the user some other time) doesn't correspond to the value in the DC. This, btw, will point out to the user if different DCs have different values. Signed-off-by: Dirk Hohndel --- desktop-widgets/tab-widgets/TabDiveInformation.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.cpp b/desktop-widgets/tab-widgets/TabDiveInformation.cpp index ccc39decd..d0b66fd4d 100644 --- a/desktop-widgets/tab-widgets/TabDiveInformation.cpp +++ b/desktop-widgets/tab-widgets/TabDiveInformation.cpp @@ -66,6 +66,7 @@ TabDiveInformation::TabDiveInformation(QWidget *parent) : TabBase(parent), ui(ne ui->salinityOverWrittenIcon->setPixmap(warning); ui->salinityOverWrittenIcon->setToolTip("Water type differs from that of dc"); ui->salinityOverWrittenIcon->setToolTipDuration(2500); + ui->salinityOverWrittenIcon->setVisible(false); } TabDiveInformation::~TabDiveInformation() @@ -194,12 +195,13 @@ int TabDiveInformation::updateSalinityComboIndex(int salinity) // If dive->user_salinity != dive->salinity (i.e. dc value) then show the salinity-overwrite indicator void TabDiveInformation::checkDcSalinityOverWritten() { + if (!current_dive) + return; int dc_value = current_dive->dc.salinity; int user_value = current_dive->user_salinity; bool show_indicator = false; - if (current_dive && dc_value && user_value && (user_value != dc_value)) - if ((dc_value < 10250) || (user_value < 10250)) // Provide for libdivecomputer that defines seawater density - show_indicator = true; // as 1.025 in contrast to Subsurface's value of 1.03 + if (user_value != dc_value) + show_indicator = true; ui->salinityOverWrittenIcon->setVisible(show_indicator); } @@ -246,13 +248,14 @@ void TabDiveInformation::updateData() else ui->waterTypeText->setText(waterTypes[SALTWATER]); } - checkDcSalinityOverWritten(); // If exclamation is needed (i.e. salinity overwrite by user), then show it ui->salinityText->setText(QString("%1g/ℓ").arg(salinity_value / 10.0)); } else { ui->waterTypeCombo->setCurrentIndex(-1); ui->waterTypeText->setText(tr("unknown")); ui->salinityText->clear(); } + checkDcSalinityOverWritten(); // If exclamation is needed (i.e. salinity overwrite by user), then show it + updateMode(current_dive); ui->visibility->setCurrentStars(current_dive->visibility); ui->wavesize->setCurrentStars(current_dive->wavesize); -- cgit v1.2.3-70-g09d2