Wavelength
Privacy-focused, cross-platform, and open-source communication application
Loading...
Searching...
No Matches
create_wavelength_dialog.h
Go to the documentation of this file.
1#ifndef WAVELENGTH_DIALOG_H
2#define WAVELENGTH_DIALOG_H
3
4#include <QFuture>
5#include <QTimer>
6
7#include "animated_dialog.h"
8
9class CyberButton;
10class CyberLineEdit;
11class CyberCheckBox;
12class QLabel;
14
25 Q_OBJECT
32
33public:
42 explicit CreateWavelengthDialog(QWidget *parent = nullptr);
43
47 ~CreateWavelengthDialog() override;
48
51
53 void SetDigitalizationProgress(double progress);
54
57
59 void SetCornerGlowProgress(double progress);
60
62 double GetScanlineOpacity() const { return scanline_opacity_; }
63
65 void SetScanlineOpacity(double opacity);
66
68 QTimer *GetRefreshTimer() const { return refresh_timer_; }
70 void StartRefreshTimer() const {
71 if (refresh_timer_) {
72 refresh_timer_->start();
73 }
74 }
75
77 void StopRefreshTimer() const {
78 if (refresh_timer_) {
79 refresh_timer_->stop();
80 }
81 }
82
84 void SetRefreshTimerInterval(const int interval) const {
85 if (refresh_timer_) {
86 refresh_timer_->setInterval(interval);
87 }
88 }
89
94 QString GetFrequency() const {
95 return frequency_;
96 }
97
102 bool IsPasswordProtected() const;
103
108 QString GetPassword() const;
109
110protected:
118 void paintEvent(QPaintEvent *event) override;
119
120private slots:
126 void ValidateInputs() const;
127
133
139 void TryGenerate();
140
146 void OnFrequencyFound();
147
153 static QString FormatFrequencyText(double frequency);
154
155private:
162 static QString FindLowestAvailableFrequency();
163
169 void InitRenderBuffers();
170
172 bool animation_started_ = false;
188 QFutureWatcher<QString> *frequency_watcher_;
192 QString frequency_ = "130.0";
194 bool frequency_found_ = false;
207};
208
209#endif // WAVELENGTH_DIALOG_H
AnimatedDialog(QWidget *parent=nullptr, AnimationType type=kSlideFromBottom)
Constructs an AnimatedDialog. Sets necessary window flags and attributes for transparency and animati...
Definition animated_dialog.cpp:14
double corner_glow_progress_
Progress property (0.0 to 1.0) potentially for corner glow effects. Animatable.
Definition animated_dialog.h:81
double digitalization_progress_
Progress property (0.0 to 1.0) for the digital materialization effect. Animatable.
Definition animated_dialog.h:79
CyberButton * cancel_button_
Button to cancel the dialog.
Definition create_wavelength_dialog.h:186
double GetDigitalizationProgress() const
Gets the current digitalization progress (vertical scanline position).
Definition create_wavelength_dialog.h:50
double scanlineOpacity
Property controlling the opacity of the horizontal scanlines effect (0.0 to 1.0). Animatable.
Definition create_wavelength_dialog.h:27
QString GetFrequency() const
Gets the frequency assigned by the server (or the default if search failed).
Definition create_wavelength_dialog.h:94
void OnFrequencyFound()
Slot triggered when the frequency search (FindLowestAvailableFrequency) completes....
Definition create_wavelength_dialog.cpp:401
QLabel * status_label_
Label to display status or error messages.
Definition create_wavelength_dialog.h:182
QLabel * loading_indicator_
Label indicating that the frequency search is in progress.
Definition create_wavelength_dialog.h:176
void ValidateInputs() const
Validates the input fields (currently just the password if protection is enabled)....
Definition create_wavelength_dialog.cpp:345
CyberLineEdit * password_edit_
Input field for the wavelength password.
Definition create_wavelength_dialog.h:180
void TryGenerate()
Attempts to finalize the wavelength generation process. Checks if a password is required and entered....
Definition create_wavelength_dialog.cpp:380
double digitalizationProgress
Property controlling the progress of the main vertical scanline reveal animation (0....
Definition create_wavelength_dialog.h:29
double GetCornerGlowProgress() const
Gets the current corner glow progress.
Definition create_wavelength_dialog.h:56
QLabel * frequency_label_
Label displaying the assigned frequency.
Definition create_wavelength_dialog.h:174
bool IsPasswordProtected() const
Checks if the "Password Protected" checkbox is checked.
Definition create_wavelength_dialog.cpp:236
CyberCheckBox * password_protected_checkbox_
Checkbox to enable/disable password protection.
Definition create_wavelength_dialog.h:178
int last_scanline_y_
Stores the last Y position of the scanline to optimize repaint regions.
Definition create_wavelength_dialog.h:202
void StopRefreshTimer() const
Stops the refresh timer.
Definition create_wavelength_dialog.h:77
CyberButton * generate_button_
Button to confirm wavelength creation and close the dialog.
Definition create_wavelength_dialog.h:184
double cornerGlowProgress
Property controlling the visibility/intensity of the corner highlight markers (0.0 to 1....
Definition create_wavelength_dialog.h:31
void SetCornerGlowProgress(double progress)
Sets the corner glow progress and triggers a repaint.
Definition create_wavelength_dialog.cpp:226
QTimer * refresh_timer_
Timer used to trigger repaints for the vertical scanline animation.
Definition create_wavelength_dialog.h:190
double GetScanlineOpacity() const
Gets the current opacity of the horizontal scanlines.
Definition create_wavelength_dialog.h:62
static QString FormatFrequencyText(double frequency)
Static utility function to format a frequency value (double) into a display string with units (Hz,...
Definition create_wavelength_dialog.cpp:465
static QString FindLowestAvailableFrequency()
Static function executed concurrently to query the relay server for the next available frequency....
Definition create_wavelength_dialog.cpp:484
TranslationManager * translator_
Pointer to the translation manager for handling UI translations.
Definition create_wavelength_dialog.h:206
int previous_height_
Stores the previous height to detect resize events for buffer reinitialization.
Definition create_wavelength_dialog.h:204
void InitRenderBuffers()
Initializes or reinitializes the QPixmap buffer used for rendering the vertical scanline effect....
Definition create_wavelength_dialog.cpp:532
void paintEvent(QPaintEvent *event) override
Overridden paint event handler. Draws the custom dialog appearance. Renders the background gradient,...
Definition create_wavelength_dialog.cpp:244
void StartFrequencySearch()
Starts the asynchronous process of finding the lowest available frequency via the relay server....
Definition create_wavelength_dialog.cpp:356
bool frequency_found_
Flag indicating if the frequency search has completed successfully or timed out.
Definition create_wavelength_dialog.h:194
bool buffers_initialized_
Flag indicating if the render buffers (scanline_buffer_) have been initialized.
Definition create_wavelength_dialog.h:200
QFutureWatcher< QString > * frequency_watcher_
Watches the QFuture returned by the concurrent frequency search.
Definition create_wavelength_dialog.h:188
QPixmap scanline_buffer_
Buffer holding the pre-rendered vertical scanline gradient.
Definition create_wavelength_dialog.h:198
void SetRefreshTimerInterval(const int interval) const
Sets the interval for the refresh timer.
Definition create_wavelength_dialog.h:84
void SetScanlineOpacity(double opacity)
Sets the opacity of the horizontal scanlines and triggers a repaint.
Definition create_wavelength_dialog.cpp:231
CreateWavelengthDialog(QWidget *parent=nullptr)
Constructs a WavelengthDialog. Sets up the UI elements (labels, input fields, buttons,...
Definition create_wavelength_dialog.cpp:27
QString frequency_
Stores the frequency found by the server or the default value.
Definition create_wavelength_dialog.h:192
double scanline_opacity_
Current opacity for the horizontal scanline effect.
Definition create_wavelength_dialog.h:196
QTimer * GetRefreshTimer() const
Gets a pointer to the internal refresh timer used for scanline animation updates.
Definition create_wavelength_dialog.h:68
void StartRefreshTimer() const
Starts the refresh timer.
Definition create_wavelength_dialog.h:70
void SetDigitalizationProgress(double progress)
Sets the digitalization progress and triggers a repaint. Starts the refresh timer if needed.
Definition create_wavelength_dialog.cpp:219
QString GetPassword() const
Gets the password entered by the user.
Definition create_wavelength_dialog.cpp:240
bool animation_started_
Flag indicating if the show animation has started (used to control scanline drawing).
Definition create_wavelength_dialog.h:172
A custom QPushButton styled with a cyberpunk aesthetic.
Definition cyber_button.h:14
A custom QCheckBox styled with a cyberpunk aesthetic.
Definition cyber_checkbox.h:14
A custom QLineEdit styled with a cyberpunk aesthetic.
Definition cyber_line_edit.h:13
Manages the loading and delivery of translations for applications.
Definition translation_manager.h:15