From 08db77333b8a6fe7be71f30bf0d5ee15a6bf01f1 Mon Sep 17 00:00:00 2001 From: willemferguson Date: Mon, 11 Nov 2019 12:52:01 +0200 Subject: Notes tab: Use top RH for depth and duretion fields Currently the top righthand part of the notes tab is used for showing and editing air teperature and water temperature. But these fields were moved over to the Information tab and are not required in the Notes tab any more. Rather use this space for the depth and duration data for manually-entered dives. Currently extra vertical space is created in the Notes tab for showing this field, resulting in inefficient use of screen space and inelegant layout. This code moves the Duration and Depth fields into the top righthand of the Notes tab. Signed-off-by: willemferguson --- desktop-widgets/tab-widgets/maintab.cpp | 49 ------------ desktop-widgets/tab-widgets/maintab.h | 3 - desktop-widgets/tab-widgets/maintab.ui | 130 ++++++++++++++++++++------------ 3 files changed, 83 insertions(+), 99 deletions(-) (limited to 'desktop-widgets') diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp index 7e82ca5f1..417f9f91e 100644 --- a/desktop-widgets/tab-widgets/maintab.cpp +++ b/desktop-widgets/tab-widgets/maintab.cpp @@ -186,7 +186,6 @@ MainTab::~MainTab() void MainTab::hideMessage() { ui.diveNotesMessage->animatedHide(); - updateTextLabels(false); } void MainTab::closeMessage() @@ -205,18 +204,6 @@ void MainTab::displayMessage(QString str) ui.diveNotesMessage->setCloseButtonVisible(false); ui.diveNotesMessage->setText(str); ui.diveNotesMessage->animatedShow(); - updateTextLabels(); -} - -void MainTab::updateTextLabels(bool showUnits) -{ - if (showUnits) { - ui.airTempLabel->setText(tr("Air temp. [%1]").arg(get_temp_unit())); - ui.waterTempLabel->setText(tr("Water temp. [%1]").arg(get_temp_unit())); - } else { - ui.airTempLabel->setText(tr("Air temp.")); - ui.waterTempLabel->setText(tr("Water temp.")); - } } void MainTab::enableEdition(EditMode newEditMode) @@ -269,10 +256,6 @@ void MainTab::divesChanged(const QVector &dives, DiveField field) ui.duration->setText(render_seconds_to_string(current_dive->duration.seconds)); if (field.depth) ui.depth->setText(get_depth_string(current_dive->maxdepth, true)); - if (field.air_temp) - ui.airtemp->setText(get_temperature_string(current_dive->airtemp, true)); - if (field.water_temp) - ui.watertemp->setText(get_temperature_string(current_dive->watertemp, true)); if (field.rating) ui.rating->setCurrentStars(current_dive->rating); if (field.notes) @@ -427,10 +410,6 @@ void MainTab::updateDiveInfo() ui.RatingLabel->setVisible(false); ui.tagWidget->setVisible(false); ui.TagLabel->setVisible(false); - ui.airTempLabel->setVisible(false); - ui.airtemp->setVisible(false); - ui.waterTempLabel->setVisible(false); - ui.watertemp->setVisible(false); ui.dateEdit->setReadOnly(true); ui.timeLabel->setVisible(false); ui.timeEdit->setVisible(false); @@ -479,10 +458,6 @@ void MainTab::updateDiveInfo() ui.DivemasterLabel->setVisible(true); ui.TagLabel->setVisible(true); ui.tagWidget->setVisible(true); - ui.airTempLabel->setVisible(true); - ui.airtemp->setVisible(true); - ui.waterTempLabel->setVisible(true); - ui.watertemp->setVisible(true); ui.dateEdit->setReadOnly(false); ui.timeLabel->setVisible(true); ui.timeEdit->setVisible(true); @@ -503,8 +478,6 @@ void MainTab::updateDiveInfo() updateDateTime(current_dive); ui.divemaster->setText(current_dive->divemaster); ui.buddy->setText(current_dive->buddy); - ui.airtemp->setText(get_temperature_string(current_dive->airtemp, true)); - ui.watertemp->setText(get_temperature_string(current_dive->watertemp, true)); } ui.duration->setText(render_seconds_to_string(current_dive->duration.seconds)); ui.depth->setText(get_depth_string(current_dive->maxdepth, true)); @@ -524,8 +497,6 @@ void MainTab::updateDiveInfo() ui.location->clear(); ui.divemaster->clear(); ui.buddy->clear(); - ui.airtemp->clear(); - ui.watertemp->clear(); ui.notes->clear(); /* set date and time to minimums which triggers showing the special value text */ ui.dateEdit->setSpecialValueText(QString("-")); @@ -733,26 +704,6 @@ void MainTab::on_depth_editingFinished() divesEdited(Command::editDepth(parseLengthToMm(ui.depth->text()), true)); } -void MainTab::on_airtemp_editingFinished() -{ - // If the field wasn't modified by the user, don't post a new undo command. - // Owing to rounding errors, this might lead to undo commands that have - // no user visible effects. These can be very confusing. - if (editMode == IGNORE_MODE || !ui.airtemp->isModified() || !current_dive) - return; - divesEdited(Command::editAirTemp(parseTemperatureToMkelvin(ui.airtemp->text()), false)); -} - -void MainTab::on_watertemp_editingFinished() -{ - // If the field wasn't modified by the user, don't post a new undo command. - // Owing to rounding errors, this might lead to undo commands that have - // no user visible effects. These can be very confusing. - if (editMode == IGNORE_MODE || !ui.watertemp->isModified() || !current_dive) - return; - divesEdited(Command::editWaterTemp(parseTemperatureToMkelvin(ui.watertemp->text()), false)); -} - // Editing of the dive time is different. If multiple dives are edited, // all dives are shifted by an offset. static void shiftTime(QDateTime &dateTime) diff --git a/desktop-widgets/tab-widgets/maintab.h b/desktop-widgets/tab-widgets/maintab.h index e4994a231..f4e2bd6e1 100644 --- a/desktop-widgets/tab-widgets/maintab.h +++ b/desktop-widgets/tab-widgets/maintab.h @@ -62,10 +62,8 @@ slots: void on_buddy_editingFinished(); void on_diveTripLocation_editingFinished(); void on_notes_editingFinished(); - void on_airtemp_editingFinished(); void on_duration_editingFinished(); void on_depth_editingFinished(); - void on_watertemp_editingFinished(); void on_dateEdit_dateChanged(const QDate &date); void on_timeEdit_timeChanged(const QTime & time); void on_rating_valueChanged(int value); @@ -75,7 +73,6 @@ slots: void closeWarning(); void displayMessage(QString str); void enableEdition(EditMode newEditMode = NONE); - void updateTextLabels(bool showUnits = true); void escDetected(void); private: Ui::MainTab ui; diff --git a/desktop-widgets/tab-widgets/maintab.ui b/desktop-widgets/tab-widgets/maintab.ui index 8e172f91a..098c67c3c 100644 --- a/desktop-widgets/tab-widgets/maintab.ui +++ b/desktop-widgets/tab-widgets/maintab.ui @@ -77,50 +77,74 @@ 0 - - - - Duration + + + + Date + + + + 1 + 0 + + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft - - + + - Date + Time + + + + 1 + 0 + - Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft - - + + - Time + - - Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + 2 + 0 + - - - Air temp. + + + + 1 + 0 + - - Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + Depth - - - Water temp. + + + + 1 + 0 + - - Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + Duration (h:mm) @@ -132,49 +156,61 @@ Qt::UTC + + + 1 + 0 + + - + - - 0 + + 1 0 Qt::UTC - + - - - - false + + + + + + + + 2 + 0 + - - - - false + + + + + 1 + 0 + - - - - Depth + + + + + 1 + 0 + - - - - - - - - + + -- cgit v1.2.3-70-g09d2