From 6c8f158569ede6712cb3c30a89af874467e884a0 Mon Sep 17 00:00:00 2001 From: Michael Keller Date: Mon, 9 Sep 2024 23:53:06 +1200 Subject: [PATCH] Profile: Allow Editing of Initial Gas. Allow the initial gas of the dive to be edited through the context menu in the dive profile, by right-clicking into the profile at the very start of the dive. Of course this will likely completely invalidate the decompression calculation of any actually logged dives, but this is no different to the addition and modification of gas changes during the dive that is already possible. Proposed by @harrydevil in #4291. Signed-off-by: Michael Keller --- profile-widget/profilewidget2.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index 8ca5489e6..cb346b24d 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -558,10 +558,14 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event) // Add or edit Gas Change if (d && item && item->ev.is_gaschange()) { - addGasChangeMenu(m, tr("Edit Gas Change"), *d, dc, item->ev.time.seconds); + addGasChangeMenu(m, tr("Edit gas change"), *d, dc, item->ev.time.seconds); } else if (d && d->cylinders.size() > 1) { // if we have more than one gas, offer to switch to another one - addGasChangeMenu(m, tr("Add gas change"), *d, dc, seconds); + const struct divecomputer *currentdc = d->get_dc(dc); + if (seconds == 0 || (!currentdc->samples.empty() && seconds <= currentdc->samples[0].time.seconds)) + addGasChangeMenu(m, tr("Set initial gas"), *d, dc, 0); + else + addGasChangeMenu(m, tr("Add gas change"), *d, dc, seconds); } m.addAction(tr("Add setpoint change"), [this, seconds]() { ProfileWidget2::addSetpointChange(seconds); }); m.addAction(tr("Add bookmark"), [this, seconds]() { addBookmark(seconds); });