Wavelength
Privacy-focused, cross-platform, and open-source communication application
Loading...
Searching...
No Matches
blob_event_handler.h
Go to the documentation of this file.
1#ifndef BLOBEVENTHANDLER_H
2#define BLOBEVENTHANDLER_H
3
4#include <QObject>
5#include <QPointF>
6#include <QTimer>
7
8class QMoveEvent;
9class QResizeEvent;
10
21class BlobEventHandler final : public QObject {
22 Q_OBJECT
23
24public:
30 explicit BlobEventHandler(QWidget *parent_widget);
31
36 ~BlobEventHandler() override;
37
44 bool ProcessResizeEvent(const QResizeEvent *event);
45
53 bool eventFilter(QObject *watched, QEvent *event) override;
54
59 void EnableEvents();
60
65 void DisableEvents();
66
71 bool AreEventsEnabled() const { return events_enabled_; }
72
78 void SetTransitionInProgress(const bool inProgress) { transition_in_progress_ = inProgress; }
79
84 bool IsInTransition() const { return transition_in_progress_; }
85
86signals:
92 void windowMoved(const QPointF &new_position, qint64 timestamp);
93
100 void movementSampleAdded(const QPointF &position, qint64 timestamp);
101
107 void significantResizeDetected(const QSize &old_size, const QSize &new_size);
108
113
118
123
124private slots:
130
131private:
137 void HandleMoveEvent(const QMoveEvent *move_event);
138
145
153 bool is_resizing_ = false;
154};
155
156#endif // BLOBEVENTHANDLER_H
QTimer event_re_enable_timer_
Timer used for delayed re-enabling of events.
Definition blob_event_handler.h:151
bool transition_in_progress_
Flag indicating if a visual transition (e.g., animation) is in progress, potentially suppressing even...
Definition blob_event_handler.h:144
bool ProcessResizeEvent(const QResizeEvent *event)
Processes a resize event for the parent widget. Applies throttling and checks for significant size ch...
Definition blob_event_handler.cpp:29
void onEventReEnableTimeout()
Slot connected to the event_re_enable_timer_'s timeout signal. Calls EnableEvents() to re-enable even...
Definition blob_event_handler.cpp:116
~BlobEventHandler() override
Destructor. Removes the event filter from the parent widget's window.
Definition blob_event_handler.cpp:23
void EnableEvents()
Enables event processing. Emits the eventsReEnabled() signal.
Definition blob_event_handler.cpp:107
void significantResizeDetected(const QSize &old_size, const QSize &new_size)
Emitted when a significant resize event is detected after throttling.
void SetTransitionInProgress(const bool inProgress)
Sets the flag indicating whether a visual transition is in progress. When true, event processing migh...
Definition blob_event_handler.h:78
bool is_resizing_
Flag indicating if the window is currently being resized (used to potentially ignore move events duri...
Definition blob_event_handler.h:153
qint64 last_processed_move_time_
Timestamp (ms since epoch) of the last processed move event.
Definition blob_event_handler.h:149
void eventsReEnabled()
Emitted when event processing is re-enabled after being disabled.
bool IsInTransition() const
Checks if a visual transition is currently marked as in progress.
Definition blob_event_handler.h:84
void movementSampleAdded(const QPointF &position, qint64 timestamp)
Emitted periodically during window movement to provide samples for velocity calculation....
void stateResetTimerRequested()
Emitted after a resize event to request resetting any temporary state timers.
void DisableEvents()
Disables event processing. Filtered events will be ignored until EnableEvents() is called.
Definition blob_event_handler.cpp:112
bool eventFilter(QObject *watched, QEvent *event) override
Filters events installed on the parent widget's window. Specifically, intercepts and handles QEvent::...
Definition blob_event_handler.cpp:92
void windowMoved(const QPointF &new_position, qint64 timestamp)
Emitted when a significant window move event is detected after throttling.
QWidget * parent_widget_
Pointer to the parent widget whose window events are monitored.
Definition blob_event_handler.h:140
bool AreEventsEnabled() const
Checks if event processing is currently enabled.
Definition blob_event_handler.h:71
bool events_enabled_
Flag indicating whether event processing is currently enabled.
Definition blob_event_handler.h:142
void HandleMoveEvent(const QMoveEvent *move_event)
Handles the logic for processing QMoveEvent received by the event filter. Applies throttling based on...
Definition blob_event_handler.cpp:59
void resizeStateRequested()
Emitted during a resize event to request a specific "resizing" state in the Blob animation.
QPointF last_processed_position_
Stores the last window position that was processed after throttling.
Definition blob_event_handler.h:147
BlobEventHandler(QWidget *parent_widget)
Constructs a BlobEventHandler. Installs an event filter on the parent widget's window.
Definition blob_event_handler.cpp:7