CCIMXDesktop
 
Loading...
Searching...
No Matches
ToastReceiver Class Reference

Receives toast notification data, often from external sources, and emits it for processing. More...

#include <ToastReceiver.h>

Inheritance diagram for ToastReceiver:

Signals

void postToast (const ToastMetaProtocol &protocolMeta)
 Signal emitted when a new toast notification is ready to be posted.
 

Public Member Functions

 ToastReceiver (FileMonitor *parent=nullptr)
 Constructs a ToastReceiver instance.
 
std::optional< ToastMetaProtocolfromExternalJsonString (const QString &json_file) const
 Parses a JSON string from an external source into a ToastMetaProtocol object.
 

Detailed Description

Receives toast notification data, often from external sources, and emits it for processing.

This class acts as a listener for toast notification data. It is typically connected to a FileMonitor to detect new toast-related files (e.g., JSON files) and then parses these files into ToastMetaProtocol objects. Once successfully parsed, it emits a signal to notify other components (like a ToastProxy or ToastPostServer) that a new toast is ready to be displayed.

Constructor & Destructor Documentation

◆ ToastReceiver()

ToastReceiver::ToastReceiver ( FileMonitor parent = nullptr)
explicit

Constructs a ToastReceiver instance.

Parameters
parentA pointer to the parent QObject, often a FileMonitor that this receiver will be associated with for detecting incoming toast data. Defaults to nullptr.

Member Function Documentation

◆ fromExternalJsonString()

std::optional< ToastMetaProtocol > ToastReceiver::fromExternalJsonString ( const QString &  json_file) const

Parses a JSON string from an external source into a ToastMetaProtocol object.

  • This method attempts to read and parse the content of a JSON file (specified by json_file) into a ToastMetaProtocol struct. It returns std::nullopt if the file cannot be read, is not valid JSON, or does not contain the expected toast metadata.
    Parameters
    json_fileThe path to the JSON file containing the toast metadata.
    Returns
    An std::optional<ToastMetaProtocol> containing the parsed toast data if successful, otherwise std::nullopt.

◆ postToast

void ToastReceiver::postToast ( const ToastMetaProtocol protocolMeta)
signal

Signal emitted when a new toast notification is ready to be posted.

  • This signal carries the parsed ToastMetaProtocol data and should be connected to a slot responsible for displaying the toast.
    Parameters
    protocolMetaA constant reference to the ToastMetaProtocol object containing the toast data.

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