Commit ee815f49 authored by Waqar Ahmed's avatar Waqar Ahmed Committed by Christoph Cullmann
Browse files

Ensure we always have readable colors in tooltip

parent 55d15632
......@@ -181,15 +181,18 @@ public:
// => update definition
// => update font
if (view != m_view) {
if (m_view) {
if (m_view && m_view->focusProxy()) {
m_view->focusProxy()->removeEventFilter(this);
}
m_view = view;
hl.setDefinition(r.definitionForFileName(view->document()->url().toString()));
updateFont();
m_view->focusProxy()->installEventFilter(this);
if (m_view && m_view->focusProxy()) {
m_view->focusProxy()->installEventFilter(this);
}
}
}
......@@ -209,9 +212,19 @@ public:
hl.setTheme(theme);
auto pal = palette();
pal.setColor(QPalette::Base, theme.editorColor(KSyntaxHighlighting::Theme::BackgroundColor));
const QColor bg = theme.editorColor(KSyntaxHighlighting::Theme::BackgroundColor);
pal.setColor(QPalette::Base, bg);
const QColor normal = theme.textColor(KSyntaxHighlighting::Theme::Normal);
pal.setColor(QPalette::Text, normal);
setPalette(pal);
this->setStyleSheet(QStringLiteral("Tooltip{"
"border-left: 1px solid %1;"
"border-top: 1px solid %1;"
"border-bottom: 1px solid %1;"
"}")
.arg(normal.name()));
updateFont();
};
updateColors(KTextEditor::Editor::instance());
......@@ -350,6 +363,10 @@ void LspTooltip::show(const QString &text, QPoint pos, KTextEditor::View *v)
if (text.isEmpty())
return;
if (!v || !v->document()) {
return;
}
Tooltip::self()->setView(v);
Tooltip::self()->setTooltipText(text);
Tooltip::self()->place(pos);
......
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