From bab5bf58f8ca9a5b1b1c64007fa77d20a45264d4 Mon Sep 17 00:00:00 2001 From: ispyisail Date: Sat, 8 Aug 2026 21:53:20 +1200 Subject: [PATCH] Fix invisible element icons on dark themes in Open/Save Element and New Element Wizard dialogs Bugtracker #335: element library icons are black and nearly invisible under a dark desktop theme (reported on KDE Plasma / Fedora 43). The main elements panel (ElementsCollectionWidget) already forces a fixed light palette on its tree views via ElementsTreeView, added in a8e2a7acf and completed in bb61dde81 -- element icons are rendered with colors read from each .elmt file (almost always black linework, matching printed-schematic convention) onto a transparent background, so any view showing them needs to stay light regardless of the OS theme. ElementsTreeView's own class doc already says "This class must be used when the tree view have an ElementsCollectionModel as model" -- but two other dialogs showing the exact same model were still using a plain QTreeView and missed that fix: the Open/Save Element/Category/Template dialog (ElementDialog) and the New Element Wizard's parent-category picker (NewElementWizard). Same underlying ElementsCollectionModel, same black-on-transparent icons, same invisibility on a dark theme. Fix: use ElementsTreeView in both, matching the main panel and the class's own documented contract. No other behavior changes -- ElementsTreeView only additionally overrides startDrag() to use a nicer drag pixmap, which is inert unless drag-out is enabled. Verified with a full Release build (504/504, no new warnings) and a standalone Qt program that shows the real ElementDialog under a forced dark QPalette (simulating a dark OS theme, since neither this build environment nor QET itself forces the palette one way or the other): screenshots down through nested collection categories (Electric > IEC 60617 > Conductors and connecting devices) confirm the tree view keeps a white background against the dark dialog chrome around it. --- sources/elementdialog.cpp | 3 ++- sources/newelementwizard.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sources/elementdialog.cpp b/sources/elementdialog.cpp index 2cc2e6c34..503aefc6b 100644 --- a/sources/elementdialog.cpp +++ b/sources/elementdialog.cpp @@ -19,6 +19,7 @@ #include "ElementsCollection/elementcollectionitem.h" #include "ElementsCollection/elementscollectionmodel.h" +#include "ElementsCollection/elementstreeview.h" #include "qetapp.h" #include "qetmessagebox.h" #include "qfilenameedit.h" @@ -88,7 +89,7 @@ void ElementDialog::setUpWidget() layout->addWidget(new QLabel(label_)); - m_tree_view = new QTreeView(this); + m_tree_view = new ElementsTreeView(this); m_model = new ElementsCollectionModel(m_tree_view); diff --git a/sources/newelementwizard.cpp b/sources/newelementwizard.cpp index 834ac98a6..afa30fa9e 100644 --- a/sources/newelementwizard.cpp +++ b/sources/newelementwizard.cpp @@ -19,6 +19,7 @@ #include "ElementsCollection/elementcollectionitem.h" #include "ElementsCollection/elementscollectionmodel.h" +#include "ElementsCollection/elementstreeview.h" #include "NameList/ui/namelistwidget.h" #include "editor/ui/qetelementeditor.h" #include "qetmessagebox.h" @@ -85,7 +86,7 @@ QWizardPage *NewElementWizard::buildStep1() page -> setSubTitle(tr("Sélectionnez une catégorie dans laquelle enregistrer le nouvel élément.", "wizard page subtitle")); QVBoxLayout *layout = new QVBoxLayout(); - m_tree_view = new QTreeView(this); + m_tree_view = new ElementsTreeView(this); m_model = new ElementsCollectionModel(m_tree_view); m_model->hideElement();