forked from qt-creator/qt-creator
Output panes: Improve the way to signal that filtering is active
At the moment, background and foreground colors of an output pane are changed (via the widget's palette) when filtering is active, in order to make it clear to the user that the output is being tampered with. There are several problems there: - The chosen background color is quite garish. - More importantly, the palette change has no effect in the compile and app output panes, because their output is explicitly formatted and thus not affected by the general text color change. As a result, the output may no longer be readable. We fix this by choosing a less intrusive approach that simply darkens (or lightens) the pane's background color a bit when filtering is active. This is still clearly visible to the user. Change-Id: I41e053b4b218be57fe7655e314d4ebf93f59f505 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -53,8 +53,6 @@ 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);
|
||||
|
@@ -59,8 +59,6 @@ public:
|
||||
|
||||
IContext *outputWindowContext = nullptr;
|
||||
Utils::OutputFormatter *formatter = nullptr;
|
||||
QColor highlightBgColor;
|
||||
QColor highlightTextColor;
|
||||
QString settingsKey;
|
||||
|
||||
bool enforceNewline = false;
|
||||
@@ -273,16 +271,6 @@ void OutputWindow::setWheelZoomEnabled(bool enabled)
|
||||
d->zoomEnabled = enabled;
|
||||
}
|
||||
|
||||
void OutputWindow::setHighlightBgColor(const QColor &bgColor)
|
||||
{
|
||||
d->highlightBgColor = bgColor;
|
||||
}
|
||||
|
||||
void OutputWindow::setHighlightTextColor(const QColor &textColor)
|
||||
{
|
||||
d->highlightTextColor = textColor;
|
||||
}
|
||||
|
||||
void OutputWindow::updateFilterProperties(const QString &filterText,
|
||||
Qt::CaseSensitivity caseSensitivity, bool isRegexp)
|
||||
{
|
||||
@@ -297,21 +285,22 @@ void OutputWindow::updateFilterProperties(const QString &filterText,
|
||||
d->filterText = filterText;
|
||||
|
||||
// Update textedit's background color
|
||||
if (filterText.isEmpty()) {
|
||||
if (filterText.isEmpty() && !filterTextWasEmpty) {
|
||||
setPalette(d->originalPalette);
|
||||
setReadOnly(d->originalReadOnly);
|
||||
} else {
|
||||
if (filterTextWasEmpty) {
|
||||
d->originalReadOnly = isReadOnly();
|
||||
d->originalPalette = palette();
|
||||
}
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Active, QPalette::Base, d->highlightBgColor);
|
||||
pal.setColor(QPalette::Inactive, QPalette::Base, d->highlightBgColor.darker(120));
|
||||
pal.setColor(QPalette::Active, QPalette::Text, d->highlightTextColor);
|
||||
pal.setColor(QPalette::Inactive, QPalette::Text, d->highlightTextColor.darker(120));
|
||||
setPalette(pal);
|
||||
if (!filterText.isEmpty() && filterTextWasEmpty) {
|
||||
d->originalReadOnly = isReadOnly();
|
||||
setReadOnly(true);
|
||||
const auto newBgColor = [this] {
|
||||
const QColor currentColor = palette().color(QPalette::Base);
|
||||
const int factor = 120;
|
||||
return currentColor.value() < 128 ? currentColor.lighter(factor)
|
||||
: currentColor.darker(factor);
|
||||
};
|
||||
QPalette p = palette();
|
||||
p.setColor(QPalette::Base, newBgColor());
|
||||
setPalette(p);
|
||||
}
|
||||
}
|
||||
d->filterMode = flags;
|
||||
|
@@ -76,8 +76,6 @@ public:
|
||||
float fontZoom() const;
|
||||
void setFontZoom(float zoom);
|
||||
void setWheelZoomEnabled(bool enabled);
|
||||
void setHighlightBgColor(const QColor &bgColor);
|
||||
void setHighlightTextColor(const QColor &textColor);
|
||||
|
||||
void updateFilterProperties(const QString &filterText, Qt::CaseSensitivity caseSensitivity, bool regexp);
|
||||
|
||||
|
@@ -426,7 +426,6 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc)
|
||||
}
|
||||
// Create new
|
||||
static int counter = 0;
|
||||
const TextEditor::FontSettings &fs = TextEditor::TextEditorSettings::fontSettings();
|
||||
Core::Id contextId = Core::Id(C_APP_OUTPUT).withSuffix(counter++);
|
||||
Core::Context context(contextId);
|
||||
Core::OutputWindow *ow = new Core::OutputWindow(context, SETTINGS_KEY, m_tabWidget);
|
||||
@@ -434,10 +433,6 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc)
|
||||
ow->setWindowIcon(Icons::WINDOW.icon());
|
||||
ow->setWordWrapEnabled(m_settings.wrapOutput);
|
||||
ow->setMaxCharCount(m_settings.maxCharCount);
|
||||
ow->setHighlightBgColor(fs.toTextCharFormat(TextEditor::C_SEARCH_RESULT)
|
||||
.background().color());
|
||||
ow->setHighlightTextColor(fs.toTextCharFormat(TextEditor::C_SEARCH_RESULT)
|
||||
.foreground().color());
|
||||
|
||||
auto updateFontSettings = [ow] {
|
||||
ow->setBaseFont(TextEditor::TextEditorSettings::fontSettings().font());
|
||||
|
@@ -172,11 +172,6 @@ CompileOutputWindow::CompileOutputWindow(QAction *cancelBuildAction) :
|
||||
|
||||
updateFontSettings();
|
||||
updateZoomEnabled();
|
||||
const TextEditor::FontSettings &fs = TextEditor::TextEditorSettings::fontSettings();
|
||||
m_outputWindow->setHighlightBgColor(fs.toTextCharFormat(TextEditor::C_SEARCH_RESULT)
|
||||
.background().color());
|
||||
m_outputWindow->setHighlightTextColor(fs.toTextCharFormat(TextEditor::C_SEARCH_RESULT)
|
||||
.foreground().color());
|
||||
setupFilterUi("CompileOutputPane.Filter");
|
||||
setFilteringEnabled(true);
|
||||
|
||||
|
Reference in New Issue
Block a user