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 /** 19 * @internal 20 * I don't want the eventFilter to be in KCursor, so we have another class 21 * for that stuff 22 * @author John Firebaugh <jfirebaugh@kde.org> 23 * @author Carsten Pfeiffer <pfeiffer@kde.org> 24 */ 25 class KCursorPrivateAutoHideEventFilter : public QObject 26 { 27 Q_OBJECT 28 29 public: 30 explicit KCursorPrivateAutoHideEventFilter(QWidget *widget); 31 ~KCursorPrivateAutoHideEventFilter() override; 32 33 bool eventFilter(QObject *o, QEvent *e) override; 34 35 void resetWidget(); 36 37 private Q_SLOTS: 38 void hideCursor(); 39 void unhideCursor(); 40 41 private: 42 QWidget *mouseWidget() const; 43 44 QTimer m_autoHideTimer; 45 QWidget *m_widget; 46 bool m_wasMouseTracking; 47 bool m_isCursorHidden; 48 bool m_isOwnCursor; 49 QCursor m_oldCursor; 50 }; 51 52 /** 53 * @internal 54 * @author Carsten Pfeiffer <pfeiffer@kde.org> 55 * @author John Firebaugh <jfirebaugh@kde.org> 56 */ 57 class KCursorPrivate : public QObject 58 { 59 friend class KCursor; // to shut up the compiler 60 Q_OBJECT 61 62 public: 63 static KCursorPrivate *self(); 64 65 void setAutoHideCursor(QWidget *w, bool enable, bool customEventFilter); 66 bool eventFilter(QObject *o, QEvent *e) override; 67 68 int hideCursorDelay; 69 70 private Q_SLOTS: 71 void slotViewportDestroyed(QObject *); 72 void slotWidgetDestroyed(QObject *); 73 74 private: 75 KCursorPrivate(); 76 ~KCursorPrivate() override; 77 78 bool enabled; 79 static KCursorPrivate *s_self; 80 81 QHash<QObject *, KCursorPrivateAutoHideEventFilter *> m_eventFilters; 82 }; 83 84 #endif // KCURSOR_PRIVATE_H 85