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
8b501355
Commit
8b501355
authored
Feb 11, 2021
by
Waqar Ahmed
Committed by
Christoph Cullmann
Feb 11, 2021
Browse files
Fix positioning
parent
e0133421
Changes
1
Hide whitespace changes
Inline
Side-by-side
addons/lspclient/lsptooltip.cpp
View file @
8b501355
...
...
@@ -140,6 +140,9 @@ public:
void
setTooltipText
(
const
QString
&
text
)
{
if
(
text
.
isEmpty
())
return
;
hl
.
setText
(
text
);
resizeTip
(
text
);
setHtml
(
hl
.
html
());
...
...
@@ -165,6 +168,9 @@ public:
setFrameStyle
(
QFrame
::
Box
);
connect
(
&
m_hideTimer
,
&
QTimer
::
timeout
,
this
,
&
Tooltip
::
hideTooltip
);
setHorizontalScrollBarPolicy
(
Qt
::
ScrollBarAsNeeded
);
setVerticalScrollBarPolicy
(
Qt
::
ScrollBarAsNeeded
);
auto
updateColors
=
[
this
](
KTextEditor
::
Editor
*
e
)
{
auto
theme
=
e
->
theme
();
hl
.
setTheme
(
theme
);
...
...
@@ -191,17 +197,35 @@ public:
Q_SLOT
void
hideTooltip
()
{
close
();
setText
(
QString
());
}
void
resizeTip
(
const
QString
&
text
)
{
QFontMetrics
fm
(
font
());
QSize
size
=
fm
.
size
(
0
,
text
);
size
.
setHeight
(
std
::
min
(
size
.
height
(),
m_view
->
window
()
->
height
()
/
3
));
size
.
setWidth
(
std
::
min
(
size
.
width
(),
m_view
->
window
()
->
width
()
/
2
));
size
.
setHeight
(
std
::
min
(
size
.
height
(),
m_view
->
height
()
/
3
));
size
.
setWidth
(
std
::
min
(
size
.
width
(),
m_view
->
width
()
/
2
));
resize
(
size
);
}
void
place
(
QPoint
p
)
{
if
(
p
.
x
()
+
width
()
>
m_view
->
x
()
+
m_view
->
width
())
p
.
rx
()
-=
4
+
width
();
if
(
p
.
y
()
+
this
->
height
()
>
m_view
->
y
()
+
m_view
->
height
())
p
.
ry
()
-=
24
+
this
->
height
();
if
(
p
.
y
()
<
m_view
->
y
())
p
.
setY
(
m_view
->
y
());
if
(
p
.
x
()
+
this
->
width
()
>
m_view
->
x
()
+
m_view
->
width
())
p
.
setX
(
m_view
->
x
()
+
m_view
->
width
()
-
this
->
width
());
if
(
p
.
x
()
<
m_view
->
x
())
p
.
setX
(
m_view
->
x
());
if
(
p
.
y
()
+
this
->
height
()
>
m_view
->
y
()
+
m_view
->
height
())
p
.
setY
(
m_view
->
y
()
+
m_view
->
height
()
-
this
->
height
());
this
->
move
(
p
);
}
protected:
void
showEvent
(
QShowEvent
*
event
)
override
{
...
...
@@ -245,9 +269,12 @@ LspTooltip::LspTooltip()
void
LspTooltip
::
show
(
const
QString
&
text
,
QPoint
pos
,
KTextEditor
::
View
*
v
)
{
if
(
text
.
isEmpty
())
return
;
Tooltip
::
self
()
->
setView
(
v
);
Tooltip
::
self
()
->
setTooltipText
(
text
);
Tooltip
::
self
()
->
mov
e
(
pos
);
Tooltip
::
self
()
->
plac
e
(
pos
);
Tooltip
::
self
()
->
show
();
}
...
...
Write
Preview
Supports
Markdown
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