1 | /* |
2 | This file is part of the KDE libraries |
3 | SPDX-FileCopyrightText: 2000 Carsten Pfeiffer <pfeiffer@kde.org> |
4 | |
5 | SPDX-License-Identifier: LGPL-2.0-or-later |
6 | */ |
7 | |
8 | #ifndef KCURSOR_P_H |
9 | #define KCURSOR_P_H |
10 | |
11 | #include <QCursor> |
12 | #include <QHash> |
13 | #include <QObject> |
14 | #include <QTimer> |
15 | |
16 | class QWidget; |
17 | |
18 | class KCursorPrivateAutoHideEventFilter : public QObject |
19 | { |
20 | Q_OBJECT |
21 | |
22 | public: |
23 | explicit KCursorPrivateAutoHideEventFilter(QWidget *widget); |
24 | ~KCursorPrivateAutoHideEventFilter() override; |
25 | |
26 | bool eventFilter(QObject *o, QEvent *e) override; |
27 | |
28 | void resetWidget(); |
29 | |
30 | private Q_SLOTS: |
31 | void hideCursor(); |
32 | void unhideCursor(); |
33 | |
34 | private: |
35 | QWidget *mouseWidget() const; |
36 | |
37 | QTimer m_autoHideTimer; |
38 | QWidget *m_widget; |
39 | bool m_wasMouseTracking; |
40 | bool m_isCursorHidden; |
41 | bool m_isOwnCursor; |
42 | QCursor m_oldCursor; |
43 | }; |
44 | |
45 | class KCursorPrivate : public QObject |
46 | { |
47 | friend class KCursor; // to shut up the compiler |
48 | Q_OBJECT |
49 | |
50 | public: |
51 | static KCursorPrivate *self(); |
52 | |
53 | void setAutoHideCursor(QWidget *w, bool enable, bool customEventFilter); |
54 | bool eventFilter(QObject *o, QEvent *e) override; |
55 | |
56 | int hideCursorDelay; |
57 | |
58 | private Q_SLOTS: |
59 | void slotViewportDestroyed(QObject *); |
60 | void slotWidgetDestroyed(QObject *); |
61 | |
62 | private: |
63 | KCursorPrivate(); |
64 | ~KCursorPrivate() override; |
65 | |
66 | bool enabled; |
67 | static KCursorPrivate *s_self; |
68 | |
69 | QHash<QObject *, KCursorPrivateAutoHideEventFilter *> m_eventFilters; |
70 | }; |
71 | |
72 | #endif // KCURSOR_PRIVATE_H |
73 | |