improve restable sel/unsel colors

This commit is contained in:
Jean-Francois Dockes 2020-09-11 16:08:02 +02:00
parent 3541ba49f1
commit f078e8a8af

View File

@ -499,9 +499,14 @@ public:
painter->save(); painter->save();
QTextDocument document; /* As we draw with a text document, not the normal tableview
QString color = opt.palette.color(QPalette::Text).name(); painter, we need to retrieve the appropriate colors and set
QString selcolor = opt.palette.color(QPalette::BrightText).name(); them as HTML styles. */
QString color = opt.palette.color(QPalette::Base).name();
QString textcolor = opt.palette.color(QPalette::Text).name();
QString selcolor = opt.palette.color(QPalette::Highlight).name();
QString seltextcolor =
opt.palette.color(QPalette::HighlightedText).name();
QString fstyle; QString fstyle;
if (prefs.reslistfontsize > 0) { if (prefs.reslistfontsize > 0) {
int fs = prefs.reslistfontsize <= fsadjusttable ? int fs = prefs.reslistfontsize <= fsadjusttable ?
@ -510,6 +515,9 @@ public:
} }
QString ntxt("<div style='"); QString ntxt("<div style='");
ntxt += " color:"; ntxt += " color:";
ntxt += (opt.state & QStyle::State_Selected)? seltextcolor:textcolor;
ntxt += ";";
ntxt += " background:";
ntxt += (opt.state & QStyle::State_Selected)? selcolor:color; ntxt += (opt.state & QStyle::State_Selected)? selcolor:color;
ntxt += ";"; ntxt += ";";
ntxt += fstyle; ntxt += fstyle;
@ -520,6 +528,7 @@ public:
QPoint where = option.rect.topLeft(); QPoint where = option.rect.topLeft();
where.ry() += TEXTINCELLVTRANS; where.ry() += TEXTINCELLVTRANS;
painter->translate(where); painter->translate(where);
QTextDocument document;
document.setHtml(text); document.setHtml(text);
document.drawContents(painter); document.drawContents(painter);
painter->restore(); painter->restore();