Wavelength
Privacy-focused, cross-platform, and open-source communication application
Loading...
Searching...
No Matches
OverlayWidget Class Referencefinal

A semi-transparent overlay widget used to dim the background content. More...

#include <overlay_widget.h>

Inheritance diagram for OverlayWidget:
Collaboration diagram for OverlayWidget:

Public Member Functions

qreal GetOpacity () const
 Gets the current opacity of the overlay.
 
 OverlayWidget (QWidget *parent=nullptr)
 Constructs an OverlayWidget. Sets necessary widget attributes for transparency and event handling. Installs an event filter on the parent to track resize events. Attempts to find a Navbar child in the parent to exclude its area.
 
void SetOpacity (qreal opacity)
 Sets the opacity of the overlay. Triggers a repaint of the widget.
 
void UpdateGeometry (const QRect &rect)
 Updates the geometry of the overlay widget. Typically called when the parent widget resizes.
 

Protected Member Functions

bool eventFilter (QObject *watched, QEvent *event) override
 Filters events from the parent widget. Specifically, watches for Resize events on the parent to call UpdateGeometry().
 
void paintEvent (QPaintEvent *event) override
 Overridden paint event handler. Draws the semi-transparent overlay. Fills the widget's area with a black color whose alpha is determined by opacity_. Excludes the exclude_rect_ area from being painted using clipping.
 

Properties

qreal opacity
 Property controlling the opacity of the overlay (0.0 = transparent, 1.0 = fully opaque black). Animatable.
 

Private Attributes

QRect exclude_rect_
 Rectangle defining an area (e.g., Navbar) to be excluded from the dimming effect.
 
qreal opacity_
 Current opacity level of the overlay (0.0 to 1.0).
 

Detailed Description

A semi-transparent overlay widget used to dim the background content.

This widget is typically placed over another widget (its parent) to create a dimming effect, often used when a modal dialog or sidebar is shown. It can exclude a specific rectangular area (like a navigation bar) from being dimmed. The opacity of the overlay can be animated. It automatically resizes to match its parent widget.

Constructor & Destructor Documentation

◆ OverlayWidget()

OverlayWidget::OverlayWidget ( QWidget * parent = nullptr)
explicit

Constructs an OverlayWidget. Sets necessary widget attributes for transparency and event handling. Installs an event filter on the parent to track resize events. Attempts to find a Navbar child in the parent to exclude its area.

Parameters
parentThe parent widget over which the overlay will be displayed.

Member Function Documentation

◆ eventFilter()

bool OverlayWidget::eventFilter ( QObject * watched,
QEvent * event )
overrideprotected

Filters events from the parent widget. Specifically, watches for Resize events on the parent to call UpdateGeometry().

Parameters
watchedThe object that generated the event.
eventThe event being processed.
Returns
True if the event was handled, false otherwise.
Here is the call graph for this function:

◆ GetOpacity()

qreal OverlayWidget::GetOpacity ( ) const
inline

Gets the current opacity of the overlay.

Returns
The current opacity value (0.0 to 1.0).

◆ paintEvent()

void OverlayWidget::paintEvent ( QPaintEvent * event)
overrideprotected

Overridden paint event handler. Draws the semi-transparent overlay. Fills the widget's area with a black color whose alpha is determined by opacity_. Excludes the exclude_rect_ area from being painted using clipping.

Parameters
eventThe paint event.

◆ SetOpacity()

void OverlayWidget::SetOpacity ( qreal opacity)

Sets the opacity of the overlay. Triggers a repaint of the widget.

Parameters
opacityThe desired opacity (0.0 to 1.0).

◆ UpdateGeometry()

void OverlayWidget::UpdateGeometry ( const QRect & rect)

Updates the geometry of the overlay widget. Typically called when the parent widget resizes.

Parameters
rectThe new geometry rectangle, usually matching the parent's bounds.
Here is the caller graph for this function:

Member Data Documentation

◆ exclude_rect_

QRect OverlayWidget::exclude_rect_
private

Rectangle defining an area (e.g., Navbar) to be excluded from the dimming effect.

◆ opacity_

qreal OverlayWidget::opacity_
private

Current opacity level of the overlay (0.0 to 1.0).

Property Documentation

◆ opacity

qreal OverlayWidget::opacity
readwrite

Property controlling the opacity of the overlay (0.0 = transparent, 1.0 = fully opaque black). Animatable.


The documentation for this class was generated from the following files: