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

@@ -68,6 +68,7 @@ ProgressBarColorNormal=hoverBackground
ProgressBarTitleColor=text ProgressBarTitleColor=text
SplitterColor=ffb0b0b0 SplitterColor=ffb0b0b0
TextColorDisabled=textDisabled TextColorDisabled=textDisabled
TextColorError=ffff4040
TextColorHighlight=ffff0000 TextColorHighlight=ffff0000
TextColorNormal=text TextColorNormal=text
TodoItemTextColor=ff000000 TodoItemTextColor=ff000000

View File

@@ -62,6 +62,7 @@ ProgressBarColorNormal=b4ffffff
ProgressBarTitleColor=ffffffff ProgressBarTitleColor=ffffffff
SplitterColor=ff151515 SplitterColor=ff151515
TextColorDisabled=ff000000 TextColorDisabled=ff000000
TextColorError=ffff0000
TextColorHighlight=ffa0a0a4 TextColorHighlight=ffa0a0a4
TextColorNormal=ff000000 TextColorNormal=ff000000
TodoItemTextColor=ff000000 TodoItemTextColor=ff000000

View File

@@ -116,6 +116,7 @@ public:
ProgressBarTitleColor, ProgressBarTitleColor,
SplitterColor, SplitterColor,
TextColorDisabled, TextColorDisabled,
TextColorError,
TextColorHighlight, TextColorHighlight,
TextColorNormal, TextColorNormal,
TodoItemTextColor, TodoItemTextColor,

View File

@@ -44,6 +44,7 @@
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/stylehelper.h> #include <utils/stylehelper.h>
#include <utils/theme/theme.h>
#include <QDebug> #include <QDebug>
#include <QSettings> #include <QSettings>
@@ -522,6 +523,7 @@ void FindToolBar::invokeFindStep()
m_plugin->updateFindCompletion(getFindText()); m_plugin->updateFindCompletion(getFindText());
IFindSupport::Result result = IFindSupport::Result result =
m_currentDocumentFind->findStep(getFindText(), effectiveFindFlags()); m_currentDocumentFind->findStep(getFindText(), effectiveFindFlags());
indicateSearchState(result);
if (result == IFindSupport::NotYetFound) if (result == IFindSupport::NotYetFound)
m_findStepTimer.start(50); m_findStepTimer.start(50);
} }
@@ -535,6 +537,7 @@ void FindToolBar::invokeFindIncremental()
QString text = getFindText(); QString text = getFindText();
IFindSupport::Result result = IFindSupport::Result result =
m_currentDocumentFind->findIncremental(text, effectiveFindFlags()); m_currentDocumentFind->findIncremental(text, effectiveFindFlags());
indicateSearchState(result);
if (result == IFindSupport::NotYetFound) if (result == IFindSupport::NotYetFound)
m_findIncrementalTimer.start(50); m_findIncrementalTimer.start(50);
if (text.isEmpty()) 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) void FindToolBar::openFind(bool focus)
{ {
setBackward(false); setBackward(false);

View File

@@ -152,6 +152,7 @@ private:
bool toolBarHasFocus() const; bool toolBarHasFocus() const;
bool canShowAllControls(bool replaceIsVisible) const; bool canShowAllControls(bool replaceIsVisible) const;
void acceptCandidateAndMoveToolBar(); void acceptCandidateAndMoveToolBar();
void indicateSearchState(IFindSupport::Result searchState);
bool eventFilter(QObject *obj, QEvent *event); bool eventFilter(QObject *obj, QEvent *event);
void setFindText(const QString &text); void setFindText(const QString &text);