Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
c9258f0b
Commit
c9258f0b
authored
Feb 13, 2022
by
Waqar Ahmed
Browse files
lsp gotosymbol dialog: Use Utils::colorIcon for coloring
parent
acf27561
Changes
2
Hide whitespace changes
Inline
Side-by-side
addons/lspclient/gotosymboldialog.cpp
View file @
c9258f0b
...
...
@@ -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
)
{
...
...
shared/drawing_utils.h
View file @
c9258f0b
...
...
@@ -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
())
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment