summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-03-16 10:44:39 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-04-12 18:19:07 +0300
commit434990dcd40cdbc414893fbc532abf52c30a155b (patch)
treeff727c54f7f2cea2691072f967b49d57d66a4c4c
parent3a3089770a5af9ef421779186f4dd47b01611ad2 (diff)
downloadsubsurface-434990dcd40cdbc414893fbc532abf52c30a155b.tar.gz
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>
-rw-r--r--desktop-widgets/locationinformation.cpp7
-rw-r--r--desktop-widgets/locationinformation.h1
2 files changed, 8 insertions, 0 deletions
diff --git a/desktop-widgets/locationinformation.cpp b/desktop-widgets/locationinformation.cpp
index 3c09656f1..1a80486a3 100644
--- a/desktop-widgets/locationinformation.cpp
+++ b/desktop-widgets/locationinformation.cpp
@@ -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) {
diff --git a/desktop-widgets/locationinformation.h b/desktop-widgets/locationinformation.h
index 161ce26ef..beb5fd404 100644
--- a/desktop-widgets/locationinformation.h
+++ b/desktop-widgets/locationinformation.h
@@ -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;