Wavelength
Privacy-focused, cross-platform, and open-source communication application
Loading...
Searching...
No Matches
overlay_widget.h
Go to the documentation of this file.
1#ifndef OVERLAY_WIDGET_H
2#define OVERLAY_WIDGET_H
3
4#include <QWidget>
5
14class OverlayWidget final : public QWidget {
15 Q_OBJECT
17 Q_PROPERTY(qreal opacity READ GetOpacity WRITE SetOpacity)
18
19public:
26 explicit OverlayWidget(QWidget *parent = nullptr);
27
33 void UpdateGeometry(const QRect &rect);
34
39 qreal GetOpacity() const { return opacity_; }
40
46 void SetOpacity(qreal opacity);
47
48private:
50 qreal opacity_;
53
54protected:
62 bool eventFilter(QObject *watched, QEvent *event) override;
63
70 void paintEvent(QPaintEvent *event) override;
71};
72
73
74#endif //OVERLAY_WIDGET_H
qreal GetOpacity() const
Gets the current opacity of the overlay.
Definition overlay_widget.h:39
OverlayWidget(QWidget *parent=nullptr)
Constructs an OverlayWidget. Sets necessary widget attributes for transparency and event handling....
Definition overlay_widget.cpp:8
qreal opacity
Property controlling the opacity of the overlay (0.0 = transparent, 1.0 = fully opaque black)....
Definition overlay_widget.h:17
bool eventFilter(QObject *watched, QEvent *event) override
Filters events from the parent widget. Specifically, watches for Resize events on the parent to call ...
Definition overlay_widget.cpp:33
void paintEvent(QPaintEvent *event) override
Overridden paint event handler. Draws the semi-transparent overlay. Fills the widget's area with a bl...
Definition overlay_widget.cpp:47
void SetOpacity(qreal opacity)
Sets the opacity of the overlay. Triggers a repaint of the widget.
Definition overlay_widget.cpp:26
qreal opacity_
Current opacity level of the overlay (0.0 to 1.0).
Definition overlay_widget.h:50
QRect exclude_rect_
Rectangle defining an area (e.g., Navbar) to be excluded from the dimming effect.
Definition overlay_widget.h:52
void UpdateGeometry(const QRect &rect)
Updates the geometry of the overlay widget. Typically called when the parent widget resizes.
Definition overlay_widget.cpp:43