Commit 71c34ef4 authored by Waqar Ahmed's avatar Waqar Ahmed
Browse files

Make tooltip a bit less annoying

parent 792327eb
......@@ -154,9 +154,15 @@ public:
// => update definition
// => update font
if (view != m_view) {
if (m_view) {
m_view->focusProxy()->removeEventFilter(this);
}
m_view = view;
hl.setDefinition(r.definitionForFileName(view->document()->url().toString()));
updateFont();
m_view->focusProxy()->installEventFilter(this);
}
}
......@@ -185,6 +191,28 @@ public:
connect(KTextEditor::Editor::instance(), &KTextEditor::Editor::configChanged, this, updateColors);
}
bool eventFilter(QObject *o, QEvent *e) override
{
switch (e->type()) {
case QEvent::KeyPress:
case QEvent::KeyRelease:
hideTooltip();
break;
case QEvent::WindowActivate:
case QEvent::WindowDeactivate:
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
case QEvent::MouseButtonDblClick:
case QEvent::Wheel:
if (!rect().contains(static_cast<QMouseEvent *>(e)->pos())) {
hideTooltip();
}
default:
break;
}
return false;
}
void updateFont()
{
if (!m_view)
......@@ -229,7 +257,7 @@ public:
protected:
void showEvent(QShowEvent *event) override
{
m_hideTimer.start(3000);
m_hideTimer.start(1000);
return QTextBrowser::showEvent(event);
}
......
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