Desktop: Dive site editing: give up focus on ESC

As long as a text field is active, CTRL-Z only affects this field.
Thus it is suprisingly hard to undo edits. There seems to be a
fundamental problem with CTRL-Z handling.

To make it somewhat easier, catch any ESC-key event and move the
focus to the MainWindow. This effectively removes the focus from
any text field.

This all appears very wrong, but so far I wasn't able to find the
root cause of the problem.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-03-16 10:44:39 +01:00 committed by Dirk Hohndel
parent 3a3089770a
commit 434990dcd4
2 changed files with 8 additions and 0 deletions

View file

@ -41,6 +41,13 @@ LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBo
ui.diveSiteListView->installEventFilter(this);
}
void LocationInformationWidget::keyPressEvent(QKeyEvent *e)
{
if (e->key() == Qt::Key_Escape)
MainWindow::instance()->setFocus();
return QGroupBox::keyPressEvent(e);
}
bool LocationInformationWidget::eventFilter(QObject *object, QEvent *ev)
{
if (ev->type() == QEvent::ContextMenu) {

View file

@ -33,6 +33,7 @@ private slots:
void updateLabels();
void diveSiteChanged(struct dive_site *ds, int field);
private:
void keyPressEvent(QKeyEvent *e) override;
void clearLabels();
Ui::LocationInformation ui;
GPSLocationInformationModel filter_model;