|
Wavelength
Privacy-focused, cross-platform, and open-source communication application
|
A custom widget representing a single message within the CommunicationStream. More...
#include <stream_message.h>
Public Types | |
| enum | MessageType { kReceived , kTransmitted , kSystem } |
| Enum defining the type/origin of the message, affecting its styling. More... | |
Public Slots | |
| void | MarkAsRead () |
| Marks the message as read, triggers the appropriate closing animation (Electronic Shutdown or a simpler fade/glitch for long messages), and emits messageRead(). Prevents multiple calls. | |
Signals | |
| void | hidden () |
| Emitted when the message finishes its fade-out or closing animation and becomes hidden. | |
| void | messageRead () |
| Emitted when the message is marked as read (MarkAsRead() is called). | |
Public Member Functions | |
| void | AddAttachment (const QString &html) |
| Parses HTML content to find an attachment placeholder and adds the corresponding AttachmentPlaceholder widget. Extracts attachment details (ID, MIME type, filename) from the HTML attributes. Removes the old attachment widget if present. Adjusts message size constraints. Connects signals to handle attachment loading and size changes. | |
| void | AdjustSizeToContent () |
| Adjusts the size of the message widget to fit its content, especially after an attachment has loaded. Forces layout recalculation and calculates optimal size based on attachment dimensions, respecting screen boundaries. Updates geometry and parent layout. | |
| void | FadeIn () |
| Starts the fade-in animation (opacity and glow). Also triggers the text reveal animation (CyberTextDisplay) upon completion. Sets focus. | |
| void | FadeOut () |
| Starts the fade-out animation (opacity and glow). Hides the widget and emits the hidden() signal upon completion. | |
| QString | GetContent () const |
| Gets the original message content (may include HTML). | |
| qreal | GetGlowIntensity () const |
| Gets the current glow intensity level. | |
| QString | GetMessageId () const |
| Gets the unique message identifier (if provided). | |
| QString | GetMessageSender () const |
| Gets the sender identifier. | |
| QPushButton * | GetNextButton () const |
| Gets a pointer to the Next navigation button. | |
| qreal | GetOpacity () const |
| Gets the current opacity level. | |
| QPushButton * | GetPrevButton () const |
| Gets a pointer to the Previous navigation button. | |
| qreal | GetShutdownProgress () const |
| Gets the current electronic shutdown effect progress. | |
| MessageType | GetType () const |
| Gets the message type (Received, Transmitted, System). | |
| bool | IsRead () const |
| Checks if the message has been marked as read. | |
| void | SetGlowIntensity (qreal intensity) |
| Sets the glow intensity level and triggers a repaint. | |
| void | SetOpacity (qreal opacity) |
| Sets the opacity level and updates the QGraphicsOpacityEffect. | |
| void | SetShutdownProgress (qreal progress) |
| Sets the electronic shutdown effect progress and updates the ElectronicShutdownEffect. | |
| void | ShowNavigationButtons (bool has_previous, bool has_next) const |
| Shows or hides the navigation buttons (Next, Previous) and the Mark Read button. Updates the layout to position the buttons correctly. | |
| QSize | sizeHint () const override |
| Returns the recommended size for the widget based on its content (text length or attachment size). | |
| void | StartShutdownAnimation () |
| Starts the electronic shutdown closing animation. Applies the ElectronicShutdownEffect and animates its progress. Hides the widget and emits hidden() upon completion. | |
| StreamMessage (QString content, QString sender, MessageType type, QString message_id=QString(), QWidget *parent=nullptr) | |
| Constructs a StreamMessage widget. Initializes UI elements (layout, text display/label/scroll area), sets up effects and animations, cleans the content, and determines the display method based on content length and type. | |
| void | UpdateContent (const QString &new_content) |
| Updates the content of an existing message, typically used for progress updates. Cleans the new content, updates the appropriate display widget (CyberTextDisplay, CyberLongTextDisplay, or QLabel), and adjusts the widget size if necessary. | |
| void | UpdateScrollAreaMaxHeight () const |
| Updates the maximum height constraint for the scroll area used for long messages. Limits the height to a percentage of the available screen height. | |
Static Public Member Functions | |
| static QIcon | CreateColoredSvgIcon (const QString &svg_path, const QColor &color, const QSize &size) |
| Static utility function to create a QIcon from an SVG file, colored with the specified color. | |
Public Attributes | |
| QPushButton * | mark_read_button |
| Button used to mark the message as read and trigger the closing animation. | |
Protected Member Functions | |
| void | focusInEvent (QFocusEvent *event) override |
| Overridden focus in event handler. Slightly increases glow intensity for visual feedback. | |
| void | focusOutEvent (QFocusEvent *event) override |
| Overridden focus out event handler. Resets glow intensity. | |
| void | keyPressEvent (QKeyEvent *event) override |
| Overridden key press event handler. Handles Space/Enter to mark as read, and Left/Right arrows for navigation. | |
| void | paintEvent (QPaintEvent *event) override |
| Overridden paint event handler. Draws the custom cyberpunk message bubble appearance. Renders the clipped background, neon border, glow effect, decorative lines/markers, sender text, and other AR-style elements based on the message type. | |
| void | resizeEvent (QResizeEvent *event) override |
| Overridden resize event handler. Updates the layout of internal elements (buttons, scroll area). | |
Properties | |
| qreal | glowIntensity |
| Property controlling the intensity of the border glow effect (0.0 to 1.0+). Animatable. | |
| qreal | opacity |
| Property controlling the widget's overall opacity (0.0 to 1.0). Animatable. | |
| qreal | shutdownProgress |
| Property controlling the progress of the electronic shutdown effect (0.0 to 1.0). Animatable. | |
Private Slots | |
| void | AdjustScrollAreaStyle () const |
| Adjusts the stylesheet of the scroll area (scrollbar colors) based on the message type. | |
| void | UpdateAnimation () |
| Slot called by animation_timer_ to update subtle background animations (e.g., glow pulsing). | |
Private Member Functions | |
| void | CleanupContent () |
| Cleans the message content by removing HTML tags and placeholders, and decoding HTML entities. Updates the clean_content_ member variable. Applies specific formatting for long text. | |
| void | ProcessAudioAttachment (const QString &html) |
| Helper to process audio attachments (likely superseded by AddAttachment). | |
| void | ProcessGifAttachment (const QString &html) |
| Helper to process GIF attachments (likely superseded by AddAttachment). | |
| void | ProcessImageAttachment (const QString &html) |
| Helper to process image attachments (likely superseded by AddAttachment). | |
| void | ProcessVideoAttachment (const QString &html) |
| Helper to process video attachments (likely superseded by AddAttachment). | |
| void | StartLongMessageClosingAnimation () |
| Starts a simpler closing animation (glitch/fade) used specifically for long messages displayed in a scroll area. | |
| void | UpdateLayout () const |
| Updates the position of the navigation and mark read buttons based on the widget's current size. | |
Static Private Member Functions | |
| static QString | ExtractAttribute (const QString &html, const QString &attribute) |
| Static utility function to extract the value of an HTML attribute from a string. | |
Private Attributes | |
| QTimer * | animation_timer_ |
| Timer for subtle background animations. | |
| QWidget * | attachment_widget_ = nullptr |
| Widget holding the attachment placeholder/viewer. | |
| QString | clean_content_ |
| Processed message content (plain text). | |
| QString | content_ |
| Original message content (may contain HTML). | |
| QLabel * | content_label_ = nullptr |
| Label for displaying short text content (if no CyberTextDisplay). | |
| qreal | glow_intensity_ |
| Current glow intensity level (for animation). | |
| bool | is_read_ |
| Flag indicating if the message has been marked as read. | |
| LongTextDisplayEffect * | long_text_display_ = nullptr |
| Widget for displaying long text within scroll area. | |
| QVBoxLayout * | main_layout_ |
| Main vertical layout. | |
| QString | message_id_ |
| Unique identifier for the message (optional). | |
| QPushButton * | next_button_ |
| Button to navigate to the next message. | |
| qreal | opacity_ |
| Current opacity level (for animation). | |
| QPushButton * | prev_button_ |
| Button to navigate to the previous message. | |
| QScrollArea * | scroll_area_ = nullptr |
| Scroll area for long messages. | |
| QString | sender_ |
| Sender identifier. | |
| ElectronicShutdownEffect * | shutdown_effect_ = nullptr |
| Graphics effect for electronic shutdown animation. | |
| qreal | shutdown_progress_ |
| Current electronic shutdown progress. | |
| TextDisplayEffect * | text_display_ = nullptr |
| Widget for animated text reveal (short messages). | |
| MessageType | type_ |
| Message type (Received, Transmitted, System). | |
A custom widget representing a single message within the CommunicationStream.
This widget displays message content (text or attachment placeholder) with cyberpunk styling, including background, borders, glow effects, and AR-style markers. It handles different message types (Received, Transmitted, System) with distinct color schemes. It supports animations for fading in/out, disintegration, and electronic shutdown. For short messages, it uses CyberTextDisplay for a typing reveal effect. For long messages, it uses CyberLongTextDisplay within a QScrollArea. It also manages navigation buttons (Next/Previous) and a "Mark as Read" button.
|
explicit |
Constructs a StreamMessage widget. Initializes UI elements (layout, text display/label/scroll area), sets up effects and animations, cleans the content, and determines the display method based on content length and type.
| content | The message content (can be plain text or HTML with attachment placeholders). |
| sender | The identifier of the message sender ("SYSTEM" for system messages). |
| type | The type of the message (Received, Transmitted, System). |
| message_id | Optional unique identifier, used for progress updates. |
| parent | Optional parent widget. |
| void StreamMessage::AddAttachment | ( | const QString & | html | ) |
Parses HTML content to find an attachment placeholder and adds the corresponding AttachmentPlaceholder widget. Extracts attachment details (ID, MIME type, filename) from the HTML attributes. Removes the old attachment widget if present. Adjusts message size constraints. Connects signals to handle attachment loading and size changes.
| html | The HTML string containing the attachment placeholder div. |
|
privateslot |
Adjusts the stylesheet of the scroll area (scrollbar colors) based on the message type.
| void StreamMessage::AdjustSizeToContent | ( | ) |
Adjusts the size of the message widget to fit its content, especially after an attachment has loaded. Forces layout recalculation and calculates optimal size based on attachment dimensions, respecting screen boundaries. Updates geometry and parent layout.
|
private |
Cleans the message content by removing HTML tags and placeholders, and decoding HTML entities. Updates the clean_content_ member variable. Applies specific formatting for long text.
|
static |
Static utility function to create a QIcon from an SVG file, colored with the specified color.
| svg_path | Path to the SVG file. |
| color | The desired color for the icon. |
| size | The desired size of the output icon pixmap. |
|
staticprivate |
Static utility function to extract the value of an HTML attribute from a string.
| html | The HTML string. |
| attribute | The name of the attribute to extract (e.g., "data-attachment-id"). |
| void StreamMessage::FadeIn | ( | ) |
Starts the fade-in animation (opacity and glow). Also triggers the text reveal animation (CyberTextDisplay) upon completion. Sets focus.
| void StreamMessage::FadeOut | ( | ) |
Starts the fade-out animation (opacity and glow). Hides the widget and emits the hidden() signal upon completion.
|
overrideprotected |
Overridden focus in event handler. Slightly increases glow intensity for visual feedback.
| event | The focus event. |
|
overrideprotected |
Overridden focus out event handler. Resets glow intensity.
| event | The focus event. |
|
inline |
Gets the original message content (may include HTML).
|
inline |
Gets the current glow intensity level.
|
inline |
Gets the unique message identifier (if provided).
|
inline |
Gets the sender identifier.
|
inline |
Gets a pointer to the Next navigation button.
|
inline |
Gets the current opacity level.
|
inline |
Gets a pointer to the Previous navigation button.
|
inline |
Gets the current electronic shutdown effect progress.
|
inline |
Gets the message type (Received, Transmitted, System).
|
signal |
Emitted when the message finishes its fade-out or closing animation and becomes hidden.
|
inline |
Checks if the message has been marked as read.
|
overrideprotected |
Overridden key press event handler. Handles Space/Enter to mark as read, and Left/Right arrows for navigation.
| event | The key event. |
|
slot |
Marks the message as read, triggers the appropriate closing animation (Electronic Shutdown or a simpler fade/glitch for long messages), and emits messageRead(). Prevents multiple calls.
|
signal |
Emitted when the message is marked as read (MarkAsRead() is called).
|
overrideprotected |
Overridden paint event handler. Draws the custom cyberpunk message bubble appearance. Renders the clipped background, neon border, glow effect, decorative lines/markers, sender text, and other AR-style elements based on the message type.
| event | The paint event. |
|
private |
Helper to process audio attachments (likely superseded by AddAttachment).
|
private |
Helper to process GIF attachments (likely superseded by AddAttachment).
|
private |
Helper to process image attachments (likely superseded by AddAttachment).
|
private |
Helper to process video attachments (likely superseded by AddAttachment).
|
overrideprotected |
Overridden resize event handler. Updates the layout of internal elements (buttons, scroll area).
| event | The resize event. |
| void StreamMessage::SetGlowIntensity | ( | qreal | intensity | ) |
Sets the glow intensity level and triggers a repaint.
| void StreamMessage::SetOpacity | ( | qreal | opacity | ) |
Sets the opacity level and updates the QGraphicsOpacityEffect.
| void StreamMessage::SetShutdownProgress | ( | qreal | progress | ) |
Sets the electronic shutdown effect progress and updates the ElectronicShutdownEffect.
| void StreamMessage::ShowNavigationButtons | ( | bool | has_previous, |
| bool | has_next ) const |
Shows or hides the navigation buttons (Next, Previous) and the Mark Read button. Updates the layout to position the buttons correctly.
| has_previous | True to show the Previous button. |
| has_next | True to show the Next button. |
|
override |
Returns the recommended size for the widget based on its content (text length or attachment size).
|
private |
Starts a simpler closing animation (glitch/fade) used specifically for long messages displayed in a scroll area.
| void StreamMessage::StartShutdownAnimation | ( | ) |
Starts the electronic shutdown closing animation. Applies the ElectronicShutdownEffect and animates its progress. Hides the widget and emits hidden() upon completion.
|
privateslot |
Slot called by animation_timer_ to update subtle background animations (e.g., glow pulsing).
| void StreamMessage::UpdateContent | ( | const QString & | new_content | ) |
Updates the content of an existing message, typically used for progress updates. Cleans the new content, updates the appropriate display widget (CyberTextDisplay, CyberLongTextDisplay, or QLabel), and adjusts the widget size if necessary.
| new_content | The updated message content. |
|
private |
Updates the position of the navigation and mark read buttons based on the widget's current size.
| void StreamMessage::UpdateScrollAreaMaxHeight | ( | ) | const |
Updates the maximum height constraint for the scroll area used for long messages. Limits the height to a percentage of the available screen height.
|
private |
Timer for subtle background animations.
|
private |
Widget holding the attachment placeholder/viewer.
|
private |
Processed message content (plain text).
|
private |
Original message content (may contain HTML).
|
private |
Label for displaying short text content (if no CyberTextDisplay).
|
private |
Current glow intensity level (for animation).
|
private |
Flag indicating if the message has been marked as read.
|
private |
Widget for displaying long text within scroll area.
|
private |
Main vertical layout.
| QPushButton* StreamMessage::mark_read_button |
Button used to mark the message as read and trigger the closing animation.
|
private |
Unique identifier for the message (optional).
|
private |
Button to navigate to the next message.
|
private |
Current opacity level (for animation).
|
private |
Button to navigate to the previous message.
|
private |
Scroll area for long messages.
|
private |
Sender identifier.
|
private |
Graphics effect for electronic shutdown animation.
|
private |
Current electronic shutdown progress.
|
private |
Widget for animated text reveal (short messages).
|
private |
Message type (Received, Transmitted, System).
|
readwrite |
Property controlling the intensity of the border glow effect (0.0 to 1.0+). Animatable.
|
readwrite |
Property controlling the widget's overall opacity (0.0 to 1.0). Animatable.
|
readwrite |
Property controlling the progress of the electronic shutdown effect (0.0 to 1.0). Animatable.