summaryrefslogtreecommitdiff
path: root/src/plugins/find
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@digia.com>2013-03-20 13:48:58 +0100
committerEike Ziller <eike.ziller@digia.com>2013-03-20 14:50:29 +0100
commit356b85d431fd9c90fac8de736fd913a20fcb6553 (patch)
tree4932424bd85322049c368f1d286938cfe54284af /src/plugins/find
parent0d850d7d15e052d6e3298c95781676e82260df69 (diff)
downloadqt-creator-356b85d431fd9c90fac8de736fd913a20fcb6553.tar.gz
Work around issue in Qt5 that shortcut override events are posted twice
Make shortcut override handling not have side effects. Task-number: QTBUG-30164 Change-Id: Ie54a31fc6539d4e509b0903983df0effa06cee12 Reviewed-by: Daniel Teske <daniel.teske@digia.com>
Diffstat (limited to 'src/plugins/find')
-rw-r--r--src/plugins/find/findtoolbar.cpp28
-rw-r--r--src/plugins/find/findtoolbar.h3
2 files changed, 24 insertions, 7 deletions
diff --git a/src/plugins/find/findtoolbar.cpp b/src/plugins/find/findtoolbar.cpp
index ec4d673a69..571c193910 100644
--- a/src/plugins/find/findtoolbar.cpp
+++ b/src/plugins/find/findtoolbar.cpp
@@ -285,6 +285,14 @@ void FindToolBar::installEventFilters()
}
}
+bool FindToolBar::shouldSetFocusOnKeyEvent(QKeyEvent *event)
+{
+ return event->key() == Qt::Key_Escape && !event->modifiers()
+ && !m_findCompleter->popup()->isVisible()
+ && !m_replaceCompleter->popup()->isVisible()
+ && m_currentDocumentFind->isEnabled();
+}
+
bool FindToolBar::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::KeyPress) {
@@ -315,13 +323,9 @@ bool FindToolBar::eventFilter(QObject *obj, QEvent *event)
}
} else if (obj == this && event->type() == QEvent::ShortcutOverride) {
QKeyEvent *ke = static_cast<QKeyEvent *>(event);
- if (ke->key() == Qt::Key_Escape && !ke->modifiers()
- && !m_findCompleter->popup()->isVisible()
- && !m_replaceCompleter->popup()->isVisible()) {
- if (setFocusToCurrentFindSupport()) {
- event->accept();
- return true;
- }
+ if (shouldSetFocusOnKeyEvent(ke)) {
+ event->accept();
+ return true;
} else if (ke->key() == Qt::Key_Space && (ke->modifiers() & Utils::HostOsInfo::controlModifier())) {
event->accept();
return true;
@@ -334,6 +338,16 @@ bool FindToolBar::eventFilter(QObject *obj, QEvent *event)
return Utils::StyledBar::eventFilter(obj, event);
}
+void FindToolBar::keyPressEvent(QKeyEvent *event)
+{
+ if (shouldSetFocusOnKeyEvent(event)) {
+ if (setFocusToCurrentFindSupport())
+ event->accept();
+ return;
+ }
+ return Utils::StyledBar::keyPressEvent(event);
+}
+
void FindToolBar::adaptToCandidate()
{
updateFindAction();
diff --git a/src/plugins/find/findtoolbar.h b/src/plugins/find/findtoolbar.h
index 6a341b80b2..f8f9b3b8ab 100644
--- a/src/plugins/find/findtoolbar.h
+++ b/src/plugins/find/findtoolbar.h
@@ -97,6 +97,7 @@ private slots:
protected:
bool focusNextPrevChild(bool next);
+ void keyPressEvent(QKeyEvent *event);
private:
void installEventFilters();
@@ -115,6 +116,8 @@ private:
void updateIcons();
void updateFlagMenus();
+ bool shouldSetFocusOnKeyEvent(QKeyEvent *event);
+
FindPlugin *m_plugin;
CurrentDocumentFind *m_currentDocumentFind;
Ui::FindWidget m_ui;