Find widget: Give feedback to user about whether search has succeeded.

Right now, the only way for a user to find out whether a search term was
found is to scan the editor window for marked strings, which is a drag
in the negative case. Also, an ongoing search is practically
indistinguishable from a failed one.
Therefore, color the search term red if the search has failed.

Change-Id: I57441c3804043e1dcfb33638844b4550abd5ac46
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
Christian Kandeler
2015-02-09 12:13:45 +01:00
parent 14fd54e900
commit 38609296d1
5 changed files with 14 additions and 0 deletions

View File

@@ -44,6 +44,7 @@
#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <utils/stylehelper.h>
#include <utils/theme/theme.h>
#include <QDebug>
#include <QSettings>
@@ -522,6 +523,7 @@ void FindToolBar::invokeFindStep()
m_plugin->updateFindCompletion(getFindText());
IFindSupport::Result result =
m_currentDocumentFind->findStep(getFindText(), effectiveFindFlags());
indicateSearchState(result);
if (result == IFindSupport::NotYetFound)
m_findStepTimer.start(50);
}
@@ -535,6 +537,7 @@ void FindToolBar::invokeFindIncremental()
QString text = getFindText();
IFindSupport::Result result =
m_currentDocumentFind->findIncremental(text, effectiveFindFlags());
indicateSearchState(result);
if (result == IFindSupport::NotYetFound)
m_findIncrementalTimer.start(50);
if (text.isEmpty())
@@ -774,6 +777,13 @@ void FindToolBar::acceptCandidateAndMoveToolBar()
}
}
void FindToolBar::indicateSearchState(IFindSupport::Result searchState)
{
const Utils::Theme::Color colorRole = searchState == IFindSupport::NotFound
? Utils::Theme::TextColorError : Utils::Theme::TextColorNormal;
m_ui.findEdit->setTextColor(m_ui.findEdit, Utils::creatorTheme()->color(colorRole));
}
void FindToolBar::openFind(bool focus)
{
setBackward(false);