Wavelength
Privacy-focused, cross-platform, and open-source communication application
Loading...
Searching...
No Matches
stream_display.h
Go to the documentation of this file.
1#ifndef WAVELENGTH_STREAM_DISPLAY_H
2#define WAVELENGTH_STREAM_DISPLAY_H
3
4#include <QMap>
5#include <QQueue>
6
7#include "stream_message.h"
8
10
21class StreamDisplay final : public QWidget {
22 Q_OBJECT
23
27 struct MessageData {
29 QString content;
31 QString sender;
33 QString id;
37 bool has_attachment = false;
38 };
39
40public:
47 explicit StreamDisplay(QWidget *parent = nullptr);
48
55 void SetFrequency(const QString &frequency, const QString &name = QString());
56
67 void AddMessage(const QString &message, const QString &message_id, StreamMessage::MessageType type);
68
69
75 void Clear();
76
77public slots:
82 void SetGlitchIntensity(qreal intensity) const;
83
88 void SetTransmittingUser(const QString &userId) const;
89
93 void ClearTransmittingUser() const;
94
99 void SetAudioAmplitude(qreal amplitude) const;
100
101private slots:
111
118 void OnStreamMessageDestroyed(const QObject *object);
119
120private:
124 QQueue<MessageData> message_queue_;
128 QMap<QString, StreamMessage *> displayed_progress_messages_;
129};
130
131#endif // WAVELENGTH_STREAM_DISPLAY_H
A custom OpenGL widget displaying an animated communication stream visualization.
Definition communication_stream.h:34
CommunicationStream * communication_stream_
The underlying widget that handles the visual rendering of the stream and messages.
Definition stream_display.h:122
QTimer * message_timer_
Timer controlling the delay between displaying queued messages.
Definition stream_display.h:126
void Clear()
Clears all messages from the display and the processing queue. Calls ClearMessages() on the Communica...
Definition stream_display.cpp:77
QQueue< MessageData > message_queue_
Queue holding messages waiting to be processed and displayed.
Definition stream_display.h:124
void OnStreamMessageDestroyed(const QObject *object)
Slot called when a StreamMessage associated with a progress ID is destroyed. Removes the correspondin...
Definition stream_display.cpp:148
StreamDisplay(QWidget *parent=nullptr)
Constructs a WavelengthStreamDisplay widget. Creates the main layout, instantiates the CommunicationS...
Definition stream_display.cpp:11
QMap< QString, StreamMessage * > displayed_progress_messages_
Map tracking currently displayed progress messages by their unique ID to allow updates.
Definition stream_display.h:128
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...
Definition stream_display.cpp:36
void ProcessNextQueuedMessage()
Processes the next message from the message_queue_. Dequeues a message, checks if it's an update to a...
Definition stream_display.cpp:100
void SetAudioAmplitude(qreal amplitude) const
Forwards the audio amplitude level to the CommunicationStream.
Definition stream_display.cpp:96
void SetTransmittingUser(const QString &userId) const
Forwards the transmitting user ID to the CommunicationStream.
Definition stream_display.cpp:88
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 Com...
Definition stream_display.cpp:27
void SetGlitchIntensity(qreal intensity) const
Sets the intensity of the glitch effect in the CommunicationStream.
Definition stream_display.cpp:84
void ClearTransmittingUser() const
Tells the CommunicationStream to clear the transmitting user display.
Definition stream_display.cpp:92
MessageType
Enum defining the type/origin of the message, affecting its styling.
Definition stream_message.h:39
Internal struct to hold data for messages waiting in the queue.
Definition stream_display.h:27
bool has_attachment
Flag indicating if the content likely contains an attachment placeholder.
Definition stream_display.h:37
QString content
The raw message content (potentially HTML).
Definition stream_display.h:29
StreamMessage::MessageType type
The type of the message (Received, Transmitted, System).
Definition stream_display.h:35
QString id
Unique identifier for the message (used for progress updates). Empty for regular messages.
Definition stream_display.h:33
QString sender
The sender identifier ("You", "SYSTEM", or extracted name).
Definition stream_display.h:31