Skip to content
GitLab
Menu
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
1547d5d4
Commit
1547d5d4
authored
Mar 08, 2022
by
Kåre Särs
Browse files
S&R: Adjust search result colors
parent
f4374a41
Pipeline
#147148
passed with stage
in 2 minutes and 22 seconds
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
addons/search/SearchResultsDelegate.cpp
View file @
1547d5d4
...
...
@@ -33,16 +33,20 @@ SearchResultsDelegate::SearchResultsDelegate(QObject *parent)
const
auto
updateColors
=
[
this
]
{
m_font
=
Utils
::
editorFont
();
const
auto
theme
=
KTextEditor
::
Editor
::
instance
()
->
theme
();
m_lineNumColor
=
QColor
::
fromRgba
(
theme
.
editorColor
(
KSyntaxHighlighting
::
Theme
::
LineNumbers
));
m_textColorLight
=
m_textColor
=
QColor
::
fromRgba
(
theme
.
textColor
(
KSyntaxHighlighting
::
Theme
::
Normal
));
m_textColorLight
.
setAlpha
(
150
);
m_numBackground
=
m_altBackground
=
QColor
::
fromRgba
(
theme
.
editorColor
(
KSyntaxHighlighting
::
Theme
::
IconBorder
));
m_numBackground
.
setAlpha
(
150
);
m_borderColor
=
QColor
::
fromRgba
(
theme
.
editorColor
(
KSyntaxHighlighting
::
Theme
::
Separator
));
m_curLineNumColor
=
QColor
::
fromRgba
(
theme
.
editorColor
(
KSyntaxHighlighting
::
Theme
::
CurrentLineNumber
));
m_textColor
=
QColor
::
fromRgba
(
theme
.
textColor
(
KSyntaxHighlighting
::
Theme
::
Normal
));
m_iconBorderColor
=
QColor
::
fromRgba
(
theme
.
editorColor
(
KSyntaxHighlighting
::
Theme
::
IconBorder
));
m_curLineHighlightColor
=
QColor
::
fromRgba
(
theme
.
editorColor
(
KSyntaxHighlighting
::
Theme
::
CurrentLine
));
m_searchColor
=
QColor
::
fromRgba
(
theme
.
editorColor
(
KSyntaxHighlighting
::
Theme
::
SearchHighlight
));
m_searchColor
.
setAlpha
(
200
);
m_replaceColor
=
QColor
::
fromRgba
(
theme
.
editorColor
(
KSyntaxHighlighting
::
Theme
::
ReplaceHighlight
));
QColor
altBase
=
QColor
::
fromRgba
(
theme
.
editorColor
(
KSyntaxHighlighting
::
Theme
::
BackgroundColor
));
m_altBase
=
altBase
.
lightness
()
>
127
?
altBase
.
darker
(
125
)
:
altBase
.
lighter
(
125
);
m_replaceColor
.
setAlpha
(
200
);
};
connect
(
e
,
&
KTextEditor
::
Editor
::
configChanged
,
this
,
updateColors
);
updateColors
();
...
...
@@ -80,7 +84,6 @@ void SearchResultsDelegate::paintMatchItem(QPainter *p, const QStyleOptionViewIt
// line num area
const
bool
selected
=
opt
.
state
&
QStyle
::
State_Selected
;
const
QBrush
iconBorderRectColor
=
selected
?
m_curLineHighlightColor
:
m_iconBorderColor
;
const
int
lineColWidth
=
lineNumAreaWidth
(
index
,
fm
)
+
(
hMargins
*
2
);
if
(
rtl
)
{
...
...
@@ -89,10 +92,10 @@ void SearchResultsDelegate::paintMatchItem(QPainter *p, const QStyleOptionViewIt
iconBorderRect
.
setWidth
(
lineColWidth
);
// line number area background
p
->
fillRect
(
iconBorderRect
,
iconBorderRectColor
);
p
->
fillRect
(
iconBorderRect
,
m_numBackground
);
// line numbers
const
QBrush
lineNumCol
=
selected
?
m_
curLineNumColor
:
m_lineNumColor
;
const
QBrush
lineNumCol
=
selected
?
m_
textColor
:
m_textColorLight
;
p
->
setPen
(
QPen
(
lineNumCol
,
1
));
p
->
drawText
(
iconBorderRect
.
adjusted
(
2.
,
0.
,
-
2.
,
0.
),
Qt
::
AlignVCenter
,
lineCol
);
...
...
@@ -162,7 +165,7 @@ void SearchResultsDelegate::paint(QPainter *painter, const QStyleOptionViewItem
// draw item without text
options
.
text
=
QString
();
if
(
!
isMatchItem
(
index
))
{
options
.
backgroundBrush
=
m_altBa
se
;
options
.
backgroundBrush
=
m_altBa
ckground
;
}
options
.
widget
->
style
()
->
drawControl
(
QStyle
::
CE_ItemViewItem
,
&
options
,
painter
,
options
.
widget
);
...
...
addons/search/SearchResultsDelegate.h
View file @
1547d5d4
...
...
@@ -24,15 +24,16 @@ private:
void
paintMatchItem
(
QPainter
*
,
const
QStyleOptionViewItem
&
,
const
QModelIndex
&
index
)
const
;
QFont
m_font
;
QBrush
m_curLineHighlightColor
;
QBrush
m_iconBorderColor
;
QBrush
m_borderColor
;
QBrush
m_lineNumColor
;
QBrush
m_curLineNumColor
;
QBrush
m_textColor
;
QBrush
m_searchColor
;
QBrush
m_replaceColor
;
QBrush
m_altBase
;
QColor
m_textColor
;
QColor
m_textColorLight
;
QColor
m_altBackground
;
QColor
m_numBackground
;
QColor
m_borderColor
;
QColor
m_searchColor
;
QColor
m_replaceColor
;
};
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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