summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swift/QtUI/UserSearch/QtSuggestingJIDInput.cpp8
-rw-r--r--Swift/QtUI/UserSearch/QtSuggestingJIDInput.h3
2 files changed, 10 insertions, 1 deletions
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
@@ -129,12 +129,17 @@ void QtSuggestingJIDInput::keyPressEvent(QKeyEvent* event) {
editingDone();
} else {
QLineEdit::keyPressEvent(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. */
QWidget* now = qApp->focusWidget();
if (!now || (now != treeViewPopup_ && now != this && !now->isAncestorOf(this) && !now->isAncestorOf(treeViewPopup_) && !this->isAncestorOf(now) && !treeViewPopup_->isAncestorOf(now))) {
hidePopup();
@@ -193,9 +198,12 @@ void QtSuggestingJIDInput::showPopup() {
setFocus();
}
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
@@ -2,13 +2,13 @@
* Copyright (c) 2013 Tobias Markmann
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2015 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
@@ -39,12 +39,13 @@ class QtSuggestingJIDInput : public QLineEdit {
signals:
void editingDone();
protected:
virtual void keyPressEvent(QKeyEvent* event);
+ virtual void hideEvent(QHideEvent* event);
private:
void handleSettingsChanged(const std::string& setting);
private slots:
void handleClicked(const QModelIndex& index);