forked from qt-creator/qt-creator
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:
@@ -68,6 +68,7 @@ ProgressBarColorNormal=hoverBackground
|
||||
ProgressBarTitleColor=text
|
||||
SplitterColor=ffb0b0b0
|
||||
TextColorDisabled=textDisabled
|
||||
TextColorError=ffff4040
|
||||
TextColorHighlight=ffff0000
|
||||
TextColorNormal=text
|
||||
TodoItemTextColor=ff000000
|
||||
|
||||
@@ -62,6 +62,7 @@ ProgressBarColorNormal=b4ffffff
|
||||
ProgressBarTitleColor=ffffffff
|
||||
SplitterColor=ff151515
|
||||
TextColorDisabled=ff000000
|
||||
TextColorError=ffff0000
|
||||
TextColorHighlight=ffa0a0a4
|
||||
TextColorNormal=ff000000
|
||||
TodoItemTextColor=ff000000
|
||||
|
||||
@@ -116,6 +116,7 @@ public:
|
||||
ProgressBarTitleColor,
|
||||
SplitterColor,
|
||||
TextColorDisabled,
|
||||
TextColorError,
|
||||
TextColorHighlight,
|
||||
TextColorNormal,
|
||||
TodoItemTextColor,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -152,6 +152,7 @@ private:
|
||||
bool toolBarHasFocus() const;
|
||||
bool canShowAllControls(bool replaceIsVisible) const;
|
||||
void acceptCandidateAndMoveToolBar();
|
||||
void indicateSearchState(IFindSupport::Result searchState);
|
||||
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
void setFindText(const QString &text);
|
||||
|
||||
Reference in New Issue
Block a user