-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmousecursor.cpp
45 lines (38 loc) · 926 Bytes
/
mousecursor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "mousecursor.h"
#include <QCursor>
#include <QGuiApplication>
MouseCursor::MouseCursor(QQuickItem *parent) :
QQuickItem(parent)
{
}
QObject* MouseCursor::target() const
{
return m_target;
}
void MouseCursor::setTarget(QObject *target)
{
if (m_target != target) {
m_target = qobject_cast<QQuickItem*>(target);
emit targetChanged();
applyCursor();
}
}
Qt::CursorShape MouseCursor::cursorShape() const
{
return m_cursorShape;
}
void MouseCursor::setCursorShape(Qt::CursorShape cursorShape)
{
if (m_cursorShape != cursorShape) {
m_cursorShape = cursorShape;
emit cursorShape;
applyCursor();
}
}
void MouseCursor::applyCursor()
{
if (m_target) {
// m_target->setCursor(m_cursorShape); FIXME: Why does this not work?
static_cast<QGuiApplication*>(QGuiApplication::instance())->setOverrideCursor(m_cursorShape);
}
}