From 38609296d1cd6f52d4c35c87ee30f67517158ea0 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Mon, 9 Feb 2015 12:13:45 +0100 Subject: [PATCH] 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 --- share/qtcreator/themes/dark.creatortheme | 1 + share/qtcreator/themes/default.creatortheme | 1 + src/libs/utils/theme/theme.h | 1 + src/plugins/coreplugin/find/findtoolbar.cpp | 10 ++++++++++ src/plugins/coreplugin/find/findtoolbar.h | 1 + 5 files changed, 14 insertions(+) diff --git a/share/qtcreator/themes/dark.creatortheme b/share/qtcreator/themes/dark.creatortheme index 0923cb1f529..e90ae2ed2e5 100644 --- a/share/qtcreator/themes/dark.creatortheme +++ b/share/qtcreator/themes/dark.creatortheme @@ -68,6 +68,7 @@ ProgressBarColorNormal=hoverBackground ProgressBarTitleColor=text SplitterColor=ffb0b0b0 TextColorDisabled=textDisabled +TextColorError=ffff4040 TextColorHighlight=ffff0000 TextColorNormal=text TodoItemTextColor=ff000000 diff --git a/share/qtcreator/themes/default.creatortheme b/share/qtcreator/themes/default.creatortheme index 73c7ad086fb..2f17c1b9095 100644 --- a/share/qtcreator/themes/default.creatortheme +++ b/share/qtcreator/themes/default.creatortheme @@ -62,6 +62,7 @@ ProgressBarColorNormal=b4ffffff ProgressBarTitleColor=ffffffff SplitterColor=ff151515 TextColorDisabled=ff000000 +TextColorError=ffff0000 TextColorHighlight=ffa0a0a4 TextColorNormal=ff000000 TodoItemTextColor=ff000000 diff --git a/src/libs/utils/theme/theme.h b/src/libs/utils/theme/theme.h index a30d175da29..aaf27e73bb2 100644 --- a/src/libs/utils/theme/theme.h +++ b/src/libs/utils/theme/theme.h @@ -116,6 +116,7 @@ public: ProgressBarTitleColor, SplitterColor, TextColorDisabled, + TextColorError, TextColorHighlight, TextColorNormal, TodoItemTextColor, diff --git a/src/plugins/coreplugin/find/findtoolbar.cpp b/src/plugins/coreplugin/find/findtoolbar.cpp index a07b9451063..493aea53b40 100644 --- a/src/plugins/coreplugin/find/findtoolbar.cpp +++ b/src/plugins/coreplugin/find/findtoolbar.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -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); diff --git a/src/plugins/coreplugin/find/findtoolbar.h b/src/plugins/coreplugin/find/findtoolbar.h index 1ee63ac3e0b..ada8beaaa56 100644 --- a/src/plugins/coreplugin/find/findtoolbar.h +++ b/src/plugins/coreplugin/find/findtoolbar.h @@ -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);