Commit 99929ac9 authored by con's avatar con
Browse files

Avoid a flickering popup at startup and save some time on startup.

QCompleter::popup() actually shows the popup, which is both annoying and slow.
Delay the annoyance from startup to a later point till this is fixed in
Qt.
parent 171cb415
......@@ -71,7 +71,8 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
m_regexpIcon(":/find/images/regexp.png"),
m_wholewordsIcon(":/find/images/wholewords.png"),
m_findIncrementalTimer(this), m_findStepTimer(this),
m_useFakeVim(false)
m_useFakeVim(false),
m_eventFiltersInstalled(false)
{
//setup ui
m_ui.setupUi(this);
......@@ -89,17 +90,12 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
m_findCompleter->setModel(m_plugin->findCompletionModel());
m_replaceCompleter->setModel(m_plugin->replaceCompletionModel());
m_ui.findEdit->setCompleter(m_findCompleter);
m_findCompleter->popup()->installEventFilter(this);
m_ui.replaceEdit->setCompleter(m_replaceCompleter);
m_ui.findEdit->setSide(qApp->layoutDirection() == Qt::LeftToRight ? Utils::FancyLineEdit::Right : Utils::FancyLineEdit::Left);
QMenu *lineEditMenu = new QMenu(m_ui.findEdit);
m_ui.findEdit->setMenu(lineEditMenu);
m_ui.findEdit->installEventFilter(this);
m_ui.replaceEdit->installEventFilter(this);
this->installEventFilter(this);
connect(m_ui.findEdit, SIGNAL(textChanged(const QString&)), this, SLOT(invokeFindIncremental()));
connect(m_ui.findEdit, SIGNAL(returnPressed()), this, SLOT(invokeFindEnter()));
connect(m_ui.replaceEdit, SIGNAL(returnPressed()), this, SLOT(invokeReplaceEnter()));
......@@ -229,6 +225,17 @@ FindToolBar::~FindToolBar()
{
}
void FindToolBar::installEventFilters()
{
if (!m_eventFiltersInstalled) {
m_findCompleter->popup()->installEventFilter(this);
m_ui.findEdit->installEventFilter(this);
m_ui.replaceEdit->installEventFilter(this);
this->installEventFilter(this);
m_eventFiltersInstalled = true;
}
}
bool FindToolBar::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::KeyPress) {
......@@ -578,6 +585,7 @@ void FindToolBar::openFind()
void FindToolBar::openFindToolBar()
{
installEventFilters();
if (!m_currentDocumentFind->candidateIsEnabled())
return;
Core::FindToolBarPlaceHolder *holder = findToolBarPlaceHolder();
......
......@@ -97,6 +97,7 @@ protected:
bool focusNextPrevChild(bool next);
private:
void installEventFilters();
void invokeClearResults();
bool setFocusToCurrentFindSupport();
void setFindFlag(IFindSupport::FindFlag flag, bool enabled);
......@@ -136,6 +137,7 @@ private:
QTimer m_findIncrementalTimer;
QTimer m_findStepTimer;
bool m_useFakeVim;
bool m_eventFiltersInstalled;
};
} // namespace Internal
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment