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

A dialog window for creating a new Wavelength frequency. More...

#include <create_wavelength_dialog.h>

Inheritance diagram for CreateWavelengthDialog:
Collaboration diagram for CreateWavelengthDialog:

Public Member Functions

 CreateWavelengthDialog (QWidget *parent=nullptr)
 Constructs a WavelengthDialog. Sets up the UI elements (labels, input fields, buttons, checkbox), connects signals and slots for input validation and frequency searching/generation logic, configures the animation type and duration, and initializes the refresh timer for the scanline animation. Connects the show animation finished signal to start the frequency search.
 
double GetCornerGlowProgress () const
 Gets the current corner glow progress.
 
double GetDigitalizationProgress () const
 Gets the current digitalization progress (vertical scanline position).
 
QString GetFrequency () const
 Gets the frequency assigned by the server (or the default if search failed).
 
QString GetPassword () const
 Gets the password entered by the user.
 
QTimer * GetRefreshTimer () const
 Gets a pointer to the internal refresh timer used for scanline animation updates.
 
double GetScanlineOpacity () const
 Gets the current opacity of the horizontal scanlines.
 
bool IsPasswordProtected () const
 Checks if the "Password Protected" checkbox is checked.
 
void SetCornerGlowProgress (double progress)
 Sets the corner glow progress and triggers a repaint.
 
void SetDigitalizationProgress (double progress)
 Sets the digitalization progress and triggers a repaint. Starts the refresh timer if needed.
 
void SetRefreshTimerInterval (const int interval) const
 Sets the interval for the refresh timer.
 
void SetScanlineOpacity (double opacity)
 Sets the opacity of the horizontal scanlines and triggers a repaint.
 
void StartRefreshTimer () const
 Starts the refresh timer.
 
void StopRefreshTimer () const
 Stops the refresh timer.
 
 ~CreateWavelengthDialog () override
 Destructor. Stops and deletes the refresh timer.
 
- Public Member Functions inherited from AnimatedDialog
 AnimatedDialog (QWidget *parent=nullptr, AnimationType type=kSlideFromBottom)
 Constructs an AnimatedDialog. Sets necessary window flags and attributes for transparency and animation.
 
int GetAnimationDuration () const
 Gets the current duration for the show and close animations.
 
void SetAnimationDuration (const int duration)
 Sets the duration for the show and close animations.
 
 ~AnimatedDialog () override
 Destructor. Ensures the overlay widget is cleaned up.
 

Protected Member Functions

void paintEvent (QPaintEvent *event) override
 Overridden paint event handler. Draws the custom dialog appearance. Renders the background gradient, clipped border, the main vertical scanline reveal effect, corner highlight markers, and the horizontal scanline overlay effect based on the corresponding progress/opacity properties.
 
- Protected Member Functions inherited from AnimatedDialog
void closeEvent (QCloseEvent *event) override
 Overridden close event handler. Prevents immediate closing, starts the close animation (AnimateClose), and fades out the overlay. The actual QDialog::close() is called when the animation finishes.
 
void showEvent (QShowEvent *event) override
 Overridden show event handler. Creates and shows the overlay widget (if applicable), then starts the show animation (AnimateShow).
 

Properties

double cornerGlowProgress
 Property controlling the visibility/intensity of the corner highlight markers (0.0 to 1.0). Animatable.
 
double digitalizationProgress
 Property controlling the progress of the main vertical scanline reveal animation (0.0 to 1.0). Animatable.
 
double scanlineOpacity
 Property controlling the opacity of the horizontal scanlines effect (0.0 to 1.0). Animatable.
 

Private Slots

static QString FormatFrequencyText (double frequency)
 Static utility function to format a frequency value (double) into a display string with units (Hz, kHz, MHz).
 
void OnFrequencyFound ()
 Slot triggered when the frequency search (FindLowestAvailableFrequency) completes. Updates the frequency label with the found frequency (or default), hides the loading indicator, enables the generate button (if inputs are valid), and triggers animations.
 
void StartFrequencySearch ()
 Starts the asynchronous process of finding the lowest available frequency via the relay server. Called automatically after the show animation finishes. Sets up a timeout for the search.
 
void TryGenerate ()
 Attempts to finalize the wavelength generation process. Checks if a password is required and entered. If valid, accepts the dialog. Uses a static flag to prevent concurrent attempts.
 
void ValidateInputs () const
 Validates the input fields (currently just the password if protection is enabled). Enables the "Create Wavelength" button only if inputs are valid and a frequency has been found. Hides the status label.
 

Private Member Functions

void InitRenderBuffers ()
 Initializes or reinitializes the QPixmap buffer used for rendering the vertical scanline effect. Called when needed by paintEvent, typically on the first paint or after a resize. Creates a pixmap with a vertical gradient representing the scanline glow.
 

Static Private Member Functions

static QString FindLowestAvailableFrequency ()
 Static function executed concurrently to query the relay server for the next available frequency. Sends an HTTP GET request to the server's API endpoint, optionally providing a preferred starting frequency. Parses the JSON response to extract the frequency. Returns a default value on error or timeout.
 

Private Attributes

bool animation_started_ = false
 Flag indicating if the show animation has started (used to control scanline drawing).
 
bool buffers_initialized_ = false
 Flag indicating if the render buffers (scanline_buffer_) have been initialized.
 
CyberButtoncancel_button_
 Button to cancel the dialog.
 
QString frequency_ = "130.0"
 Stores the frequency found by the server or the default value.
 
bool frequency_found_ = false
 Flag indicating if the frequency search has completed successfully or timed out.
 
QLabel * frequency_label_
 Label displaying the assigned frequency.
 
QFutureWatcher< QString > * frequency_watcher_
 Watches the QFuture returned by the concurrent frequency search.
 
CyberButtongenerate_button_
 Button to confirm wavelength creation and close the dialog.
 
int last_scanline_y_ = -1
 Stores the last Y position of the scanline to optimize repaint regions.
 
QLabel * loading_indicator_
 Label indicating that the frequency search is in progress.
 
CyberLineEditpassword_edit_
 Input field for the wavelength password.
 
CyberCheckBoxpassword_protected_checkbox_
 Checkbox to enable/disable password protection.
 
int previous_height_ = 0
 Stores the previous height to detect resize events for buffer reinitialization.
 
QTimer * refresh_timer_
 Timer used to trigger repaints for the vertical scanline animation.
 
QPixmap scanline_buffer_
 Buffer holding the pre-rendered vertical scanline gradient.
 
double scanline_opacity_
 Current opacity for the horizontal scanline effect.
 
QLabel * status_label_
 Label to display status or error messages.
 
TranslationManagertranslator_ = nullptr
 Pointer to the translation manager for handling UI translations.
 

Additional Inherited Members

- Public Types inherited from AnimatedDialog
enum  AnimationType { kSlideFromBottom , kDigitalMaterialization }
 Enum defining the available animation styles for showing and closing the dialog. More...
 
- Signals inherited from AnimatedDialog
void showAnimationFinished ()
 Emitted when the show animation (AnimateShow) has finished.
 
- Protected Attributes inherited from AnimatedDialog
double corner_glow_progress_ = 0.0
 Progress property (0.0 to 1.0) potentially for corner glow effects. Animatable.
 
double digitalization_progress_ = 0.0
 Progress property (0.0 to 1.0) for the digital materialization effect. Animatable.
 

Detailed Description

A dialog window for creating a new Wavelength frequency.

This class provides a user interface for initiating the creation of a new Wavelength session. It automatically searches for the lowest available frequency via a relay server, allows setting a password, and displays the assigned frequency. It inherits from AnimatedDialog to provide a "digital materialization" animation effect on show/close, featuring a moving scanline. It includes input validation and interacts with the relay server API to find an available frequency.

Constructor & Destructor Documentation

◆ CreateWavelengthDialog()

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

Constructs a WavelengthDialog. Sets up the UI elements (labels, input fields, buttons, checkbox), connects signals and slots for input validation and frequency searching/generation logic, configures the animation type and duration, and initializes the refresh timer for the scanline animation. Connects the show animation finished signal to start the frequency search.

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

◆ ~CreateWavelengthDialog()

CreateWavelengthDialog::~CreateWavelengthDialog ( )
override

Destructor. Stops and deletes the refresh timer.

Member Function Documentation

◆ FindLowestAvailableFrequency()

QString CreateWavelengthDialog::FindLowestAvailableFrequency ( )
staticprivate

Static function executed concurrently to query the relay server for the next available frequency. Sends an HTTP GET request to the server's API endpoint, optionally providing a preferred starting frequency. Parses the JSON response to extract the frequency. Returns a default value on error or timeout.

Returns
The available frequency as a string (e.g., "130.0"), or a default value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FormatFrequencyText

QString CreateWavelengthDialog::FormatFrequencyText ( double frequency)
staticprivateslot

Static utility function to format a frequency value (double) into a display string with units (Hz, kHz, MHz).

Parameters
frequencyThe frequency value in Hz.
Returns
A formatted string (e.g., "1.3 MHz").

◆ GetCornerGlowProgress()

double CreateWavelengthDialog::GetCornerGlowProgress ( ) const
inline

Gets the current corner glow progress.

◆ GetDigitalizationProgress()

double CreateWavelengthDialog::GetDigitalizationProgress ( ) const
inline

Gets the current digitalization progress (vertical scanline position).

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

◆ GetFrequency()

QString CreateWavelengthDialog::GetFrequency ( ) const
inline

Gets the frequency assigned by the server (or the default if search failed).

Returns
The frequency string (e.g., "130.0").

◆ GetPassword()

QString CreateWavelengthDialog::GetPassword ( ) const

Gets the password entered by the user.

Returns
The password string.

◆ GetRefreshTimer()

QTimer * CreateWavelengthDialog::GetRefreshTimer ( ) const
inline

Gets a pointer to the internal refresh timer used for scanline animation updates.

◆ GetScanlineOpacity()

double CreateWavelengthDialog::GetScanlineOpacity ( ) const
inline

Gets the current opacity of the horizontal scanlines.

◆ InitRenderBuffers()

void CreateWavelengthDialog::InitRenderBuffers ( )
private

Initializes or reinitializes the QPixmap buffer used for rendering the vertical scanline effect. Called when needed by paintEvent, typically on the first paint or after a resize. Creates a pixmap with a vertical gradient representing the scanline glow.

Here is the caller graph for this function:

◆ IsPasswordProtected()

bool CreateWavelengthDialog::IsPasswordProtected ( ) const

Checks if the "Password Protected" checkbox is checked.

Returns
True if the checkbox is checked, false otherwise.

◆ OnFrequencyFound

void CreateWavelengthDialog::OnFrequencyFound ( )
privateslot

Slot triggered when the frequency search (FindLowestAvailableFrequency) completes. Updates the frequency label with the found frequency (or default), hides the loading indicator, enables the generate button (if inputs are valid), and triggers animations.

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

◆ paintEvent()

void CreateWavelengthDialog::paintEvent ( QPaintEvent * event)
overrideprotected

Overridden paint event handler. Draws the custom dialog appearance. Renders the background gradient, clipped border, the main vertical scanline reveal effect, corner highlight markers, and the horizontal scanline overlay effect based on the corresponding progress/opacity properties.

Parameters
eventThe paint event.
Here is the call graph for this function:

◆ SetCornerGlowProgress()

void CreateWavelengthDialog::SetCornerGlowProgress ( double progress)

Sets the corner glow progress and triggers a repaint.

◆ SetDigitalizationProgress()

void CreateWavelengthDialog::SetDigitalizationProgress ( double progress)

Sets the digitalization progress and triggers a repaint. Starts the refresh timer if needed.

◆ SetRefreshTimerInterval()

void CreateWavelengthDialog::SetRefreshTimerInterval ( const int interval) const
inline

Sets the interval for the refresh timer.

◆ SetScanlineOpacity()

void CreateWavelengthDialog::SetScanlineOpacity ( double opacity)

Sets the opacity of the horizontal scanlines and triggers a repaint.

◆ StartFrequencySearch

void CreateWavelengthDialog::StartFrequencySearch ( )
privateslot

Starts the asynchronous process of finding the lowest available frequency via the relay server. Called automatically after the show animation finishes. Sets up a timeout for the search.

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

◆ StartRefreshTimer()

void CreateWavelengthDialog::StartRefreshTimer ( ) const
inline

Starts the refresh timer.

◆ StopRefreshTimer()

void CreateWavelengthDialog::StopRefreshTimer ( ) const
inline

Stops the refresh timer.

◆ TryGenerate

void CreateWavelengthDialog::TryGenerate ( )
privateslot

Attempts to finalize the wavelength generation process. Checks if a password is required and entered. If valid, accepts the dialog. Uses a static flag to prevent concurrent attempts.

Here is the caller graph for this function:

◆ ValidateInputs

void CreateWavelengthDialog::ValidateInputs ( ) const
privateslot

Validates the input fields (currently just the password if protection is enabled). Enables the "Create Wavelength" button only if inputs are valid and a frequency has been found. Hides the status label.

Here is the caller graph for this function:

Member Data Documentation

◆ animation_started_

bool CreateWavelengthDialog::animation_started_ = false
private

Flag indicating if the show animation has started (used to control scanline drawing).

◆ buffers_initialized_

bool CreateWavelengthDialog::buffers_initialized_ = false
private

Flag indicating if the render buffers (scanline_buffer_) have been initialized.

◆ cancel_button_

CyberButton* CreateWavelengthDialog::cancel_button_
private

Button to cancel the dialog.

◆ frequency_

QString CreateWavelengthDialog::frequency_ = "130.0"
private

Stores the frequency found by the server or the default value.

◆ frequency_found_

bool CreateWavelengthDialog::frequency_found_ = false
private

Flag indicating if the frequency search has completed successfully or timed out.

◆ frequency_label_

QLabel* CreateWavelengthDialog::frequency_label_
private

Label displaying the assigned frequency.

◆ frequency_watcher_

QFutureWatcher<QString>* CreateWavelengthDialog::frequency_watcher_
private

Watches the QFuture returned by the concurrent frequency search.

◆ generate_button_

CyberButton* CreateWavelengthDialog::generate_button_
private

Button to confirm wavelength creation and close the dialog.

◆ last_scanline_y_

int CreateWavelengthDialog::last_scanline_y_ = -1
private

Stores the last Y position of the scanline to optimize repaint regions.

◆ loading_indicator_

QLabel* CreateWavelengthDialog::loading_indicator_
private

Label indicating that the frequency search is in progress.

◆ password_edit_

CyberLineEdit* CreateWavelengthDialog::password_edit_
private

Input field for the wavelength password.

◆ password_protected_checkbox_

CyberCheckBox* CreateWavelengthDialog::password_protected_checkbox_
private

Checkbox to enable/disable password protection.

◆ previous_height_

int CreateWavelengthDialog::previous_height_ = 0
private

Stores the previous height to detect resize events for buffer reinitialization.

◆ refresh_timer_

QTimer* CreateWavelengthDialog::refresh_timer_
private

Timer used to trigger repaints for the vertical scanline animation.

◆ scanline_buffer_

QPixmap CreateWavelengthDialog::scanline_buffer_
private

Buffer holding the pre-rendered vertical scanline gradient.

◆ scanline_opacity_

double CreateWavelengthDialog::scanline_opacity_
private

Current opacity for the horizontal scanline effect.

◆ status_label_

QLabel* CreateWavelengthDialog::status_label_
private

Label to display status or error messages.

◆ translator_

TranslationManager* CreateWavelengthDialog::translator_ = nullptr
private

Pointer to the translation manager for handling UI translations.

Property Documentation

◆ cornerGlowProgress

double CreateWavelengthDialog::cornerGlowProgress
readwrite

Property controlling the visibility/intensity of the corner highlight markers (0.0 to 1.0). Animatable.

◆ digitalizationProgress

double CreateWavelengthDialog::digitalizationProgress
readwrite

Property controlling the progress of the main vertical scanline reveal animation (0.0 to 1.0). Animatable.

◆ scanlineOpacity

double CreateWavelengthDialog::scanlineOpacity
readwrite

Property controlling the opacity of the horizontal scanlines effect (0.0 to 1.0). Animatable.


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