From c7f4a4f01d5fe30707945d5438527f20de43308c Mon Sep 17 00:00:00 2001 From: ispyisail Date: Mon, 28 Sep 2026 11:30:08 +1300 Subject: [PATCH 1/2] Show element icons light on a dark palette in search results and the picker The collection tree draws element previews through ElementPreviewDelegate, which inverts the black line art on a dark palette. The ranked search list (#1051) and the Insert element picker (#1052) are separate views and never installed it, so their icons stayed black on a dark background. Install the delegate on the ranked list, the picker's list and the shortcut bar editor's lists, and adapt the pinned-element buttons' icons directly. Coloured icons and light palettes are unchanged. Reported in #1083. Co-Authored-By: Claude Opus 5.5 --- sources/ElementsCollection/elementpickerpopup.cpp | 11 ++++++++++- .../ElementsCollection/elementscollectionwidget.cpp | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/sources/ElementsCollection/elementpickerpopup.cpp b/sources/ElementsCollection/elementpickerpopup.cpp index 5ebc14fd4..018c44cef 100644 --- a/sources/ElementsCollection/elementpickerpopup.cpp +++ b/sources/ElementsCollection/elementpickerpopup.cpp @@ -45,7 +45,9 @@ #include #include "../qetapp.h" +#include "../qetpalette.h" #include "../shortcutmanager.h" +#include "elementpreviewdelegate.h" #include "elementslocation.h" //The palette is read from disk each time the picker opens. It is meant as @@ -105,6 +107,7 @@ ElementPickerPopup::ElementPickerPopup(ElementsCollectionWidget *source, m_edit_available->setIconSize(QSize(20, 20)); m_edit_available->setMinimumHeight(220); for (QListWidget *list : {m_edit_row, m_edit_available}) { + list->setItemDelegate(new ElementPreviewDelegate(list)); list->setDragDropMode(QAbstractItemView::DragDrop); list->setDefaultDropAction(Qt::MoveAction); list->setSelectionMode(QAbstractItemView::SingleSelection); @@ -166,6 +169,7 @@ ElementPickerPopup::ElementPickerPopup(ElementsCollectionWidget *source, m_edit_symbols_search->setClearButtonEnabled(true); m_edit_symbols = new QListWidget(m_edit_symbols_box); m_edit_symbols->setIconSize(QSize(32, 32)); + m_edit_symbols->setItemDelegate(new ElementPreviewDelegate(m_edit_symbols)); m_edit_symbols->setMinimumHeight(220); m_edit_symbols->setDragDropMode(QAbstractItemView::DragOnly); m_edit_symbols->setDefaultDropAction(Qt::CopyAction); @@ -217,6 +221,8 @@ ElementPickerPopup::ElementPickerPopup(ElementsCollectionWidget *source, m_model = new QStandardItemModel(this); m_view = new QListView(this); m_view->setModel(m_model); + //Element previews are black line art; adapt them to a dark palette + m_view->setItemDelegate(new ElementPreviewDelegate(m_view)); m_view->setIconSize(QSize(40, 40)); m_view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); m_view->setEditTriggers(QAbstractItemView::NoEditTriggers); @@ -378,7 +384,10 @@ void ElementPickerPopup::setCommands(const QStringList &ids) auto *button = new QToolButton(m_commands); button->setAutoRaise(true); button->setIconSize(QSize(24, 24)); - button->setIcon(location.icon()); + //No item delegate on a button: adapt the preview here + button->setIcon(QIcon(QET::Palette::forPalette( + location.icon().pixmap(QSize(24, 24), devicePixelRatio()), + palette()))); button->setToolTip(location.name()); button->setFocusPolicy(Qt::NoFocus); connect(button, &QToolButton::clicked, this, [this, location]() { diff --git a/sources/ElementsCollection/elementscollectionwidget.cpp b/sources/ElementsCollection/elementscollectionwidget.cpp index 222425243..8183faaaa 100644 --- a/sources/ElementsCollection/elementscollectionwidget.cpp +++ b/sources/ElementsCollection/elementscollectionwidget.cpp @@ -27,6 +27,7 @@ #include "../qetmessagebox.h" #include "../qetproject.h" #include "elementcollectionitem.h" +#include "elementpreviewdelegate.h" #include "elementscollectionmodel.h" #include "elementslocation.h" #include "elementstreeview.h" @@ -258,6 +259,8 @@ void ElementsCollectionWidget::setUpWidget() m_search_model = new QStandardItemModel(this); m_search_results = new SearchResultsView(this); m_search_results->setModel(m_search_model); + //Same dark-palette icons as the tree the list stands in for + m_search_results->setItemDelegate(new ElementPreviewDelegate(m_search_results)); m_search_results->setDragDropMode(QAbstractItemView::DragOnly); m_search_results->setIconSize(QSize(50, 50)); m_search_results->setUniformItemSizes(false); From 9b09469a539ff10339af3f28101b902eea07f1dc Mon Sep 17 00:00:00 2001 From: ispyisail Date: Mon, 28 Sep 2026 11:53:13 +1300 Subject: [PATCH 2/2] Adapt only element icons in the shortcut bar editor, not its commands The editor's bar row and command list mix element previews with command icons. The command icons already follow the palette through the qet-dark icon theme, and running them through ElementPreviewDelegate again flattened them to one lightness (up to 16/255 per pixel off master; a two-tone icon would have had its tones swapped). Adapt the element icons once, where the items are built, instead of installing the delegate on those lists. This also covers an element dragged from the element list onto the bar, which copies the item's icon and so previously kept the dark one until the editor was reopened. Co-Authored-By: Claude Opus 5.5 --- .../ElementsCollection/elementpickerpopup.cpp | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/sources/ElementsCollection/elementpickerpopup.cpp b/sources/ElementsCollection/elementpickerpopup.cpp index 018c44cef..ccc714e4e 100644 --- a/sources/ElementsCollection/elementpickerpopup.cpp +++ b/sources/ElementsCollection/elementpickerpopup.cpp @@ -55,6 +55,25 @@ //slow and the grid unusable. static const int max_palette_entries = 60; +/** + @brief elementIcon + @return the element preview @a icon, adapted to @a widget's palette at + @a size. The shortcut bar and its editor mix these with command icons, + which already follow the palette through the icon theme, so the + element icons are adapted once here rather than by an + ElementPreviewDelegate over the whole list. An item dragged from one + list to another keeps its adapted icon. +*/ +static QIcon elementIcon(const QIcon &icon, const QSize &size, const QWidget *widget) +{ + if (icon.isNull() || !QET::Palette::isDark(widget->palette())) { + return icon; + } + return QIcon(QET::Palette::forPalette( + icon.pixmap(size, widget->devicePixelRatio()), + widget->palette())); +} + /** @brief ElementPickerPopup::ElementPickerPopup @param source : the collection widget whose model the search runs against @@ -107,7 +126,6 @@ ElementPickerPopup::ElementPickerPopup(ElementsCollectionWidget *source, m_edit_available->setIconSize(QSize(20, 20)); m_edit_available->setMinimumHeight(220); for (QListWidget *list : {m_edit_row, m_edit_available}) { - list->setItemDelegate(new ElementPreviewDelegate(list)); list->setDragDropMode(QAbstractItemView::DragDrop); list->setDefaultDropAction(Qt::MoveAction); list->setSelectionMode(QAbstractItemView::SingleSelection); @@ -169,7 +187,6 @@ ElementPickerPopup::ElementPickerPopup(ElementsCollectionWidget *source, m_edit_symbols_search->setClearButtonEnabled(true); m_edit_symbols = new QListWidget(m_edit_symbols_box); m_edit_symbols->setIconSize(QSize(32, 32)); - m_edit_symbols->setItemDelegate(new ElementPreviewDelegate(m_edit_symbols)); m_edit_symbols->setMinimumHeight(220); m_edit_symbols->setDragDropMode(QAbstractItemView::DragOnly); m_edit_symbols->setDefaultDropAction(Qt::CopyAction); @@ -384,10 +401,7 @@ void ElementPickerPopup::setCommands(const QStringList &ids) auto *button = new QToolButton(m_commands); button->setAutoRaise(true); button->setIconSize(QSize(24, 24)); - //No item delegate on a button: adapt the preview here - button->setIcon(QIcon(QET::Palette::forPalette( - location.icon().pixmap(QSize(24, 24), devicePixelRatio()), - palette()))); + button->setIcon(elementIcon(location.icon(), QSize(24, 24), this)); button->setToolTip(location.name()); button->setFocusPolicy(Qt::NoFocus); connect(button, &QToolButton::clicked, this, [this, location]() { @@ -551,7 +565,7 @@ QListWidgetItem *ElementPickerPopup::barItem(const QString &id, bool icon_only) const ElementsLocation location(id); if (location.exist()) { text = location.name(); - icon = location.icon(); + icon = elementIcon(location.icon(), QSize(24, 24), this); } } else if (QAction *action = commandAction(id)) { text = action->text().remove(QLatin1Char('&')); @@ -641,7 +655,8 @@ void ElementPickerPopup::runSymbolSearch() if (ElementsLocation(hit.path).isProject()) { continue; } - auto *item = new QListWidgetItem(hit.icon, hit.name); + auto *item = new QListWidgetItem( + elementIcon(hit.icon, m_edit_symbols->iconSize(), this), hit.name); item->setData(Qt::UserRole, hit.path); item->setToolTip(QStringLiteral("%1\n%2").arg(hit.name, hit.folder)); m_edit_symbols->addItem(item);