ProjectExplorer: Allow text filtering in message pane

Change-Id: I7b70f7056c757fcb13634021b8e2dcf0b3a34097
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Christian Kandeler
2019-05-14 14:33:08 +02:00
parent 51afb04674
commit 5bbed92061
3 changed files with 19 additions and 8 deletions

View File

@@ -53,6 +53,8 @@ MessageOutputWindow::MessageOutputWindow()
QColor activeHighlightedText = p.color(QPalette::Active, QPalette::HighlightedText);
p.setColor(QPalette::HighlightedText, activeHighlightedText);
m_widget->setPalette(p);
m_widget->setHighlightBgColor(p.color(QPalette::Highlight));
m_widget->setHighlightTextColor(p.color(QPalette::HighlightedText));
connect(this, &IOutputPane::zoomIn, m_widget, &Core::OutputWindow::zoomIn);
connect(this, &IOutputPane::zoomOut, m_widget, &Core::OutputWindow::zoomOut);
@@ -62,6 +64,9 @@ MessageOutputWindow::MessageOutputWindow()
auto agg = new Aggregation::Aggregate;
agg->add(m_widget);
agg->add(new BaseTextFind(m_widget));
setupFilterUi("MessageOutputPane.Filter");
setFilteringEnabled(true);
}
MessageOutputWindow::~MessageOutputWindow()
@@ -139,5 +144,10 @@ bool MessageOutputWindow::canNavigate() const
return false;
}
void MessageOutputWindow::updateFilter()
{
m_widget->setFilterText(filterText());
}
} // namespace Internal
} // namespace Core

View File

@@ -64,6 +64,8 @@ public:
bool canNavigate() const override;
private:
void updateFilter() override;
OutputWindow *m_widget;
};

View File

@@ -74,6 +74,7 @@ public:
QTextCursor cursor;
QString filterText;
QTextBlock lastFilteredBlock;
QPalette originalPalette;
OutputWindow::FilterModeFlags filterMode = OutputWindow::FilterModeFlag::Default;
};
@@ -297,21 +298,19 @@ void OutputWindow::setFilterText(const QString &filterText)
// Update textedit's background color
if (filterText.isEmpty()) {
setPalette({});
setPalette(d->originalPalette);
setReadOnly(d->m_originalReadOnly);
} else {
if (filterTextWasEmpty) {
d->m_originalReadOnly = isReadOnly();
d->originalPalette = palette();
}
QPalette pal;
pal.setColor(QPalette::Active, QPalette::Base, d->m_highlightBgColor);
pal.setColor(QPalette::Inactive, QPalette::Base, d->m_highlightBgColor.darker(120));
pal.setColor(QPalette::Active, QPalette::Text, d->m_highlightTextColor);
pal.setColor(QPalette::Inactive, QPalette::Text, d->m_highlightTextColor.darker(120));
setPalette(pal);
}
if (filterText.isEmpty()) {
setReadOnly(d->m_originalReadOnly);
} else {
if (filterTextWasEmpty)
d->m_originalReadOnly = isReadOnly();
setReadOnly(true);
}