diff --git a/sources/ElementsCollection/elementstreeview.cpp b/sources/ElementsCollection/elementstreeview.cpp index fbdaae0dd..eb62e2d1f 100644 --- a/sources/ElementsCollection/elementstreeview.cpp +++ b/sources/ElementsCollection/elementstreeview.cpp @@ -43,6 +43,14 @@ ElementsTreeView::ElementsTreeView(QWidget *parent) : { // force du noir sur une alternance de blanc (comme le schema) et de gris // clair, avec du blanc sur bleu pas trop fonce pour la selection + // + // Element icons are rendered with colors read directly from each .elmt + // file (almost always black linework, matching printed-schematic + // convention) onto a transparent background -- so this view must keep + // a light background regardless of the OS/desktop theme, or the icons + // become invisible on dark themes. QAbstractItemView paints its rows + // using the viewport's palette, not the view's own, so the palette + // must be applied to both to actually take effect under every style. QPalette qp = palette(); qp.setColor(QPalette::Text, Qt::black); qp.setColor(QPalette::Base, Qt::white); @@ -50,6 +58,7 @@ ElementsTreeView::ElementsTreeView(QWidget *parent) : qp.setColor(QPalette::Highlight, QColor("#678db2")); qp.setColor(QPalette::HighlightedText, Qt::black); setPalette(qp); + viewport()->setPalette(qp); } /** diff --git a/sources/elementspanel.cpp b/sources/elementspanel.cpp index 3f1ce10a2..09f12cf96 100644 --- a/sources/elementspanel.cpp +++ b/sources/elementspanel.cpp @@ -56,6 +56,14 @@ ElementsPanel::ElementsPanel(QWidget *parent) : // force du noir sur une alternance de blanc (comme le schema) et de gris // clair, avec du blanc sur bleu pas trop fonce pour la selection + // + // Element icons are rendered with colors read directly from each .elmt + // file (almost always black linework, matching printed-schematic + // convention) onto a transparent background -- so this view must keep + // a light background regardless of the OS/desktop theme, or the icons + // become invisible on dark themes. QAbstractItemView paints its rows + // using the viewport's palette, not the view's own, so the palette + // must be applied to both to actually take effect under every style. QPalette qp = palette(); qp.setColor(QPalette::Text, Qt::black); qp.setColor(QPalette::Base, Qt::white); @@ -63,6 +71,7 @@ ElementsPanel::ElementsPanel(QWidget *parent) : qp.setColor(QPalette::Highlight, QColor("#678db2")); qp.setColor(QPalette::HighlightedText, Qt::black); setPalette(qp); + viewport()->setPalette(qp); // we handle double click on items ourselves connect(this, &ElementsPanel::itemDoubleClicked, this, &ElementsPanel::slot_doubleClick);