From 8c6205fc0d43af849769c11f8a8fb79396895ecc Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 1 Apr 2019 21:07:51 +0200 Subject: 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 --- desktop-widgets/tab-widgets/maintab.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'desktop-widgets/tab-widgets/maintab.cpp') 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() -- cgit v1.2.3-70-g09d2