mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-29 22:24:13 +02:00
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 <noreply@anthropic.com>
This commit is contained in:
@@ -45,7 +45,9 @@
|
||||
#include <limits>
|
||||
|
||||
#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]() {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user