Commit c9258f0b authored by Waqar Ahmed's avatar Waqar Ahmed
Browse files

lsp gotosymbol dialog: Use Utils::colorIcon for coloring

parent acf27561
......@@ -19,6 +19,7 @@
#include <QStandardItemModel>
#include <QStyledItemDelegate>
#include <drawing_utils.h>
#include <kfts_fuzzy_match.h>
#include <ktexteditor_utils.h>
......@@ -59,13 +60,9 @@ public:
{
QStyleOptionViewItem options = option;
initStyleOption(&options, index);
options.icon = Utils::colorIcon(options.icon, normalColor);
auto style = options.widget->style();
auto iconRect = style->subElementRect(QStyle::SE_ItemViewItemDecoration, &options, options.widget);
auto icon = options.icon;
options.icon = QIcon();
auto pm = createPixmap(icon, iconRect.size());
painter->save();
......@@ -73,7 +70,6 @@ public:
options.text = QString();
style->drawControl(QStyle::CE_ItemViewItem, &options, painter, options.widget);
style->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm);
auto textRectX = options.widget->style()->subElementRect(QStyle::SE_ItemViewItemText, &options, options.widget).x();
auto width = textRectX - options.rect.x();
......@@ -119,15 +115,6 @@ public:
}
private:
QPixmap createPixmap(const QIcon &icon, QSize iconSize) const
{
auto pm = icon.pixmap(iconSize);
auto mask = pm.createMaskFromColor(Qt::transparent, Qt::MaskInColor);
pm.fill(normalColor);
pm.setMask(mask);
return pm;
}
QColor colorForSymbolKind(LSPSymbolKind kind) const
{
switch (kind) {
......
......@@ -10,7 +10,7 @@ namespace Utils
/**
* @brief colors the @p icon with @fgColor
*/
QPixmap colorIcon(const QIcon &icon, const QColor &fgColor, const QSize s = QSize(16, 16))
inline QPixmap colorIcon(const QIcon &icon, const QColor &fgColor, const QSize s = QSize(16, 16))
{
auto p = icon.pixmap(s);
if (p.isNull())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment