another try for dark theme
This commit is contained in:
@@ -877,18 +877,32 @@ void QCodeEdit::highlightBrackets() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QCodeEdit::applyExtraSelection() {
|
QColor inverseColorValue(const QColor & c) {
|
||||||
auto inverseColorValue = [](const QColor & c) {
|
|
||||||
int hsv[4];
|
int hsv[4];
|
||||||
c.getHsv(&hsv[0], &hsv[1], &hsv[2], &hsv[3]);
|
c.getHsv(&hsv[0], &hsv[1], &hsv[2], &hsv[3]);
|
||||||
return QColor::fromHsv(hsv[0], hsv[1], 255 - hsv[2], hsv[3]);
|
return QColor::fromHsv(hsv[0], hsv[1], 255 - hsv[2], hsv[3]);
|
||||||
};
|
}
|
||||||
|
QBrush QCodeEdit::invertedBrush(const QBrush & b) {
|
||||||
|
auto ret = b;
|
||||||
|
ret.setColor(inverseColorValue(b.color()));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QTextCharFormat QCodeEdit::invertedFormat(const QTextCharFormat & f) {
|
||||||
|
auto ret = f;
|
||||||
|
ret.setForeground(invertedBrush(ret.foreground()));
|
||||||
|
ret.setBackground(invertedBrush(ret.background()));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCodeEdit::applyExtraSelection() {
|
||||||
QList<QTextEdit::ExtraSelection> esl;
|
QList<QTextEdit::ExtraSelection> esl;
|
||||||
esl << es_line << es_selected << es_custom << es_brackets << es_search_list << es_cursor << es_link;
|
esl << es_line << es_selected << es_custom << es_brackets << es_search_list << es_cursor << es_link;
|
||||||
if (is_dark_theme) {
|
if (is_dark_theme) {
|
||||||
for (auto & e: esl) {
|
for (auto & e: esl) {
|
||||||
e.format.foreground().setColor(inverseColorValue(e.format.foreground().color()));
|
e.format = invertedFormat(e.format);
|
||||||
e.format.background().setColor(inverseColorValue(e.format.background().color()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
esl << es_blockselection;
|
esl << es_blockselection;
|
||||||
|
|||||||
@@ -111,6 +111,9 @@ public:
|
|||||||
void registerAutoCompletitionClass(int id, ACClassType ac_class, const QString & name, const QIcon & icon = QIcon());
|
void registerAutoCompletitionClass(int id, ACClassType ac_class, const QString & name, const QIcon & icon = QIcon());
|
||||||
bool wordCompletitionEnabled() const { return word_complete; }
|
bool wordCompletitionEnabled() const { return word_complete; }
|
||||||
|
|
||||||
|
static QBrush invertedBrush(const QBrush & b);
|
||||||
|
static QTextCharFormat invertedFormat(const QTextCharFormat & f);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef QPair<QString, QString> StringsPair;
|
typedef QPair<QString, QString> StringsPair;
|
||||||
typedef QPair<int, QList<ACEntry>> ACSection; // section, ACClass.id -> list of entries
|
typedef QPair<int, QList<ACEntry>> ACSection; // section, ACClass.id -> list of entries
|
||||||
|
|||||||
Reference in New Issue
Block a user