forked from qt-creator/qt-creator
Core: Allow different highlight colors in search result window
... and make use of that in CppTool's "Find Usages" by assigning different colors to read and write accesses. Fixes: QTCREATORBUG-12734 Change-Id: I067db2c8d693bb2c5be44249931ee4f0269f7e52 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -5,6 +5,8 @@
|
|||||||
<style name="Selection" foreground="#bec0c2" background="#1d545c"/>
|
<style name="Selection" foreground="#bec0c2" background="#1d545c"/>
|
||||||
<style name="LineNumber" foreground="#bec0c2" background="#404244"/>
|
<style name="LineNumber" foreground="#bec0c2" background="#404244"/>
|
||||||
<style name="SearchResult" background="#8a7f2c"/>
|
<style name="SearchResult" background="#8a7f2c"/>
|
||||||
|
<style name="SearchResultAlt1" background="#8a402c"/>
|
||||||
|
<style name="SearchResultAlt2" foreground="#ffaaaa" background="#553636"/>
|
||||||
<style name="SearchScope" background="#8a602c"/>
|
<style name="SearchScope" background="#8a602c"/>
|
||||||
<style name="Parentheses" foreground="#bec0c2" background="#1d545c"/>
|
<style name="Parentheses" foreground="#bec0c2" background="#1d545c"/>
|
||||||
<style name="ParenthesesMismatch" background="#ff6aad"/>
|
<style name="ParenthesesMismatch" background="#ff6aad"/>
|
||||||
|
@@ -33,6 +33,8 @@
|
|||||||
<style name="AutoComplete" foreground="#a0a0ff" background="#333333"/>
|
<style name="AutoComplete" foreground="#a0a0ff" background="#333333"/>
|
||||||
<style name="Preprocessor" foreground="#5555ff"/>
|
<style name="Preprocessor" foreground="#5555ff"/>
|
||||||
<style name="SearchResult" background="#555500"/>
|
<style name="SearchResult" background="#555500"/>
|
||||||
|
<style name="SearchResultAlt1" background="#363636"/>
|
||||||
|
<style name="SearchResultAlt2" foreground="#ffaaaa" background="#553636"/>
|
||||||
<style name="SearchScope" background="#222200"/>
|
<style name="SearchScope" background="#222200"/>
|
||||||
<style name="Selection" foreground="#000000" background="#aaaaaa"/>
|
<style name="Selection" foreground="#000000" background="#aaaaaa"/>
|
||||||
<style name="Static" foreground="#55ff55" italic="true"/>
|
<style name="Static" foreground="#55ff55" italic="true"/>
|
||||||
|
@@ -5,6 +5,8 @@
|
|||||||
<style name="Selection" foreground="#ffffff" background="#308cc6"/>
|
<style name="Selection" foreground="#ffffff" background="#308cc6"/>
|
||||||
<style name="LineNumber" foreground="#9f9d9a" background="#efebe7"/>
|
<style name="LineNumber" foreground="#9f9d9a" background="#efebe7"/>
|
||||||
<style name="SearchResult" background="#ffef0b"/>
|
<style name="SearchResult" background="#ffef0b"/>
|
||||||
|
<style name="SearchResultAlt1" background="#b4b4b4"/>
|
||||||
|
<style name="SearchResultAlt2" background="#ff6464"/>
|
||||||
<style name="SearchScope" background="#f5fafd"/>
|
<style name="SearchScope" background="#f5fafd"/>
|
||||||
<style name="Parentheses" foreground="#ff0000" background="#b4eeb4"/>
|
<style name="Parentheses" foreground="#ff0000" background="#b4eeb4"/>
|
||||||
<style name="ParenthesesMismatch" background="#ff00ff"/>
|
<style name="ParenthesesMismatch" background="#ff00ff"/>
|
||||||
|
@@ -40,6 +40,8 @@
|
|||||||
<style name="Preprocessor" foreground="#409090"/>
|
<style name="Preprocessor" foreground="#409090"/>
|
||||||
<style name="RemovedLine" foreground="#ff0000"/>
|
<style name="RemovedLine" foreground="#ff0000"/>
|
||||||
<style name="SearchResult" foreground="#000000" background="#ffef0b"/>
|
<style name="SearchResult" foreground="#000000" background="#ffef0b"/>
|
||||||
|
<style name="SearchResultAlt1" foreground="#000000" background="#616161"/>
|
||||||
|
<style name="SearchResultAlt2" foreground="#000000" background="#ff6464"/>
|
||||||
<style name="SearchScope" foreground="#000000" background="#f8fafc"/>
|
<style name="SearchScope" foreground="#000000" background="#f8fafc"/>
|
||||||
<style name="Selection" foreground="#ffffff" background="#4e4e8f"/>
|
<style name="Selection" foreground="#ffffff" background="#4e4e8f"/>
|
||||||
<style name="Static" foreground="#cb6ecb"/>
|
<style name="Static" foreground="#cb6ecb"/>
|
||||||
|
@@ -14,6 +14,8 @@
|
|||||||
<style name="Selection" background="#11404c"/>
|
<style name="Selection" background="#11404c"/>
|
||||||
<style name="LineNumber" foreground="#888888" background="#272822"/>
|
<style name="LineNumber" foreground="#888888" background="#272822"/>
|
||||||
<style name="SearchResult" background="#555500"/>
|
<style name="SearchResult" background="#555500"/>
|
||||||
|
<style name="SearchResultAlt1" background="#aa0000"/>
|
||||||
|
<style name="SearchResultAlt2" foreground="#ffaaaa" background="#553636"/>
|
||||||
<style name="SearchScope" background="#222200"/>
|
<style name="SearchScope" background="#222200"/>
|
||||||
<style name="Parentheses" foreground="#ffffff" background="#11404c"/>
|
<style name="Parentheses" foreground="#ffffff" background="#11404c"/>
|
||||||
<style name="CurrentLine" background="#373737"/>
|
<style name="CurrentLine" background="#373737"/>
|
||||||
|
@@ -11,6 +11,8 @@
|
|||||||
<style name="Selection" foreground="#002b36" background="#586e75"/>
|
<style name="Selection" foreground="#002b36" background="#586e75"/>
|
||||||
<style name="LineNumber" foreground="#586e75" background="#073642"/>
|
<style name="LineNumber" foreground="#586e75" background="#073642"/>
|
||||||
<style name="SearchResult" background="#073642"/>
|
<style name="SearchResult" background="#073642"/>
|
||||||
|
<style name="SearchResultAlt1" background="#586e75"/>
|
||||||
|
<style name="SearchResultAlt2" background="#073642"/>
|
||||||
<style name="SearchScope" background="#073642"/>
|
<style name="SearchScope" background="#073642"/>
|
||||||
<style name="Parentheses" foreground="#dc322f" background="#586e75" bold="true"/>
|
<style name="Parentheses" foreground="#dc322f" background="#586e75" bold="true"/>
|
||||||
<style name="ParenthesesMismatch" foreground="#fdff2c" background="#d33682" bold="true"/>
|
<style name="ParenthesesMismatch" foreground="#fdff2c" background="#d33682" bold="true"/>
|
||||||
|
@@ -11,6 +11,8 @@
|
|||||||
<style name="Selection" foreground="#eee8d5" background="#93a1a1"/>
|
<style name="Selection" foreground="#eee8d5" background="#93a1a1"/>
|
||||||
<style name="LineNumber" foreground="#93a1a1" background="#eee8d5"/>
|
<style name="LineNumber" foreground="#93a1a1" background="#eee8d5"/>
|
||||||
<style name="SearchResult" background="#eee8d5"/>
|
<style name="SearchResult" background="#eee8d5"/>
|
||||||
|
<style name="SearchResultAlt1" background="#93a1a1"/>
|
||||||
|
<style name="SearchResultAlt2" background="#e0dbcb"/>
|
||||||
<style name="SearchScope" background="#073642"/>
|
<style name="SearchScope" background="#073642"/>
|
||||||
<style name="Parentheses" foreground="#dc322f" background="#93a1a1" bold="true"/>
|
<style name="Parentheses" foreground="#dc322f" background="#93a1a1" bold="true"/>
|
||||||
<style name="ParenthesesMismatch" foreground="#ffff00" background="#ff00ff" bold="true"/>
|
<style name="ParenthesesMismatch" foreground="#ffff00" background="#ff00ff" bold="true"/>
|
||||||
|
@@ -25,18 +25,41 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "../core_global.h"
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class SearchResultColor{
|
class CORE_EXPORT SearchResultColor {
|
||||||
public:
|
public:
|
||||||
|
enum class Style { Default, Alt1, Alt2 };
|
||||||
|
|
||||||
|
SearchResultColor() = default;
|
||||||
|
SearchResultColor(const QColor &textBg, const QColor &textFg,
|
||||||
|
const QColor &highlightBg, const QColor &highlightFg)
|
||||||
|
: textBackground(textBg), textForeground(textFg),
|
||||||
|
highlightBackground(highlightBg), highlightForeground(highlightFg)
|
||||||
|
{
|
||||||
|
if (!highlightBackground.isValid())
|
||||||
|
highlightBackground = textBackground;
|
||||||
|
if (!highlightForeground.isValid())
|
||||||
|
highlightForeground = textForeground;
|
||||||
|
}
|
||||||
|
|
||||||
QColor textBackground;
|
QColor textBackground;
|
||||||
QColor textForeground;
|
QColor textForeground;
|
||||||
QColor highlightBackground;
|
QColor highlightBackground;
|
||||||
QColor highlightForeground;
|
QColor highlightForeground;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
|
inline uint qHash(SearchResultColor::Style style)
|
||||||
|
{
|
||||||
|
return QT_PREPEND_NAMESPACE(qHash(int(style)));
|
||||||
|
}
|
||||||
|
|
||||||
|
using SearchResultColors = QHash<SearchResultColor::Style, SearchResultColor>;
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "searchresultcolor.h"
|
||||||
|
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
@@ -94,6 +96,7 @@ public:
|
|||||||
QVariant userData; // user data for identification of the item
|
QVariant userData; // user data for identification of the item
|
||||||
Search::TextRange mainRange;
|
Search::TextRange mainRange;
|
||||||
bool useTextEditorFont = false;
|
bool useTextEditorFont = false;
|
||||||
|
SearchResultColor::Style style = SearchResultColor::Style::Default;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
@@ -69,11 +69,11 @@ void SearchResultTreeModel::setShowReplaceUI(bool show)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchResultTreeModel::setTextEditorFont(const QFont &font, const SearchResultColor &color)
|
void SearchResultTreeModel::setTextEditorFont(const QFont &font, const SearchResultColors &colors)
|
||||||
{
|
{
|
||||||
emit layoutAboutToBeChanged();
|
emit layoutAboutToBeChanged();
|
||||||
m_textEditorFont = font;
|
m_textEditorFont = font;
|
||||||
m_color = color;
|
m_colors = colors;
|
||||||
emit layoutChanged();
|
emit layoutChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,10 +248,10 @@ QVariant SearchResultTreeModel::data(const SearchResultTreeItem *row, int role)
|
|||||||
result = QVariant();
|
result = QVariant();
|
||||||
break;
|
break;
|
||||||
case Qt::ForegroundRole:
|
case Qt::ForegroundRole:
|
||||||
result = m_color.textForeground;
|
result = m_colors.value(row->item.style).textForeground;
|
||||||
break;
|
break;
|
||||||
case Qt::BackgroundRole:
|
case Qt::BackgroundRole:
|
||||||
result = m_color.textBackground;
|
result = m_colors.value(row->item.style).textBackground;
|
||||||
break;
|
break;
|
||||||
case ItemDataRoles::ResultLineRole:
|
case ItemDataRoles::ResultLineRole:
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
@@ -267,10 +267,10 @@ QVariant SearchResultTreeModel::data(const SearchResultTreeItem *row, int role)
|
|||||||
result = row->item.icon;
|
result = row->item.icon;
|
||||||
break;
|
break;
|
||||||
case ItemDataRoles::ResultHighlightBackgroundColor:
|
case ItemDataRoles::ResultHighlightBackgroundColor:
|
||||||
result = m_color.highlightBackground;
|
result = m_colors.value(row->item.style).highlightBackground;
|
||||||
break;
|
break;
|
||||||
case ItemDataRoles::ResultHighlightForegroundColor:
|
case ItemDataRoles::ResultHighlightForegroundColor:
|
||||||
result = m_color.highlightForeground;
|
result = m_colors.value(row->item.style).highlightForeground;
|
||||||
break;
|
break;
|
||||||
case ItemDataRoles::ResultBeginColumnNumberRole:
|
case ItemDataRoles::ResultBeginColumnNumberRole:
|
||||||
result = row->item.mainRange.begin.column;
|
result = row->item.mainRange.begin.column;
|
||||||
|
@@ -45,7 +45,7 @@ public:
|
|||||||
~SearchResultTreeModel() override;
|
~SearchResultTreeModel() override;
|
||||||
|
|
||||||
void setShowReplaceUI(bool show);
|
void setShowReplaceUI(bool show);
|
||||||
void setTextEditorFont(const QFont &font, const SearchResultColor &color);
|
void setTextEditorFont(const QFont &font, const SearchResultColors &colors);
|
||||||
|
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
||||||
@@ -80,7 +80,7 @@ private:
|
|||||||
|
|
||||||
SearchResultTreeItem *m_rootItem;
|
SearchResultTreeItem *m_rootItem;
|
||||||
SearchResultTreeItem *m_currentParent;
|
SearchResultTreeItem *m_currentParent;
|
||||||
SearchResultColor m_color;
|
SearchResultColors m_colors;
|
||||||
QModelIndex m_currentIndex;
|
QModelIndex m_currentIndex;
|
||||||
QStringList m_currentPath; // the path that belongs to the current parent
|
QStringList m_currentPath; // the path that belongs to the current parent
|
||||||
QFont m_textEditorFont;
|
QFont m_textEditorFont;
|
||||||
|
@@ -57,12 +57,12 @@ void SearchResultTreeView::setAutoExpandResults(bool expand)
|
|||||||
m_autoExpandResults = expand;
|
m_autoExpandResults = expand;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchResultTreeView::setTextEditorFont(const QFont &font, const SearchResultColor &color)
|
void SearchResultTreeView::setTextEditorFont(const QFont &font, const SearchResultColors &colors)
|
||||||
{
|
{
|
||||||
m_model->setTextEditorFont(font, color);
|
m_model->setTextEditorFont(font, colors);
|
||||||
|
|
||||||
QPalette p;
|
QPalette p;
|
||||||
p.setColor(QPalette::Base, color.textBackground);
|
p.setColor(QPalette::Base, colors.value(SearchResultColor::Style::Default).textBackground);
|
||||||
setPalette(p);
|
setPalette(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -30,10 +30,11 @@
|
|||||||
#include <utils/itemviews.h>
|
#include <utils/itemviews.h>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
class SearchResultColor;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class SearchResultTreeModel;
|
class SearchResultTreeModel;
|
||||||
class SearchResultColor;
|
|
||||||
|
|
||||||
class SearchResultTreeView : public Utils::TreeView
|
class SearchResultTreeView : public Utils::TreeView
|
||||||
{
|
{
|
||||||
@@ -43,7 +44,7 @@ public:
|
|||||||
explicit SearchResultTreeView(QWidget *parent = nullptr);
|
explicit SearchResultTreeView(QWidget *parent = nullptr);
|
||||||
|
|
||||||
void setAutoExpandResults(bool expand);
|
void setAutoExpandResults(bool expand);
|
||||||
void setTextEditorFont(const QFont &font, const SearchResultColor &color);
|
void setTextEditorFont(const QFont &font, const SearchResultColors &colors);
|
||||||
void setTabWidth(int tabWidth);
|
void setTabWidth(int tabWidth);
|
||||||
|
|
||||||
SearchResultTreeModel *model() const;
|
SearchResultTreeModel *model() const;
|
||||||
|
@@ -246,7 +246,8 @@ void SearchResultWidget::setAdditionalReplaceWidget(QWidget *widget)
|
|||||||
void SearchResultWidget::addResult(const QString &fileName,
|
void SearchResultWidget::addResult(const QString &fileName,
|
||||||
const QString &rowText,
|
const QString &rowText,
|
||||||
Search::TextRange mainRange,
|
Search::TextRange mainRange,
|
||||||
const QVariant &userData)
|
const QVariant &userData,
|
||||||
|
SearchResultColor::Style style)
|
||||||
{
|
{
|
||||||
SearchResultItem item;
|
SearchResultItem item;
|
||||||
item.path = QStringList({QDir::toNativeSeparators(fileName)});
|
item.path = QStringList({QDir::toNativeSeparators(fileName)});
|
||||||
@@ -254,6 +255,7 @@ void SearchResultWidget::addResult(const QString &fileName,
|
|||||||
item.text = rowText;
|
item.text = rowText;
|
||||||
item.useTextEditorFont = true;
|
item.useTextEditorFont = true;
|
||||||
item.userData = userData;
|
item.userData = userData;
|
||||||
|
item.style = style;
|
||||||
addResults(QList<SearchResultItem>() << item, SearchResult::AddOrdered);
|
addResults(QList<SearchResultItem>() << item, SearchResult::AddOrdered);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,9 +369,9 @@ void SearchResultWidget::notifyVisibilityChanged(bool visible)
|
|||||||
emit visibilityChanged(visible);
|
emit visibilityChanged(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchResultWidget::setTextEditorFont(const QFont &font, const SearchResultColor &color)
|
void SearchResultWidget::setTextEditorFont(const QFont &font, const SearchResultColors &colors)
|
||||||
{
|
{
|
||||||
m_searchResultTreeView->setTextEditorFont(font, color);
|
m_searchResultTreeView->setTextEditorFont(font, colors);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchResultWidget::setTabWidth(int tabWidth)
|
void SearchResultWidget::setTabWidth(int tabWidth)
|
||||||
|
@@ -40,10 +40,9 @@ class QCheckBox;
|
|||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
class SearchResultTreeView;
|
class SearchResultTreeView;
|
||||||
class SearchResultColor;
|
|
||||||
|
|
||||||
class SearchResultWidget : public QWidget
|
class SearchResultWidget : public QWidget
|
||||||
{
|
{
|
||||||
@@ -59,7 +58,8 @@ public:
|
|||||||
void addResult(const QString &fileName,
|
void addResult(const QString &fileName,
|
||||||
const QString &lineText,
|
const QString &lineText,
|
||||||
Search::TextRange mainRange,
|
Search::TextRange mainRange,
|
||||||
const QVariant &userData = QVariant());
|
const QVariant &userData = QVariant(),
|
||||||
|
SearchResultColor::Style style = SearchResultColor::Style::Default);
|
||||||
void addResults(const QList<SearchResultItem> &items, SearchResult::AddMode mode);
|
void addResults(const QList<SearchResultItem> &items, SearchResult::AddMode mode);
|
||||||
|
|
||||||
int count() const;
|
int count() const;
|
||||||
@@ -76,7 +76,7 @@ public:
|
|||||||
|
|
||||||
void notifyVisibilityChanged(bool visible);
|
void notifyVisibilityChanged(bool visible);
|
||||||
|
|
||||||
void setTextEditorFont(const QFont &font, const SearchResultColor &color);
|
void setTextEditorFont(const QFont &font, const SearchResultColors &colors);
|
||||||
void setTabWidth(int tabWidth);
|
void setTabWidth(int tabWidth);
|
||||||
|
|
||||||
void setAutoExpandResults(bool expand);
|
void setAutoExpandResults(bool expand);
|
||||||
|
@@ -25,7 +25,6 @@
|
|||||||
|
|
||||||
#include "searchresultwindow.h"
|
#include "searchresultwindow.h"
|
||||||
#include "searchresultwidget.h"
|
#include "searchresultwidget.h"
|
||||||
#include "searchresultcolor.h"
|
|
||||||
#include "textfindconstants.h"
|
#include "textfindconstants.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
@@ -126,7 +125,7 @@ namespace Internal {
|
|||||||
QList<SearchResult *> m_searchResults;
|
QList<SearchResult *> m_searchResults;
|
||||||
int m_currentIndex;
|
int m_currentIndex;
|
||||||
QFont m_font;
|
QFont m_font;
|
||||||
SearchResultColor m_color;
|
SearchResultColors m_colors;
|
||||||
int m_tabWidth;
|
int m_tabWidth;
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -503,7 +502,7 @@ SearchResult *SearchResultWindow::startNewSearch(const QString &label,
|
|||||||
d, &SearchResultWindowPrivate::moveWidgetToTop);
|
d, &SearchResultWindowPrivate::moveWidgetToTop);
|
||||||
connect(widget, &SearchResultWidget::requestPopup,
|
connect(widget, &SearchResultWidget::requestPopup,
|
||||||
d, &SearchResultWindowPrivate::popupRequested);
|
d, &SearchResultWindowPrivate::popupRequested);
|
||||||
widget->setTextEditorFont(d->m_font, d->m_color);
|
widget->setTextEditorFont(d->m_font, d->m_colors);
|
||||||
widget->setTabWidth(d->m_tabWidth);
|
widget->setTabWidth(d->m_tabWidth);
|
||||||
widget->setSupportPreserveCase(preserveCaseMode == PreserveCaseEnabled);
|
widget->setSupportPreserveCase(preserveCaseMode == PreserveCaseEnabled);
|
||||||
bool supportsReplace = searchOrSearchAndReplace != SearchOnly;
|
bool supportsReplace = searchOrSearchAndReplace != SearchOnly;
|
||||||
@@ -574,25 +573,12 @@ void SearchResultWindow::setFocus()
|
|||||||
/*!
|
/*!
|
||||||
\internal
|
\internal
|
||||||
*/
|
*/
|
||||||
void SearchResultWindow::setTextEditorFont(const QFont &font,
|
void SearchResultWindow::setTextEditorFont(const QFont &font, const SearchResultColors &colors)
|
||||||
const QColor &textForegroundColor,
|
|
||||||
const QColor &textBackgroundColor,
|
|
||||||
const QColor &highlightForegroundColor,
|
|
||||||
const QColor &highlightBackgroundColor)
|
|
||||||
{
|
{
|
||||||
d->m_font = font;
|
d->m_font = font;
|
||||||
Internal::SearchResultColor color;
|
d->m_colors = colors;
|
||||||
color.textBackground = textBackgroundColor;
|
|
||||||
color.textForeground = textForegroundColor;
|
|
||||||
color.highlightBackground = highlightBackgroundColor.isValid()
|
|
||||||
? highlightBackgroundColor
|
|
||||||
: textBackgroundColor;
|
|
||||||
color.highlightForeground = highlightForegroundColor.isValid()
|
|
||||||
? highlightForegroundColor
|
|
||||||
: textForegroundColor;
|
|
||||||
d->m_color = color;
|
|
||||||
foreach (Internal::SearchResultWidget *widget, d->m_searchResultWidgets)
|
foreach (Internal::SearchResultWidget *widget, d->m_searchResultWidgets)
|
||||||
widget->setTextEditorFont(font, color);
|
widget->setTextEditorFont(font, colors);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -796,7 +782,8 @@ void SearchResult::setAdditionalReplaceWidget(QWidget *widget)
|
|||||||
\sa addResults()
|
\sa addResults()
|
||||||
*/
|
*/
|
||||||
void SearchResult::addResult(const QString &fileName, int lineNumber, const QString &lineText,
|
void SearchResult::addResult(const QString &fileName, int lineNumber, const QString &lineText,
|
||||||
int searchTermStart, int searchTermLength, const QVariant &userData)
|
int searchTermStart, int searchTermLength, const QVariant &userData,
|
||||||
|
SearchResultColor::Style style)
|
||||||
{
|
{
|
||||||
Search::TextRange mainRange;
|
Search::TextRange mainRange;
|
||||||
mainRange.begin.line = lineNumber;
|
mainRange.begin.line = lineNumber;
|
||||||
@@ -804,7 +791,7 @@ void SearchResult::addResult(const QString &fileName, int lineNumber, const QStr
|
|||||||
mainRange.end.line = mainRange.begin.line;
|
mainRange.end.line = mainRange.begin.line;
|
||||||
mainRange.end.column = mainRange.begin.column + searchTermLength;
|
mainRange.end.column = mainRange.begin.column + searchTermLength;
|
||||||
|
|
||||||
m_widget->addResult(fileName, lineText, mainRange, userData);
|
m_widget->addResult(fileName, lineText, mainRange, userData, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -822,9 +809,10 @@ void SearchResult::addResult(const QString &fileName, int lineNumber, const QStr
|
|||||||
void SearchResult::addResult(const QString &fileName,
|
void SearchResult::addResult(const QString &fileName,
|
||||||
const QString &lineText,
|
const QString &lineText,
|
||||||
Search::TextRange mainRange,
|
Search::TextRange mainRange,
|
||||||
const QVariant &userData)
|
const QVariant &userData,
|
||||||
|
SearchResultColor::Style style)
|
||||||
{
|
{
|
||||||
m_widget->addResult(fileName, lineText, mainRange, userData);
|
m_widget->addResult(fileName, lineText, mainRange, userData, style);
|
||||||
emit countChanged(m_widget->count());
|
emit countChanged(m_widget->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "searchresultcolor.h"
|
||||||
#include "searchresultitem.h"
|
#include "searchresultitem.h"
|
||||||
|
|
||||||
#include <coreplugin/ioutputpane.h>
|
#include <coreplugin/ioutputpane.h>
|
||||||
@@ -68,11 +69,13 @@ public slots:
|
|||||||
const QString &lineText,
|
const QString &lineText,
|
||||||
int searchTermStart,
|
int searchTermStart,
|
||||||
int searchTermLength,
|
int searchTermLength,
|
||||||
const QVariant &userData = QVariant());
|
const QVariant &userData = QVariant(),
|
||||||
|
SearchResultColor::Style style = SearchResultColor::Style::Default);
|
||||||
void addResult(const QString &fileName,
|
void addResult(const QString &fileName,
|
||||||
const QString &lineText,
|
const QString &lineText,
|
||||||
Search::TextRange mainRange,
|
Search::TextRange mainRange,
|
||||||
const QVariant &userData = QVariant());
|
const QVariant &userData = QVariant(),
|
||||||
|
SearchResultColor::Style style = SearchResultColor::Style::Default);
|
||||||
void addResults(const QList<SearchResultItem> &items, AddMode mode);
|
void addResults(const QList<SearchResultItem> &items, AddMode mode);
|
||||||
void finishSearch(bool canceled);
|
void finishSearch(bool canceled);
|
||||||
void setTextToReplace(const QString &textToReplace);
|
void setTextToReplace(const QString &textToReplace);
|
||||||
@@ -137,11 +140,7 @@ public:
|
|||||||
void goToPrev() override;
|
void goToPrev() override;
|
||||||
bool canNavigate() const override;
|
bool canNavigate() const override;
|
||||||
|
|
||||||
void setTextEditorFont(const QFont &font,
|
void setTextEditorFont(const QFont &font, const SearchResultColors &colors);
|
||||||
const QColor &textForegroundColor,
|
|
||||||
const QColor &textBackgroundColor,
|
|
||||||
const QColor &highlightForegroundColor,
|
|
||||||
const QColor &highlightBackgroundColor);
|
|
||||||
void setTabWidth(int width);
|
void setTabWidth(int width);
|
||||||
void openNewSearchPanel();
|
void openNewSearchPanel();
|
||||||
|
|
||||||
|
@@ -551,13 +551,23 @@ static void displayResults(SearchResult *search, QFutureWatcher<CPlusPlus::Usage
|
|||||||
{
|
{
|
||||||
CppFindReferencesParameters parameters = search->userData().value<CppFindReferencesParameters>();
|
CppFindReferencesParameters parameters = search->userData().value<CppFindReferencesParameters>();
|
||||||
|
|
||||||
|
static const auto colorStyleForUsageType = [](CPlusPlus::Usage::Type type) {
|
||||||
|
switch (type) {
|
||||||
|
case CPlusPlus::Usage::Type::Read:
|
||||||
|
return SearchResultColor::Style::Alt1;
|
||||||
|
case CPlusPlus::Usage::Type::Write:
|
||||||
|
case CPlusPlus::Usage::Type::WritableRef:
|
||||||
|
return SearchResultColor::Style::Alt2;
|
||||||
|
case CPlusPlus::Usage::Type::Declaration:
|
||||||
|
case CPlusPlus::Usage::Type::Other:
|
||||||
|
return SearchResultColor::Style::Default;
|
||||||
|
}
|
||||||
|
return SearchResultColor::Style::Default; // For dumb compilers.
|
||||||
|
};
|
||||||
for (int index = first; index != last; ++index) {
|
for (int index = first; index != last; ++index) {
|
||||||
CPlusPlus::Usage result = watcher->future().resultAt(index);
|
const CPlusPlus::Usage result = watcher->future().resultAt(index);
|
||||||
search->addResult(result.path.toString(),
|
search->addResult(result.path.toString(), result.line, result.lineText,
|
||||||
result.line,
|
result.col, result.len, {}, colorStyleForUsageType(result.type));
|
||||||
result.lineText,
|
|
||||||
result.col,
|
|
||||||
result.len);
|
|
||||||
|
|
||||||
if (parameters.prettySymbolName.isEmpty())
|
if (parameters.prettySymbolName.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
@@ -151,6 +151,8 @@ static bool isOverlayCategory(TextStyle category)
|
|||||||
return category == C_OCCURRENCES
|
return category == C_OCCURRENCES
|
||||||
|| category == C_OCCURRENCES_RENAME
|
|| category == C_OCCURRENCES_RENAME
|
||||||
|| category == C_SEARCH_RESULT
|
|| category == C_SEARCH_RESULT
|
||||||
|
|| category == C_SEARCH_RESULT_ALT1
|
||||||
|
|| category == C_SEARCH_RESULT_ALT2
|
||||||
|| category == C_PARENTHESES_MISMATCH;
|
|| category == C_PARENTHESES_MISMATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -340,9 +340,9 @@ QColor FormatDescription::defaultBackground(TextStyle id)
|
|||||||
return col;
|
return col;
|
||||||
} else if (id == C_SELECTION) {
|
} else if (id == C_SELECTION) {
|
||||||
return Utils::Theme::initialPalette().color(QPalette::Highlight);
|
return Utils::Theme::initialPalette().color(QPalette::Highlight);
|
||||||
} else if (id == C_OCCURRENCES) {
|
} else if (id == C_OCCURRENCES || id == C_SEARCH_RESULT_ALT1) {
|
||||||
return QColor(180, 180, 180);
|
return QColor(180, 180, 180);
|
||||||
} else if (id == C_OCCURRENCES_RENAME) {
|
} else if (id == C_OCCURRENCES_RENAME || id == C_SEARCH_RESULT_ALT2) {
|
||||||
return QColor(255, 100, 100);
|
return QColor(255, 100, 100);
|
||||||
} else if (id == C_DISABLED_CODE) {
|
} else if (id == C_DISABLED_CODE) {
|
||||||
return QColor(239, 239, 239);
|
return QColor(239, 239, 239);
|
||||||
|
@@ -39,6 +39,8 @@ const char *nameForStyle(TextStyle style)
|
|||||||
case C_SELECTION: return "Selection";
|
case C_SELECTION: return "Selection";
|
||||||
case C_LINE_NUMBER: return "LineNumber";
|
case C_LINE_NUMBER: return "LineNumber";
|
||||||
case C_SEARCH_RESULT: return "SearchResult";
|
case C_SEARCH_RESULT: return "SearchResult";
|
||||||
|
case C_SEARCH_RESULT_ALT1: return "SearchResultAlt1";
|
||||||
|
case C_SEARCH_RESULT_ALT2: return "SearchResultAlt2";
|
||||||
case C_SEARCH_SCOPE: return "SearchScope";
|
case C_SEARCH_SCOPE: return "SearchScope";
|
||||||
case C_PARENTHESES: return "Parentheses";
|
case C_PARENTHESES: return "Parentheses";
|
||||||
case C_PARENTHESES_MISMATCH:return "ParenthesesMismatch";
|
case C_PARENTHESES_MISMATCH:return "ParenthesesMismatch";
|
||||||
|
@@ -39,6 +39,8 @@ enum TextStyle : quint8 {
|
|||||||
C_SELECTION,
|
C_SELECTION,
|
||||||
C_LINE_NUMBER,
|
C_LINE_NUMBER,
|
||||||
C_SEARCH_RESULT,
|
C_SEARCH_RESULT,
|
||||||
|
C_SEARCH_RESULT_ALT1,
|
||||||
|
C_SEARCH_RESULT_ALT2,
|
||||||
C_SEARCH_SCOPE,
|
C_SEARCH_SCOPE,
|
||||||
C_PARENTHESES,
|
C_PARENTHESES,
|
||||||
C_PARENTHESES_MISMATCH,
|
C_PARENTHESES_MISMATCH,
|
||||||
|
@@ -250,11 +250,20 @@ ExtensionSystem::IPlugin::ShutdownFlag TextEditorPlugin::aboutToShutdown()
|
|||||||
void TextEditorPluginPrivate::updateSearchResultsFont(const FontSettings &settings)
|
void TextEditorPluginPrivate::updateSearchResultsFont(const FontSettings &settings)
|
||||||
{
|
{
|
||||||
if (auto window = SearchResultWindow::instance()) {
|
if (auto window = SearchResultWindow::instance()) {
|
||||||
|
const Format textFormat = settings.formatFor(C_TEXT);
|
||||||
|
const Format defaultResultFormat = settings.formatFor(C_SEARCH_RESULT);
|
||||||
|
const Format alt1ResultFormat = settings.formatFor(C_SEARCH_RESULT_ALT1);
|
||||||
|
const Format alt2ResultFormat = settings.formatFor(C_SEARCH_RESULT_ALT2);
|
||||||
window->setTextEditorFont(QFont(settings.family(), settings.fontSize() * settings.fontZoom() / 100),
|
window->setTextEditorFont(QFont(settings.family(), settings.fontSize() * settings.fontZoom() / 100),
|
||||||
settings.formatFor(C_TEXT).foreground(),
|
{std::make_pair(SearchResultColor::Style::Default,
|
||||||
settings.formatFor(C_TEXT).background(),
|
SearchResultColor(textFormat.background(), textFormat.foreground(),
|
||||||
settings.formatFor(C_SEARCH_RESULT).foreground(),
|
defaultResultFormat.background(), defaultResultFormat.foreground())),
|
||||||
settings.formatFor(C_SEARCH_RESULT).background());
|
std::make_pair(SearchResultColor::Style::Alt1,
|
||||||
|
SearchResultColor(textFormat.background(), textFormat.foreground(),
|
||||||
|
alt1ResultFormat.background(), alt1ResultFormat.foreground())),
|
||||||
|
std::make_pair(SearchResultColor::Style::Alt2,
|
||||||
|
SearchResultColor(textFormat.background(), textFormat.foreground(),
|
||||||
|
alt2ResultFormat.background(), alt2ResultFormat.foreground()))});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -104,6 +104,14 @@ FormatDescriptions TextEditorSettingsPrivate::initialFormats()
|
|||||||
formatDescr.emplace_back(C_SEARCH_RESULT, tr("Search Result"),
|
formatDescr.emplace_back(C_SEARCH_RESULT, tr("Search Result"),
|
||||||
tr("Highlighted search results inside the editor."),
|
tr("Highlighted search results inside the editor."),
|
||||||
FormatDescription::ShowBackgroundControl);
|
FormatDescription::ShowBackgroundControl);
|
||||||
|
formatDescr.emplace_back(C_SEARCH_RESULT_ALT1, tr("Search Result (alternative 1)"),
|
||||||
|
tr("Highlighted search results inside the editor.\n"
|
||||||
|
"Used to mark read accesses to C++ symbols."),
|
||||||
|
FormatDescription::ShowBackgroundControl);
|
||||||
|
formatDescr.emplace_back(C_SEARCH_RESULT_ALT2, tr("Search Result (alternative 2)"),
|
||||||
|
tr("Highlighted search results inside the editor.\n"
|
||||||
|
"Used to mark write accesses to C++ symbols."),
|
||||||
|
FormatDescription::ShowBackgroundControl);
|
||||||
formatDescr.emplace_back(C_SEARCH_SCOPE, tr("Search Scope"),
|
formatDescr.emplace_back(C_SEARCH_SCOPE, tr("Search Scope"),
|
||||||
tr("Section where the pattern is searched in."),
|
tr("Section where the pattern is searched in."),
|
||||||
FormatDescription::ShowBackgroundControl);
|
FormatDescription::ShowBackgroundControl);
|
||||||
|
Reference in New Issue
Block a user