diff options
Diffstat (limited to 'desktop-widgets')
-rw-r--r-- | desktop-widgets/mainwindow.cpp | 3 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/maintab.cpp | 11 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/maintab.h | 1 |
3 files changed, 13 insertions, 2 deletions
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 09af6414f..84c4c867a 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -528,11 +528,13 @@ void MainWindow::on_actionOpen_triggered() void MainWindow::on_actionSave_triggered() { + mainTab->stealFocus(); // Make sure that any currently edited field is updated before saving. file_save(); } void MainWindow::on_actionSaveAs_triggered() { + mainTab->stealFocus(); // Make sure that any currently edited field is updated before saving. file_save_as(); } @@ -582,6 +584,7 @@ void MainWindow::on_actionCloudstoragesave_triggered() qDebug() << "Saving cloud storage to:" << filename; if (mainTab->isEditing()) mainTab->acceptChanges(); + mainTab->stealFocus(); // Make sure that any currently edited field is updated before saving. showProgressBar(); int error = save_dives(qPrintable(filename)); 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(); |