diff options
author | willemferguson <willemferguson@zoology.up.ac.za> | 2019-11-20 20:40:23 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-01-06 07:00:34 +0900 |
commit | b12d0b1840ab46a2aa05d3079f36437bee688f95 (patch) | |
tree | 4aacbc7117bfaa9886804237d54b91b2e8ef032e /desktop-widgets/tab-widgets | |
parent | d2cf58e07e64b4e1e6a81f07c2efce38c55be78b (diff) | |
download | subsurface-b12d0b1840ab46a2aa05d3079f36437bee688f95.tar.gz |
desktop UI: small cleanups of salinity code
Added code for string translation.
Added code to improve UI on Windows.
Added some comments to make the code more understandable.
Enable salinity combobox for manually entered dives
Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets/tab-widgets')
-rw-r--r-- | desktop-widgets/tab-widgets/TabDiveInformation.cpp | 27 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/TabDiveInformation.h | 1 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/TabDiveInformation.ui | 2 |
3 files changed, 19 insertions, 11 deletions
diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.cpp b/desktop-widgets/tab-widgets/TabDiveInformation.cpp index d588cce80..8d23c2d0a 100644 --- a/desktop-widgets/tab-widgets/TabDiveInformation.cpp +++ b/desktop-widgets/tab-widgets/TabDiveInformation.cpp @@ -5,6 +5,7 @@ #include "profile-widget/profilewidget2.h" #include "../tagwidget.h" #include "commands/command.h" +#include "core/subsurface-string.h" #include "core/units.h" #include "core/dive.h" #include "core/qthelper.h" @@ -22,10 +23,10 @@ TabDiveInformation::TabDiveInformation(QWidget *parent) : TabBase(parent), ui(ne { ui->setupUi(this); connect(&diveListNotifier, &DiveListNotifier::divesChanged, this, &TabDiveInformation::divesChanged); - QStringList atmPressTypes { "mbar", get_depth_unit() ,"use dc"}; + QStringList atmPressTypes { "mbar", get_depth_unit() ,tr("use dc")}; ui->atmPressType->insertItems(0, atmPressTypes); pressTypeIndex = 0; - QStringList waterTypes {"Fresh", "Salty", "EN13319", "Salt", "use dc"}; + QStringList waterTypes {tr("Fresh"), tr("Salty"), "EN13319", tr("Salt"), tr("use dc")}; ui->waterTypeCombo->insertItems(0, waterTypes); // This needs to be the same order as enum dive_comp_type in dive.h! @@ -36,7 +37,11 @@ TabDiveInformation::TabDiveInformation(QWidget *parent) : TabBase(parent), ui(ne connect(ui->diveType, SIGNAL(currentIndexChanged(int)), this, SLOT(diveModeChanged(int))); QString CSSSetSmallLabel = "QLabel { color: mediumblue; font-size: " + // Using label height QString::number((int)(0.5 + ui->diveHeadingLabel->geometry().height() * 0.66)) + "px;}"; // .. set CSS font size of star widget subscripts +#if defined(Q_OS_WIN) ui->scrollAreaWidgetContents_3->setStyleSheet("QGroupBox::title { color: mediumblue;} "); +#else + ui->scrollAreaWidgetContents_3->setStyleSheet("QGroupBox { border: 1px solid silver; border-radius: 4px; margin-top: 0.65em; background-color: #e7e4e4;} QGroupBox::title { color: mediumblue;} "); +#endif ui->diveHeadingLabel->setStyleSheet(CSS_SET_HEADING_BLUE); ui->gasHeadingLabel->setStyleSheet(CSS_SET_HEADING_BLUE); ui->environmentHeadingLabel->setStyleSheet(CSS_SET_HEADING_BLUE); @@ -102,13 +107,14 @@ void TabDiveInformation::closeWarning() } void TabDiveInformation::updateWaterTypeWidget() -{ - if (prefs.salinityEditDefault) { +{ // Decide on whether to show the water type/salinity combobox or not + if (prefs.salinityEditDefault || manualDive) + { // if the preference setting has been checked or this is a manually-entered dive ui->waterTypeText->setVisible(false); - ui->waterTypeCombo->setVisible(true); - } else { + ui->waterTypeCombo->setVisible(true); // show combobox + } else { // if the preference setting has not been set ui->waterTypeCombo->setVisible(false); - ui->waterTypeText->setVisible(true); + ui->waterTypeText->setVisible(true); // show water type as text label } } @@ -216,6 +222,7 @@ void TabDiveInformation::updateData() } int salinity_value; + manualDive = same_string(current_dive->dc.model, "manually added dive"); updateWaterTypeWidget(); updateProfile(); updateWhen(); @@ -232,13 +239,13 @@ void TabDiveInformation::updateData() ui->waterTypeCombo->setCurrentIndex(updateSalinityComboIndex(salinity_value)); } else { // If water salinity is not editable: show water type as a text label if (salinity_value < 10050) - ui->waterTypeText->setText("Fresh"); + ui->waterTypeText->setText(tr("Fresh")); else if (salinity_value < 10190) - ui->waterTypeText->setText("Salty"); + ui->waterTypeText->setText(tr("Salty")); else if (salinity_value < 10210) ui->waterTypeText->setText("EN13319"); else - ui->waterTypeText->setText("Salt"); + ui->waterTypeText->setText(tr("Salt")); } checkDcSalinityOverWritten(); // If exclamation is needed (i.e. salinity overwrite by user), then show it ui->salinityText->setText(QString("%1g/ℓ").arg(salinity_value / 10.0)); diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.h b/desktop-widgets/tab-widgets/TabDiveInformation.h index f905bc597..008d40f61 100644 --- a/desktop-widgets/tab-widgets/TabDiveInformation.h +++ b/desktop-widgets/tab-widgets/TabDiveInformation.h @@ -31,6 +31,7 @@ private slots: void on_waterTypeCombo_activated(int index); private: Ui::TabDiveInformation *ui; + bool manualDive; void updateProfile(); int updateSalinityComboIndex(int salinity); void checkDcSalinityOverWritten(); diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.ui b/desktop-widgets/tab-widgets/TabDiveInformation.ui index 2990e6dfc..e31344529 100644 --- a/desktop-widgets/tab-widgets/TabDiveInformation.ui +++ b/desktop-widgets/tab-widgets/TabDiveInformation.ui @@ -476,7 +476,7 @@ <set>Qt::AlignHCenter</set> </property> <property name="sizePolicy"> - <sizepolicy hsizetype="Ignored" vsizetype="Preferred"> + <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> <horstretch>1</horstretch> <verstretch>0</verstretch> </sizepolicy> |