#ifndef WEDGEHIGHLIGHTER_H
#define WEDGEHIGHLIGHTER_H
#include <QColor>
#include <QString>
#include <QSyntaxHighlighter>
#include <QTextCharFormat>
class WedgeHighlighter : public QSyntaxHighlighter {
public:
WedgeHighlighter(QTextDocument *parent, const QColor &focusColor, const QColor &highlightColor, const QColor &textColor, const QString &headerFormat)
: QSyntaxHighlighter(parent), m_focusColor(focusColor), m_highlightColor(highlightColor), m_textColor(textColor), m_headerFormat(headerFormat) {}
void setColors(const QColor &focusColor, const QColor &highlightColor, const QColor &textColor) {
m_focusColor = focusColor;
m_highlightColor = highlightColor;
m_textColor = textColor;
rehighlight();
}
void setHeaderFormat(const QString &headerFormat) {
if (m_headerFormat == headerFormat) return;
m_headerFormat = headerFormat;
rehighlight();
}
protected:
void highlightBlock(const QString &text) override;
private:
QColor m_focusColor;
QColor m_highlightColor;
QColor m_textColor;
QString m_headerFormat;
};
#endif