mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 21:03:23 +00:00
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>
This commit is contained in:
parent
9b5eab4ca1
commit
8c6205fc0d
3 changed files with 13 additions and 2 deletions
|
@ -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));
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -53,6 +53,7 @@ public:
|
|||
void updateCoordinatesText(qreal lat, qreal lon);
|
||||
void refreshDisplayedDiveSite();
|
||||
void nextInputField(QKeyEvent *event);
|
||||
void stealFocus();
|
||||
|
||||
signals:
|
||||
void diveSiteChanged();
|
||||
|
|
Loading…
Add table
Reference in a new issue