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

A widget that displays another widget (content) with a cyberpunk-themed decryption animation. More...

#include <attachment_viewer.h>

Inheritance diagram for AttachmentViewer:
Collaboration diagram for AttachmentViewer:

Signals

void decryptionCounterChanged (int value)
 Emitted when the decryptionCounter property changes. Connected to the MaskOverlay's SetRevealProgress slot.
 
void viewingFinished ()
 Emitted when the viewer is closed (either manually or automatically after decryption).
 

Public Member Functions

 AttachmentViewer (QWidget *parent=nullptr)
 Constructs a CyberAttachmentViewer. Initializes the layout, status label, content container, MaskOverlay, animation timer, and applies basic styling. Connects the decryptionCounter property to the MaskOverlay's progress.
 
int GetDecryptionCounter () const
 Gets the current decryption progress counter (0-100).
 
void SetContent (QWidget *content)
 Sets the widget to be displayed after the decryption animation. Removes any previous content, adds the new content widget to the layout, hides the content initially, shows and configures the MaskOverlay, resets the decryption state, and updates geometry.
 
void SetDecryptionCounter (int counter)
 Sets the decryption progress counter (0-100). Updates the internal value, updates the status label text, and emits decryptionCounterChanged.
 
QSize sizeHint () const override
 Returns the recommended size for the viewer based on its content and layout. Calculates the size needed to accommodate the status label and the content widget's size hint.
 
void UpdateContentLayout ()
 Forces an update of the content layout and geometry. Useful after the content widget's size changes dynamically. Notifies parent widgets.
 
 ~AttachmentViewer () override
 Destructor. Ensures graphics effects are removed from the content widget if set.
 

Protected Member Functions

void paintEvent (QPaintEvent *event) override
 Overridden paint event handler. Draws the custom cyberpunk border and AR markers. Renders the clipped border, decorative lines, corner markers, and status text (SEC level, LOCK status).
 
void resizeEvent (QResizeEvent *event) override
 Overridden resize event handler. Ensures the MaskOverlay is resized to match the content container's bounds.
 

Properties

int decryptionCounter
 Property controlling the decryption progress (0-100). Animatable. Drives the MaskOverlay reveal.
 

Private Slots

void CloseViewer ()
 Closes the viewer by emitting the viewingFinished signal.
 
void FinishDecryption ()
 Slot called when the decryption animation finishes. Sets the state to decrypted, updates the status label, stops and hides the MaskOverlay, and makes the actual content widget visible.
 
void OnActionButtonClicked ()
 Slot triggered automatically after a short delay or potentially by a user action (though currently automatic). Initiates the scanning animation if not already decrypted. If decrypted, closes the viewer.
 
void StartDecryptionAnimation ()
 Starts the decryption phase. Updates the status label, ensures the MaskOverlay is visible, and starts a QPropertyAnimation to animate the decryptionCounter property from 0 to 100.
 
void StartScanningAnimation ()
 Starts the visual scanning phase. Updates the status label, ensures the MaskOverlay is visible and animating its scanline. Schedules the start of the decryption animation after a delay.
 
void UpdateAnimation () const
 Slot called by animation_timer_ (if active) to update visual elements during animation. Adds random glitch characters to the status label text during decryption.
 
void UpdateDecryptionStatus () const
 Updates the status label text to show the current decryption percentage.
 

Private Attributes

QTimer * animation_timer_
 Timer potentially used for secondary animations (like status label glitches).
 
QWidget * content_container_
 Container widget holding the content_widget_ and mask_overlay_.
 
QVBoxLayout * content_layout_
 Layout for the content_container_.
 
QWidget * content_widget_ = nullptr
 Pointer to the widget being displayed (e.g., an image viewer).
 
int decryption_counter_
 Current decryption progress (0-100).
 
bool is_decrypted_
 Flag indicating if the decryption process has completed.
 
bool is_scanning_
 Flag indicating if the viewer is currently in the "scanning" phase.
 
QVBoxLayout * layout_
 Main layout for the viewer.
 
MaskOverlayEffectmask_overlay_
 The overlay widget that handles the scanline and reveal effect.
 
QLabel * status_label_
 Label displaying status messages (Scanning, Decrypting %, Finished).
 
TranslationManagertranslator_ = nullptr
 Pointer to the translation manager for handling UI translations.
 

Detailed Description

A widget that displays another widget (content) with a cyberpunk-themed decryption animation.

This viewer wraps a content widget and initially hides it behind a MaskOverlay. It simulates a scanning and decryption process:

  1. Initialization: Shows a status label and the MaskOverlay with a moving scanline.
  2. Scanning: Status label indicates scanning; MaskOverlay continues animating.
  3. Decryption: Status label shows decryption progress (0-100%); MaskOverlay reveals the content from top to bottom as the decryption progress increases (controlled by the decryptionCounter property).
  4. Finished: MaskOverlay is hidden, the actual content widget is shown, and the status label indicates completion.

The viewer itself has a cyberpunk-styled border and AR markers drawn in its paintEvent. It manages the lifecycle of the MaskOverlay and the visibility of the content widget.

Constructor & Destructor Documentation

◆ AttachmentViewer()

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

Constructs a CyberAttachmentViewer. Initializes the layout, status label, content container, MaskOverlay, animation timer, and applies basic styling. Connects the decryptionCounter property to the MaskOverlay's progress.

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

◆ ~AttachmentViewer()

AttachmentViewer::~AttachmentViewer ( )
override

Destructor. Ensures graphics effects are removed from the content widget if set.

Member Function Documentation

◆ CloseViewer

void AttachmentViewer::CloseViewer ( )
privateslot

Closes the viewer by emitting the viewingFinished signal.

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

◆ decryptionCounterChanged

void AttachmentViewer::decryptionCounterChanged ( int value)
signal

Emitted when the decryptionCounter property changes. Connected to the MaskOverlay's SetRevealProgress slot.

Parameters
valueThe new decryption counter-value (0-100).
Here is the caller graph for this function:

◆ FinishDecryption

void AttachmentViewer::FinishDecryption ( )
privateslot

Slot called when the decryption animation finishes. Sets the state to decrypted, updates the status label, stops and hides the MaskOverlay, and makes the actual content widget visible.

Here is the caller graph for this function:

◆ GetDecryptionCounter()

int AttachmentViewer::GetDecryptionCounter ( ) const
inline

Gets the current decryption progress counter (0-100).

Returns
The decryption counter-value.

◆ OnActionButtonClicked

void AttachmentViewer::OnActionButtonClicked ( )
privateslot

Slot triggered automatically after a short delay or potentially by a user action (though currently automatic). Initiates the scanning animation if not already decrypted. If decrypted, closes the viewer.

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

◆ paintEvent()

void AttachmentViewer::paintEvent ( QPaintEvent * event)
overrideprotected

Overridden paint event handler. Draws the custom cyberpunk border and AR markers. Renders the clipped border, decorative lines, corner markers, and status text (SEC level, LOCK status).

Parameters
eventThe paint event.

◆ resizeEvent()

void AttachmentViewer::resizeEvent ( QResizeEvent * event)
overrideprotected

Overridden resize event handler. Ensures the MaskOverlay is resized to match the content container's bounds.

Parameters
eventThe resize event.

◆ SetContent()

void AttachmentViewer::SetContent ( QWidget * content)

Sets the widget to be displayed after the decryption animation. Removes any previous content, adds the new content widget to the layout, hides the content initially, shows and configures the MaskOverlay, resets the decryption state, and updates geometry.

Parameters
contentPointer to the widget to display.
Here is the call graph for this function:

◆ SetDecryptionCounter()

void AttachmentViewer::SetDecryptionCounter ( int counter)

Sets the decryption progress counter (0-100). Updates the internal value, updates the status label text, and emits decryptionCounterChanged.

Parameters
counterThe new counter-value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sizeHint()

QSize AttachmentViewer::sizeHint ( ) const
override

Returns the recommended size for the viewer based on its content and layout. Calculates the size needed to accommodate the status label and the content widget's size hint.

Returns
The calculated QSize hint.
Here is the caller graph for this function:

◆ StartDecryptionAnimation

void AttachmentViewer::StartDecryptionAnimation ( )
privateslot

Starts the decryption phase. Updates the status label, ensures the MaskOverlay is visible, and starts a QPropertyAnimation to animate the decryptionCounter property from 0 to 100.

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

◆ StartScanningAnimation

void AttachmentViewer::StartScanningAnimation ( )
privateslot

Starts the visual scanning phase. Updates the status label, ensures the MaskOverlay is visible and animating its scanline. Schedules the start of the decryption animation after a delay.

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

◆ UpdateAnimation

void AttachmentViewer::UpdateAnimation ( ) const
privateslot

Slot called by animation_timer_ (if active) to update visual elements during animation. Adds random glitch characters to the status label text during decryption.

Here is the caller graph for this function:

◆ UpdateContentLayout()

void AttachmentViewer::UpdateContentLayout ( )

Forces an update of the content layout and geometry. Useful after the content widget's size changes dynamically. Notifies parent widgets.

◆ UpdateDecryptionStatus

void AttachmentViewer::UpdateDecryptionStatus ( ) const
privateslot

Updates the status label text to show the current decryption percentage.

Here is the caller graph for this function:

◆ viewingFinished

void AttachmentViewer::viewingFinished ( )
signal

Emitted when the viewer is closed (either manually or automatically after decryption).

Here is the caller graph for this function:

Member Data Documentation

◆ animation_timer_

QTimer* AttachmentViewer::animation_timer_
private

Timer potentially used for secondary animations (like status label glitches).

◆ content_container_

QWidget* AttachmentViewer::content_container_
private

Container widget holding the content_widget_ and mask_overlay_.

◆ content_layout_

QVBoxLayout* AttachmentViewer::content_layout_
private

Layout for the content_container_.

◆ content_widget_

QWidget* AttachmentViewer::content_widget_ = nullptr
private

Pointer to the widget being displayed (e.g., an image viewer).

◆ decryption_counter_

int AttachmentViewer::decryption_counter_
private

Current decryption progress (0-100).

◆ is_decrypted_

bool AttachmentViewer::is_decrypted_
private

Flag indicating if the decryption process has completed.

◆ is_scanning_

bool AttachmentViewer::is_scanning_
private

Flag indicating if the viewer is currently in the "scanning" phase.

◆ layout_

QVBoxLayout* AttachmentViewer::layout_
private

Main layout for the viewer.

◆ mask_overlay_

MaskOverlayEffect* AttachmentViewer::mask_overlay_
private

The overlay widget that handles the scanline and reveal effect.

◆ status_label_

QLabel* AttachmentViewer::status_label_
private

Label displaying status messages (Scanning, Decrypting %, Finished).

◆ translator_

TranslationManager* AttachmentViewer::translator_ = nullptr
private

Pointer to the translation manager for handling UI translations.

Property Documentation

◆ decryptionCounter

int AttachmentViewer::decryptionCounter
readwrite

Property controlling the decryption progress (0-100). Animatable. Drives the MaskOverlay reveal.


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