From 1c854d580ae21d6647bcdd5d6db3e57cda9b5f3c Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 5 Feb 2019 08:01:04 +0100 Subject: Desktop: on ESC, remove focus when editing dive fields Give the user a way to accept the changes made to a dive-field by pressing ESC. Signed-off-by: Berthold Stoeger --- desktop-widgets/tab-widgets/maintab.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'desktop-widgets') diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp index 677b5adb2..11ec9690b 100644 --- a/desktop-widgets/tab-widgets/maintab.cpp +++ b/desktop-widgets/tab-widgets/maintab.cpp @@ -721,9 +721,8 @@ void MainTab::acceptChanges() struct dive *d; bool do_replot = false; - if (ui.location->hasFocus()) { - this->setFocus(); - } + if (ui.location->hasFocus()) + setFocus(); acceptingEdit = true; tabBar()->setTabIcon(0, QIcon()); // Notes @@ -1337,8 +1336,12 @@ void MainTab::editWeightWidget(const QModelIndex &index) void MainTab::escDetected() { + // In edit mode, pressing escape cancels the current changes. + // In standard mode, remove focus of any active widget to if (editMode != NONE) rejectChanges(); + else + setFocus(); } void MainTab::clearTabs() { -- cgit v1.2.3-70-g09d2