From b77d990ed6892081f7c1e0df62631b57aad3b59f Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 14 Nov 2013 15:20:11 -0200 Subject: Close the Air list when clicking outside of it. This patch closes the air list when clicing outside of it, making the use of the planner more pleasant. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/diveplanner.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 18a97567c..b0f3e901e 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -191,11 +191,18 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent) bool DivePlannerGraphics::eventFilter(QObject *object, QEvent* event) { - if (object == gasListView && event->type() == QEvent::KeyPress) { + if (object != gasListView) + return false; + if (event->type() == QEvent::KeyPress) { QKeyEvent *ke = static_cast(event); if (ke->key() == Qt::Key_Escape) gasListView->hide(); } + if (event->type() == QEvent::MouseButtonPress){ + QMouseEvent *me = static_cast(event); + if (!gasListView->geometry().contains(me->pos())) + gasListView->hide(); + } return false; } -- cgit v1.2.3-70-g09d2