File indexing completed on 2025-02-02 14:19:59
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2000 Carsten Pfeiffer <pfeiffer@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef KCURSOR_P_H 0009 #define KCURSOR_P_H 0010 0011 #include <QCursor> 0012 #include <QHash> 0013 #include <QObject> 0014 #include <QTimer> 0015 0016 class QWidget; 0017 0018 /** 0019 * @internal 0020 * I don't want the eventFilter to be in KCursor, so we have another class 0021 * for that stuff 0022 * @author John Firebaugh <jfirebaugh@kde.org> 0023 * @author Carsten Pfeiffer <pfeiffer@kde.org> 0024 */ 0025 class KCursorPrivateAutoHideEventFilter : public QObject 0026 { 0027 Q_OBJECT 0028 0029 public: 0030 explicit KCursorPrivateAutoHideEventFilter(QWidget *widget); 0031 ~KCursorPrivateAutoHideEventFilter() override; 0032 0033 bool eventFilter(QObject *o, QEvent *e) override; 0034 0035 void resetWidget(); 0036 0037 private Q_SLOTS: 0038 void hideCursor(); 0039 void unhideCursor(); 0040 0041 private: 0042 QWidget *mouseWidget() const; 0043 0044 QTimer m_autoHideTimer; 0045 QWidget *m_widget; 0046 bool m_wasMouseTracking; 0047 bool m_isCursorHidden; 0048 bool m_isOwnCursor; 0049 QCursor m_oldCursor; 0050 }; 0051 0052 /** 0053 * @internal 0054 * @author Carsten Pfeiffer <pfeiffer@kde.org> 0055 * @author John Firebaugh <jfirebaugh@kde.org> 0056 */ 0057 class KCursorPrivate : public QObject 0058 { 0059 friend class KCursor; // to shut up the compiler 0060 Q_OBJECT 0061 0062 public: 0063 static KCursorPrivate *self(); 0064 0065 void setAutoHideCursor(QWidget *w, bool enable, bool customEventFilter); 0066 bool eventFilter(QObject *o, QEvent *e) override; 0067 0068 int hideCursorDelay; 0069 0070 private Q_SLOTS: 0071 void slotViewportDestroyed(QObject *); 0072 void slotWidgetDestroyed(QObject *); 0073 0074 private: 0075 KCursorPrivate(); 0076 ~KCursorPrivate() override; 0077 0078 bool enabled; 0079 static KCursorPrivate *s_self; 0080 0081 QHash<QObject *, KCursorPrivateAutoHideEventFilter *> m_eventFilters; 0082 }; 0083 0084 #endif // KCURSOR_PRIVATE_H