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 <acrlakshman@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Lakshman 2014-03-10 22:49:08 -05:00 committed by Dirk Hohndel
parent eb47b2a8d8
commit 6e4466aa0a
6 changed files with 35 additions and 2 deletions

View file

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