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

A widget that manages and displays messages within a CommunicationStream. More...

#include <stream_display.h>

Inheritance diagram for StreamDisplay:
Collaboration diagram for StreamDisplay:

Classes

struct  MessageData
 Internal struct to hold data for messages waiting in the queue. More...
 

Public Slots

void ClearTransmittingUser () const
 Tells the CommunicationStream to clear the transmitting user display.
 
void SetAudioAmplitude (qreal amplitude) const
 Forwards the audio amplitude level to the CommunicationStream.
 
void SetGlitchIntensity (qreal intensity) const
 Sets the intensity of the glitch effect in the CommunicationStream.
 
void SetTransmittingUser (const QString &userId) const
 Forwards the transmitting user ID to the CommunicationStream.
 

Public Member Functions

void AddMessage (const QString &message, const QString &message_id, StreamMessage::MessageType type)
 Adds a new message to the display queue or updates an existing progress message. If the message_id is provided and corresponds to a currently displayed progress message, the content of that message is updated. Otherwise, a new MessageData entry is created (extracting sender, checking for attachments) and added to the processing queue. Starts the processing timer if the queue was empty.
 
void Clear ()
 Clears all messages from the display and the processing queue. Calls ClearMessages() on the CommunicationStream, clears the internal queue and map, and stops the message processing timer.
 
void SetFrequency (const QString &frequency, const QString &name=QString())
 Sets the frequency identifier and optional name for the stream. Updates the name displayed in the CommunicationStream and clears any existing messages.
 
 StreamDisplay (QWidget *parent=nullptr)
 Constructs a WavelengthStreamDisplay widget. Creates the main layout, instantiates the CommunicationStream, initializes the message queue, progress message map, and the message processing timer.
 

Private Slots

void OnStreamMessageDestroyed (const QObject *object)
 Slot called when a StreamMessage associated with a progress ID is destroyed. Removes the corresponding entry from the displayed_progress_messages_ map to prevent dangling pointers and incorrect update attempts.
 
void ProcessNextQueuedMessage ()
 Processes the next message from the message_queue_. Dequeues a message, checks if it's an update to an existing progress message. If not, calls the appropriate AddMessage method on CommunicationStream. If it's a progress message, adds the returned StreamMessage pointer to the displayed_progress_messages_ map and connects its destroyed() signal. Restarts the timer with a random delay if the queue is not empty.
 

Private Attributes

CommunicationStreamcommunication_stream_
 The underlying widget that handles the visual rendering of the stream and messages.
 
QMap< QString, StreamMessage * > displayed_progress_messages_
 Map tracking currently displayed progress messages by their unique ID to allow updates.
 
QQueue< MessageDatamessage_queue_
 Queue holding messages waiting to be processed and displayed.
 
QTimer * message_timer_
 Timer controlling the delay between displaying queued messages.
 

Detailed Description

A widget that manages and displays messages within a CommunicationStream.

This class acts as a controller for the CommunicationStream widget. It receives messages via the AddMessage slot, queues them, and processes them sequentially with a delay to create a staggered display effect. It handles updating existing progress messages based on their unique ID and manages the lifecycle of displayed messages. It also provides slots to forward control signals (like audio amplitude and transmitting user) to the underlying CommunicationStream.

Constructor & Destructor Documentation

◆ StreamDisplay()

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

Constructs a WavelengthStreamDisplay widget. Creates the main layout, instantiates the CommunicationStream, initializes the message queue, progress message map, and the message processing timer.

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

Member Function Documentation

◆ AddMessage()

void StreamDisplay::AddMessage ( const QString & message,
const QString & message_id,
StreamMessage::MessageType type )

Adds a new message to the display queue or updates an existing progress message. If the message_id is provided and corresponds to a currently displayed progress message, the content of that message is updated. Otherwise, a new MessageData entry is created (extracting sender, checking for attachments) and added to the processing queue. Starts the processing timer if the queue was empty.

Parameters
messageThe message content (potentially HTML).
message_idA unique identifier for progress messages, empty otherwise.
typeThe type of the message (Received, Transmitted, System).

◆ Clear()

void StreamDisplay::Clear ( )

Clears all messages from the display and the processing queue. Calls ClearMessages() on the CommunicationStream, clears the internal queue and map, and stops the message processing timer.

Here is the caller graph for this function:

◆ ClearTransmittingUser

void StreamDisplay::ClearTransmittingUser ( ) const
slot

Tells the CommunicationStream to clear the transmitting user display.

◆ OnStreamMessageDestroyed

void StreamDisplay::OnStreamMessageDestroyed ( const QObject * object)
privateslot

Slot called when a StreamMessage associated with a progress ID is destroyed. Removes the corresponding entry from the displayed_progress_messages_ map to prevent dangling pointers and incorrect update attempts.

Parameters
objectPointer to the QObject that was destroyed (the StreamMessage).
Here is the caller graph for this function:

◆ ProcessNextQueuedMessage

void StreamDisplay::ProcessNextQueuedMessage ( )
privateslot

Processes the next message from the message_queue_. Dequeues a message, checks if it's an update to an existing progress message. If not, calls the appropriate AddMessage method on CommunicationStream. If it's a progress message, adds the returned StreamMessage pointer to the displayed_progress_messages_ map and connects its destroyed() signal. Restarts the timer with a random delay if the queue is not empty.

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

◆ SetAudioAmplitude

void StreamDisplay::SetAudioAmplitude ( qreal amplitude) const
slot

Forwards the audio amplitude level to the CommunicationStream.

Parameters
amplitudeThe current audio amplitude level.

◆ SetFrequency()

void StreamDisplay::SetFrequency ( const QString & frequency,
const QString & name = QString() )

Sets the frequency identifier and optional name for the stream. Updates the name displayed in the CommunicationStream and clears any existing messages.

Parameters
frequencyThe frequency identifier (e.g., "100.0").
nameOptional display name for the frequency.
Here is the call graph for this function:

◆ SetGlitchIntensity

void StreamDisplay::SetGlitchIntensity ( qreal intensity) const
slot

Sets the intensity of the glitch effect in the CommunicationStream.

Parameters
intensityThe desired glitch intensity level.

◆ SetTransmittingUser

void StreamDisplay::SetTransmittingUser ( const QString & userId) const
slot

Forwards the transmitting user ID to the CommunicationStream.

Parameters
userIdThe identifier of the user currently transmitting audio.

Member Data Documentation

◆ communication_stream_

CommunicationStream* StreamDisplay::communication_stream_
private

The underlying widget that handles the visual rendering of the stream and messages.

◆ displayed_progress_messages_

QMap<QString, StreamMessage *> StreamDisplay::displayed_progress_messages_
private

Map tracking currently displayed progress messages by their unique ID to allow updates.

◆ message_queue_

QQueue<MessageData> StreamDisplay::message_queue_
private

Queue holding messages waiting to be processed and displayed.

◆ message_timer_

QTimer* StreamDisplay::message_timer_
private

Timer controlling the delay between displaying queued messages.


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