File indexing completed on 2024-04-28 04:21:25

0001 // SPDX-FileCopyrightText: 2023 The KPhotoAlbum Development Team
0002 //
0003 // SPDX-License-Identifier: GPL-2.0-or-later
0004 
0005 #pragma once
0006 
0007 #include <QStack>
0008 #include <QWidget>
0009 
0010 /**
0011   This class handles hiding the mouse cursor when it is not needed while viewing images or videos.
0012 
0013   In some situations, e.g. when selecting an area for zooming, or when bringing up the annotation dialog,
0014   this handling is temporarily disabled.
0015   */
0016 class CursorVisibilityHandler : public QObject
0017 {
0018     Q_OBJECT
0019 public:
0020     explicit CursorVisibilityHandler(QWidget *parentWidget);
0021     void disableCursorHiding();
0022     void enableCursorHiding();
0023 
0024     bool cursorHidingEnabled() const;
0025 
0026 protected:
0027     bool eventFilter(QObject *watched, QEvent *event) override;
0028 
0029 private:
0030     void showCursorTemporarily();
0031     void hideCursor();
0032 
0033     QWidget *m_parentWidget;
0034     QTimer *m_timer;
0035     QStack<bool> m_cursorHidingEnabled;
0036 };