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

A security layer simulating fingerprint authentication. More...

#include <fingerprint_layer.h>

Inheritance diagram for FingerprintLayer:
Collaboration diagram for FingerprintLayer:

Public Member Functions

 FingerprintLayer (QWidget *parent=nullptr)
 Constructs a FingerprintLayer. Initializes the UI elements (title, fingerprint image label, instructions, progress bar), sets up the layout, creates the progress timer, loads the list of available fingerprint SVG files, and initializes the SVG renderer.
 
void Initialize () override
 Initializes the layer for display. Resets the progress bar and styles, loads a random fingerprint image, and ensures the layer is fully opaque.
 
void Reset () override
 Resets the layer to its initial state. Stops the progress timer, resets the progress bar value and style, resets the fingerprint image style, restores the base fingerprint image, and ensures the layer is fully opaque.
 
 ~FingerprintLayer () override
 Destructor. Stops and deletes the progress timer and the SVG renderer.
 
- Public Member Functions inherited from SecurityLayer
 SecurityLayer (QWidget *parent=nullptr)
 Constructs a SecurityLayer.
 
 ~SecurityLayer () override=default
 Virtual destructor. Ensures proper cleanup for derived classes.
 

Private Slots

void ProcessFingerprint (bool completed)
 Handles the completion of the fingerprint scan. Changes the UI element styles (border, progress bar chunk) to green, updates the fingerprint image to be fully green, and initiates the fade-out animation after a short delay.
 
void UpdateProgress ()
 Slot called periodically by fingerprint_timer_ when the user is holding the mouse button. Increments the progress bar value, updates the visual appearance of the fingerprint scan, and calls ProcessFingerprint(true) when the progress reaches 100%.
 

Private Member Functions

bool eventFilter (QObject *obj, QEvent *event) override
 Filters mouse press and release events on the fingerprint_image_ label. Starts the fingerprint_timer_ on left mouse button press and stops it on release.
 
void LoadRandomFingerprint ()
 Loads a random fingerprint SVG file from fingerprint_files_ and renders it into base_fingerprint_. Handles potential loading errors. Sets the initial pixmap on fingerprint_image_.
 
void UpdateFingerprintScan (int progress_value) const
 Updates the visual appearance of the fingerprint image during the scan. Renders the SVG and applies a color overlay: gray for the unscanned part and blue for the scanned part, based on the current progress value.
 

Private Attributes

QImage base_fingerprint_
 The base image of the fingerprint (rendered SVG in gray).
 
QString current_fingerprint_
 Path to the currently loaded fingerprint SVG file.
 
QStringList fingerprint_files_
 List of paths to available fingerprint SVG files.
 
QLabel * fingerprint_image_
 Label displaying the fingerprint image.
 
QProgressBar * fingerprint_progress_
 Progress bar indicating the scan progress.
 
QTimer * fingerprint_timer_
 Timer controlling the progress update while the mouse button is held.
 
QSvgRenderer * svg_renderer_
 Renderer used to load and draw SVG fingerprint images.
 

Additional Inherited Members

- Signals inherited from SecurityLayer
void layerCompleted ()
 Emitted when the user successfully completes the security challenge presented by this layer.
 
void layerFailed ()
 Emitted when the user fails the security challenge (e.g., incorrect code, timeout, collision). Note: Not all layers currently implement failure conditions that emit this signal.
 

Detailed Description

A security layer simulating fingerprint authentication.

This layer displays a fingerprint image (loaded from an SVG file) and requires the user to press and hold on the image. A progress bar fills up while the user holds the mouse button. The fingerprint image visually updates during the "scan" process, changing color from gray to blue as the progress increases. Upon successful completion (progress reaches 100%), the UI elements turn green, and the layer fades out, emitting the layerCompleted() signal.

Constructor & Destructor Documentation

◆ FingerprintLayer()

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

Constructs a FingerprintLayer. Initializes the UI elements (title, fingerprint image label, instructions, progress bar), sets up the layout, creates the progress timer, loads the list of available fingerprint SVG files, and initializes the SVG renderer.

Parameters
parentOptional parent widget.
Here is the call graph for this function:

◆ ~FingerprintLayer()

FingerprintLayer::~FingerprintLayer ( )
override

Destructor. Stops and deletes the progress timer and the SVG renderer.

Member Function Documentation

◆ eventFilter()

bool FingerprintLayer::eventFilter ( QObject * obj,
QEvent * event )
overrideprivate

Filters mouse press and release events on the fingerprint_image_ label. Starts the fingerprint_timer_ on left mouse button press and stops it on release.

Parameters
objThe object that generated the event.
eventThe event being processed.
Returns
True if the event was handled (mouse press/release on the image), false otherwise.

◆ Initialize()

void FingerprintLayer::Initialize ( )
overridevirtual

Initializes the layer for display. Resets the progress bar and styles, loads a random fingerprint image, and ensures the layer is fully opaque.

Implements SecurityLayer.

Here is the call graph for this function:

◆ LoadRandomFingerprint()

void FingerprintLayer::LoadRandomFingerprint ( )
private

Loads a random fingerprint SVG file from fingerprint_files_ and renders it into base_fingerprint_. Handles potential loading errors. Sets the initial pixmap on fingerprint_image_.

Here is the caller graph for this function:

◆ ProcessFingerprint

void FingerprintLayer::ProcessFingerprint ( bool completed)
privateslot

Handles the completion of the fingerprint scan. Changes the UI element styles (border, progress bar chunk) to green, updates the fingerprint image to be fully green, and initiates the fade-out animation after a short delay.

Parameters
completedAlways true in the current implementation, indicating successful completion.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Reset()

void FingerprintLayer::Reset ( )
overridevirtual

Resets the layer to its initial state. Stops the progress timer, resets the progress bar value and style, resets the fingerprint image style, restores the base fingerprint image, and ensures the layer is fully opaque.

Implements SecurityLayer.

Here is the caller graph for this function:

◆ UpdateFingerprintScan()

void FingerprintLayer::UpdateFingerprintScan ( int progress_value) const
private

Updates the visual appearance of the fingerprint image during the scan. Renders the SVG and applies a color overlay: gray for the unscanned part and blue for the scanned part, based on the current progress value.

Parameters
progress_valueThe current progress percentage (0-100).
Here is the caller graph for this function:

◆ UpdateProgress

void FingerprintLayer::UpdateProgress ( )
privateslot

Slot called periodically by fingerprint_timer_ when the user is holding the mouse button. Increments the progress bar value, updates the visual appearance of the fingerprint scan, and calls ProcessFingerprint(true) when the progress reaches 100%.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ base_fingerprint_

QImage FingerprintLayer::base_fingerprint_
private

The base image of the fingerprint (rendered SVG in gray).

◆ current_fingerprint_

QString FingerprintLayer::current_fingerprint_
private

Path to the currently loaded fingerprint SVG file.

◆ fingerprint_files_

QStringList FingerprintLayer::fingerprint_files_
private

List of paths to available fingerprint SVG files.

◆ fingerprint_image_

QLabel* FingerprintLayer::fingerprint_image_
private

Label displaying the fingerprint image.

◆ fingerprint_progress_

QProgressBar* FingerprintLayer::fingerprint_progress_
private

Progress bar indicating the scan progress.

◆ fingerprint_timer_

QTimer* FingerprintLayer::fingerprint_timer_
private

Timer controlling the progress update while the mouse button is held.

◆ svg_renderer_

QSvgRenderer* FingerprintLayer::svg_renderer_
private

Renderer used to load and draw SVG fingerprint images.


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