Refactoring and documentation

This commit is contained in:
Anika Raemer 2021-08-28 14:08:02 +02:00
parent 87a208d305
commit 3fb5be5a74
10 changed files with 149 additions and 75 deletions

View file

@ -15,19 +15,44 @@ class MouseEventSpy : public QObject
Q_OBJECT
protected:
explicit MouseEventSpy(QObject *parent = 0);
explicit MouseEventSpy(QObject *parent = nullptr) : QObject(parent) { /* nothing */ }
signals:
void mouseEventDetected();
public:
/**
* @brief Create instance if necessary.
*
* If no instance has been created yet, create new instance and install it as event filter
* in QGuiApplication.
*
* @see MouseEventSpy::instance()
*/
static void init();
/**
* @brief Implements the singleton pattern.
* @return Instance of MouseEventSpy
*
* If no instance has been created yet, create new instance and install it as event filter
* in QGuiApplication.
*/
static MouseEventSpy* instance();
protected:
/**
* @brief Expand QObject::eventFilter to react to MouseEvents.
*
* Restart timer each time a mouse event is detected.
*/
bool eventFilter(QObject* watched, QEvent* event);
private:
/**
* @brief Checks whether the event type is a mouse event.
* @param t Event type
* @return Returns whether the event type is a mouse event.
*/
bool isMouseEvent(QEvent::Type t);
};