1
0
Fork 0
flightgear/src/GUI/HoverArea.cxx

34 lines
692 B
C++
Raw Normal View History

2020-04-01 09:47:29 +00:00
#include "HoverArea.hxx"
#include <QDebug>
#include <QQuickWindow>
HoverArea::HoverArea()
{
connect(this, &QQuickItem::windowChanged, [this](QQuickWindow* win) {
if (win) {
win->installEventFilter(this);
}
});
}
bool HoverArea::eventFilter(QObject *sender, QEvent *event)
{
Q_UNUSED(sender)
if (event->type() == QEvent::MouseMove) {
QMouseEvent* me = static_cast<QMouseEvent*>(event);
const auto local = mapFromScene(me->pos());
const bool con = contains(local);
if (con != m_containsMouse) {
m_containsMouse = con;
emit containsMouseChanged(con);
}
}
return false;
}