From a5c0e268421d4350ffdd07b46fd76b454cf48271 Mon Sep 17 00:00:00 2001 From: Tobias Markmann Date: Wed, 18 Mar 2015 13:56:50 +0100 Subject: Fix popup visibility issues in QtSuggestingJIDInput When hiding the popup after selection of an item via mouse, the focus was given to a widget other then the QtSuggestingJIDInput or its parent dialog. This patch explicitly sets the focus back to the QtSuggestingJIDInput. Hide the potentially open popup when the QtSuggestingJIDInput is hidden. This can happen when the user closes a dialog with a QtSuggestingJIDInput inside of it. Test-Information: Verified described behavior on OS X 10.9.5 and Windows 8. Change-Id: Ic6629e6e626be18a70de159df62cda79dd82ee09 diff --git a/Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp b/Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp index 2b775f9..8ed6efb 100644 --- a/Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp +++ b/Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp @@ -132,6 +132,11 @@ void QtSuggestingJIDInput::keyPressEvent(QKeyEvent* event) { } } +void QtSuggestingJIDInput::hideEvent(QHideEvent* /* event */) { + // Hide our popup when we are hidden (can happen when a dialog is closed by the user). + treeViewPopup_->hide(); +} + void QtSuggestingJIDInput::handleApplicationFocusChanged(QWidget* /*old*/, QWidget* /*now*/) { /* Using the now argument gives use the wrong widget. This is part of the code needed to prevent stealing of focus when opening a the suggestion window. */ @@ -196,6 +201,9 @@ void QtSuggestingJIDInput::showPopup() { void QtSuggestingJIDInput::hidePopup() { disconnect(qApp, SIGNAL(focusChanged(QWidget*, QWidget*)), this, SLOT(handleApplicationFocusChanged(QWidget*, QWidget*))); treeViewPopup_->hide(); + + // Give focus back to input widget because the hide() call passes the focus to the wrong widget. + setFocus(); } } diff --git a/Swift/QtUI/UserSearch/QtSuggestingJIDInput.h b/Swift/QtUI/UserSearch/QtSuggestingJIDInput.h index cacb8d2..d5ec45d 100644 --- a/Swift/QtUI/UserSearch/QtSuggestingJIDInput.h +++ b/Swift/QtUI/UserSearch/QtSuggestingJIDInput.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2014 Isode Limited. + * Copyright (c) 2014-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -42,6 +42,7 @@ class QtSuggestingJIDInput : public QLineEdit { protected: virtual void keyPressEvent(QKeyEvent* event); + virtual void hideEvent(QHideEvent* event); private: void handleSettingsChanged(const std::string& setting); -- cgit v0.10.2-6-g49f6