1#ifndef WAVELENGTH_CHAT_VIEW_H
2#define WAVELENGTH_CHAT_VIEW_H
53 explicit ChatView(QWidget *parent =
nullptr);
82 void SetWavelength(
const QString &frequency,
const QString &name = QString());
99 void OnMessageSent(
const QString &frequency,
const QString &message)
const;
163 void OnPttDenied(
const QString &frequency,
const QString &reason);
void OnReadyReadInput() const
Slot called when the audio input device has data ready to be read. Reads all available audio data,...
Definition chat_view.cpp:456
void StartAudioInput()
Starts capturing audio from the microphone if PTT state is Transmitting. Connects the readyRead signa...
Definition chat_view.cpp:602
void OnWavelengthClosed(const QString &frequency)
Handles the event when the host closes the current Wavelength. Updates the status indicator,...
Definition chat_view.cpp:250
QAudioOutput * audio_output_
Object managing audio output to the speakers.
Definition chat_view.h:275
TranslationManager * translator_
Pointer to the translation manager for handling UI translations.
Definition chat_view.h:287
void OnPttButtonPressed()
Slot called when the PTT button is pressed. Plays the PTT activation sound, sets the state to Request...
Definition chat_view.cpp:325
void UpdateProgressMessage(const QString &message_id, const QString &message) const
Slot to update a message in the message area, typically used for file transfer progress....
Definition chat_view.cpp:489
void AbortWavelength()
Initiates the process of leaving or closing the current Wavelength. Updates the status indicator,...
Definition chat_view.cpp:505
double GetScanlineOpacity() const
Gets the current opacity of the scanline effect.
Definition chat_view.h:65
QSoundEffect * ptt_on_sound_
Sound effect played when the PTT button is pressed.
Definition chat_view.h:283
double scanlineOpacity
Property controlling the opacity of the animated scanline effect (0.0 to 1.0). Animatable.
Definition chat_view.h:32
QString current_transmitter_id_
Stores the ID of the user currently transmitting audio (if receiving).
Definition chat_view.h:268
QPushButton * send_button_
Button to send the text message in the input field.
Definition chat_view.h:255
void TriggerVisualEffect()
Triggers a random, brief increase in the scanline effect opacity.
Definition chat_view.cpp:545
void StopAudioOutput()
Stops audio playback. Resets the output device pointer.
Definition chat_view.cpp:689
void SendMessage() const
Sends the text message currently in the input field. Clears the input field and sends the message via...
Definition chat_view.cpp:493
void TriggerActivityEffect()
Triggers a subtle scanline effect animation when there is activity (e.g., a message received).
Definition chat_view.cpp:564
void ResetStatusIndicator() const
Resets the status_indicator_ label to its default "CONNECTION ACTIVE" state and style.
Definition chat_view.cpp:763
void AttachFile()
Opens a file dialog to allow the user to select a file for sending. If a file is selected,...
Definition chat_view.cpp:284
void SetWavelength(const QString &frequency, const QString &name=QString())
Configures the view for a specific Wavelength. Sets the header title with the frequency and optional ...
Definition chat_view.cpp:201
void OnPttDenied(const QString &frequency, const QString &reason)
Slot called when the server denies the PTT request. If the frequency matches and the state is Request...
Definition chat_view.cpp:379
void SetScanlineOpacity(double opacity)
Sets the opacity of the scanline effect. Triggers a repaint of the widget.
Definition chat_view.cpp:196
void wavelengthAborted()
Emitted when the user aborts the connection or the Wavelength is closed by the host....
bool is_aborting_
Flag indicating if the view is in the process of aborting the connection (prevents duplicate actions)...
Definition chat_view.h:266
PttState
Enum representing the possible states of the Push-to-Talk (PTT) functionality.
Definition chat_view.h:37
@ Requesting
PTT button pressed, waiting for grant from the server.
Definition chat_view.h:39
@ Transmitting
PTT granted, microphone is active, sending audio data.
Definition chat_view.h:40
@ Idle
Not requesting, transmitting, or receiving PTT.
Definition chat_view.h:38
@ Receiving
Receiving audio data from another user.
Definition chat_view.h:41
void UpdatePttButtonState() const
Updates the appearance and enabled state of the PTT button based on the current ptt_state_....
Definition chat_view.cpp:724
QPushButton * ptt_button_
Button for Push-to-Talk functionality.
Definition chat_view.h:259
void TriggerConnectionEffect()
Triggers a more pronounced scanline effect animation when connecting to a Wavelength.
Definition chat_view.cpp:555
QPushButton * abort_button_
Button to disconnect from the current Wavelength.
Definition chat_view.h:257
void OnMessageReceived(const QString &frequency, const QString &message)
Handles displaying a received message for the current Wavelength. Adds the message to the message_are...
Definition chat_view.cpp:237
void OnAudioDataReceived(const QString &frequency, const QByteArray &audio_data) const
Slot called when binary audio data is received from the server. If the frequency matches and the stat...
Definition chat_view.cpp:422
~ChatView() override
Destructor. Stops audio input/output and cleans up audio resources.
Definition chat_view.cpp:189
QLabel * status_indicator_
Label indicating the connection status ("CONNECTION ACTIVE", "ABORTING", etc.).
Definition chat_view.h:247
PttState ptt_state_
Current state of the Push-to-Talk interaction.
Definition chat_view.h:271
QAudioFormat audio_format_
The audio format used for both input and output (PCM, 16 kHz, 16-bit mono).
Definition chat_view.h:281
double scanline_opacity_
Current opacity level for the scanline effect overlay.
Definition chat_view.h:264
qreal CalculateAmplitude(const QByteArray &buffer) const
Calculates the Root Mean Square (RMS) amplitude of a raw audio buffer. Used for audio visualization....
Definition chat_view.cpp:703
void OnPttStopReceiving(const QString &frequency)
Slot called when the remote user stops transmitting PTT. If the frequency matches and the state is Re...
Definition chat_view.cpp:410
QSoundEffect * ptt_off_sound_
Sound effect played when the PTT button is released.
Definition chat_view.h:285
void OnPttStartReceiving(const QString &frequency, const QString &sender_id)
Slot called when another user starts transmitting PTT on the current Wavelength. If the state is Idle...
Definition chat_view.cpp:394
QLineEdit * input_field_
Input field for typing text messages.
Definition chat_view.h:251
QIODevice * input_device_
I/O device providing access to the raw audio stream from audio_input_.
Definition chat_view.h:277
StreamDisplay * message_area_
Custom widget for displaying the stream of messages and audio visualization.
Definition chat_view.h:249
void StopAudioInput()
Stops capturing audio from the microphone. Disconnects signals and resets the input device pointer.
Definition chat_view.cpp:629
void Clear()
Clears the view and resets its state. Resets the current frequency, clears the message area,...
Definition chat_view.cpp:276
void OnPttButtonReleased()
Slot called when the PTT button is released. Plays the PTT deactivation sound. If transmitting,...
Definition chat_view.cpp:342
void InitializeAudio()
Initializes the audio format and creates QAudioInput/QAudioOutput objects. Determines supported forma...
Definition chat_view.cpp:573
ChatView(QWidget *parent=nullptr)
Constructs a WavelengthChatView. Initializes the UI elements (labels, message area,...
Definition chat_view.cpp:23
void paintEvent(QPaintEvent *event) override
Overridden paint event handler. Draws the custom cyberpunk border, AR markers, and scanline effect.
Definition chat_view.cpp:318
void OnMessageSent(const QString &frequency, const QString &message) const
Handles displaying a message sent by the local user on the current Wavelength. Adds the message to th...
Definition chat_view.cpp:245
void OnPttGranted(const QString &frequency)
Slot called when the server grants the PTT request. If the frequency matches and the state is Request...
Definition chat_view.cpp:363
QIODevice * output_device_
I/O device providing access to the raw audio stream for audio_output_.
Definition chat_view.h:279
QString current_frequency_
The frequency of the Wavelength currently displayed in this view. "-1.0" if inactive.
Definition chat_view.h:262
QLabel * header_label_
Label displaying the Wavelength frequency and name.
Definition chat_view.h:245
void StartAudioOutput()
Starts audio playback if PTT state is Receiving. Prepares the audio output device to receive data.
Definition chat_view.cpp:661
QAudioInput * audio_input_
Object managing audio input from the microphone.
Definition chat_view.h:273
QPushButton * attach_button_
Button to open the file attachment dialog.
Definition chat_view.h:253
A widget that manages and displays messages within a CommunicationStream.
Definition stream_display.h:21
Manages the loading and delivery of translations for applications.
Definition translation_manager.h:15