summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/tab-widgets
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-04-01 21:07:51 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-04-12 18:19:07 +0300
commit8c6205fc0d43af849769c11f8a8fb79396895ecc (patch)
treed61c9f4bc7224bbf6e7190b84d2a25a8ba786473 /desktop-widgets/tab-widgets
parent9b5eab4ca1589fe28062819e7ebe8daa3929d45a (diff)
downloadsubsurface-8c6205fc0d43af849769c11f8a8fb79396895ecc.tar.gz
Undo: on save remove focus from active fields
The editing of a dive field is only performed when focus is removed from the field. On pressing CTRL-s, the changes in the currently active field were therefore not saved. Remove the focus from all fields to trigger an edit command yand thus ensure that all changes are saved. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/tab-widgets')
-rw-r--r--desktop-widgets/tab-widgets/maintab.cpp11
-rw-r--r--desktop-widgets/tab-widgets/maintab.h1
2 files changed, 10 insertions, 2 deletions
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp
index cc4f4faac..099487aea 100644
--- a/desktop-widgets/tab-widgets/maintab.cpp
+++ b/desktop-widgets/tab-widgets/maintab.cpp
@@ -727,7 +727,7 @@ void MainTab::acceptChanges()
bool do_replot = false;
if (ui.location->hasFocus())
- setFocus();
+ stealFocus();
EditMode lastMode = editMode;
editMode = IGNORE;
@@ -1077,6 +1077,13 @@ void MainTab::editWeightWidget(const QModelIndex &index)
ui.weights->edit(index);
}
+// Remove focus from any active field to update the corresponding value in the dive.
+// Do this by setting the focus to ourself
+void MainTab::stealFocus()
+{
+ setFocus();
+}
+
void MainTab::escDetected()
{
// In edit mode, pressing escape cancels the current changes.
@@ -1084,7 +1091,7 @@ void MainTab::escDetected()
if (editMode != NONE)
rejectChanges();
else
- setFocus();
+ stealFocus();
}
void MainTab::clearTabs()
diff --git a/desktop-widgets/tab-widgets/maintab.h b/desktop-widgets/tab-widgets/maintab.h
index 59503fa06..9968472c9 100644
--- a/desktop-widgets/tab-widgets/maintab.h
+++ b/desktop-widgets/tab-widgets/maintab.h
@@ -53,6 +53,7 @@ public:
void updateCoordinatesText(qreal lat, qreal lon);
void refreshDisplayedDiveSite();
void nextInputField(QKeyEvent *event);
+ void stealFocus();
signals:
void diveSiteChanged();