From 6e4466aa0a349df1b377a3755117b1f7da76e68f Mon Sep 17 00:00:00 2001 From: Lakshman Date: Mon, 10 Mar 2014 22:49:08 -0500 Subject: Show temperature units in the label when editing dive Currently when user wants to add a new dive information, the ways to know what unit system is being used are - Through preferences panel. - Save the dive information, which displays units in the text field. This patch provides an option to the user to show current unit system by displaying the unit on the side of the label when the user is editing the fields. This feature can be enabled or disabled by using the new checkbox option i.e. `Show units in text labels` included in `preferences->units` section. Signed-off-by: Lakshman Anumolu Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 13 +++++++++++++ qt-ui/maintab.h | 1 + qt-ui/preferences.cpp | 3 +++ qt-ui/preferences.ui | 16 +++++++++++++++- 4 files changed, 32 insertions(+), 1 deletion(-) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 068d703a3..45483f177 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -201,6 +201,7 @@ void MainTab::hideMessage() ui.diveEquipmentMessage->animatedHide(); ui.diveInfoMessage->animatedHide(); ui.diveStatisticsMessage->animatedHide(); + updateTextLabels(); } void MainTab::closeMessage() @@ -222,6 +223,18 @@ void MainTab::displayMessage(QString str) ui.diveInfoMessage->animatedShow(); ui.diveStatisticsMessage->setText(str); ui.diveStatisticsMessage->animatedShow(); + updateTextLabels(true); +} + +void MainTab::updateTextLabels(bool showUnits) +{ + if (showUnits && prefs.text_label_with_units) { + ui.airTempLabel->setText(QApplication::translate("MainTab", "Air temp [%1]").arg(get_temp_unit())); + ui.waterTempLabel->setText(QApplication::translate("MainTab", "Water temp [%1]").arg(get_temp_unit())); + } else { + ui.airTempLabel->setText(QApplication::translate("MainTab", "Air temp", 0, QApplication::UnicodeUTF8)); + ui.waterTempLabel->setText(QApplication::translate("MainTab", "Water temp", 0, QApplication::UnicodeUTF8)); + } } void MainTab::enableEdition(EditMode newEditMode) diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h index 946b673b6..9da1e897f 100644 --- a/qt-ui/maintab.h +++ b/qt-ui/maintab.h @@ -94,6 +94,7 @@ slots: void displayMessage(QString str); void enableEdition(EditMode newEditMode = NONE); void toggleTriggeredColumn(); + void updateTextLabels(bool showUnits = false); private: Ui::MainTab ui; diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp index 2c72cebf2..03123858b 100644 --- a/qt-ui/preferences.cpp +++ b/qt-ui/preferences.cpp @@ -75,6 +75,7 @@ void PreferencesDialog::setUiFromPrefs() ui.cuft->setChecked(prefs.units.volume == units::CUFT); ui.kg->setChecked(prefs.units.weight == units::KG); ui.lbs->setChecked(prefs.units.weight == units::LBS); + ui.text_label_with_units->setChecked(prefs.text_label_with_units); ui.font->setCurrentFont(QString(prefs.divelist_font)); ui.fontsize->setValue(prefs.font_size); @@ -190,6 +191,7 @@ void PreferencesDialog::syncSettings() s.setValue("volume", ui.cuft->isChecked() ? units::CUFT : units::LITER); s.setValue("weight", ui.lbs->isChecked() ? units::LBS : units::KG); s.setValue("vertical_speed_time", ui.vertical_speed_minutes->isChecked() ? units::MINUTES : units::SECONDS); + SB("text_label_with_units", ui.text_label_with_units); s.endGroup(); // Defaults s.beginGroup("GeneralSettings"); @@ -244,6 +246,7 @@ void PreferencesDialog::loadSettings() GET_UNIT("weight", weight, units::LBS, units::KG); } GET_UNIT("vertical_speed_time", vertical_speed_time, units::MINUTES, units::SECONDS); + GET_BOOL("text_label_with_units", text_label_with_units); s.endGroup(); s.beginGroup("TecDetails"); GET_BOOL("po2graph", pp_graphs.po2); diff --git a/qt-ui/preferences.ui b/qt-ui/preferences.ui index 988c5484f..115e93526 100644 --- a/qt-ui/preferences.ui +++ b/qt-ui/preferences.ui @@ -478,7 +478,21 @@ - + + + + + + + true + + + Show units in text labels + + + + + -- cgit v1.2.3-70-g09d2