LogView changes - registerCategory() now take two QBrush: text and background. If NoBrush the no changes in colors
This commit is contained in:
@@ -97,7 +97,7 @@ int LogView::linesLimit() const {
|
||||
}
|
||||
|
||||
|
||||
void LogView::registerCategory(const QString & label, QString keyword, const QImage & icon, QColor color, bool bold) {
|
||||
void LogView::registerCategory(const QString & label, QString keyword, const QImage & icon, QBrush text_brush, QBrush background, bool bold) {
|
||||
QRegularExpression regexp(keyword,
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
||||
QRegularExpression::PatternOptions(QRegularExpression::CaseInsensitiveOption)
|
||||
@@ -105,18 +105,19 @@ void LogView::registerCategory(const QString & label, QString keyword, const QIm
|
||||
Qt::CaseInsensitive
|
||||
#endif
|
||||
);
|
||||
registerCategory(label, regexp, icon, color, bold);
|
||||
registerCategory(label, regexp, icon, text_brush, background, bold);
|
||||
}
|
||||
|
||||
|
||||
void LogView::registerCategory(const QString & label, QRegularExpression regexp, const QImage & icon, QColor color, bool bold) {
|
||||
void LogView::registerCategory(const QString & label, QRegularExpression regexp, const QImage & icon, QBrush text_brush, QBrush background, bool bold) {
|
||||
if (!regexp.isValid() || regexp.pattern().isEmpty()) return;
|
||||
removeCategory(regexp);
|
||||
Category c;
|
||||
c.regexp = regexp;
|
||||
c.label = label;
|
||||
c.image = icon;
|
||||
c.color = color;
|
||||
c.text_brush = text_brush;
|
||||
c.background = background;
|
||||
c.bold = bold;
|
||||
c.makeIcon(iconImageSize(), preferredIconSize(1., this));
|
||||
categories.append(c);
|
||||
@@ -223,7 +224,10 @@ void LogView::newLine(const QString & keyword) {
|
||||
if (matched) {
|
||||
QTextCharFormat cf = def_cf;
|
||||
QTextBlockFormat bf = def_bf;
|
||||
bf.setBackground(c.color);
|
||||
if (c.text_brush != Qt::NoBrush)
|
||||
cf.setForeground(c.text_brush);
|
||||
if (c.background != Qt::NoBrush)
|
||||
bf.setBackground(c.background);
|
||||
if (c.bold)
|
||||
cf.setFontWeight(QFont::Bold);
|
||||
tc.setCharFormat(cf);
|
||||
@@ -246,8 +250,8 @@ void LogView::newLine(const QString & keyword) {
|
||||
if (isFilterVisible())
|
||||
filterBlock(tc.block(), fs, regexp);
|
||||
tc.movePosition(QTextCursor::End);
|
||||
tc.insertBlock();
|
||||
tc.setCharFormat(def_cf);
|
||||
tc.insertBlock();
|
||||
tc.setBlockFormat(def_bf);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user