|
VR-Engage
2.2
|
DtVreChatQML provides the bridge between the C++ chat functionality and the QML-based UI. It exposes properties and methods that can be accessed from QML to display chat messages, manage channels, and send/receive communications. This class handles the business logic of the chat system, including message formatting, channel management, and command processing.
#include <vreChatWindow.h>
Public Slots | |
| void | setCurrentUsername (QString username) |
| void | setChat (DtVreChatModel *model) |
Signals | |
| void | currentUsernameChanged (QString username) |
| void | currentChannelIdxChanged (int channelIdx) |
| void | chatChanged () |
| void | pinChatChanged (bool pinned) |
Public Member Functions | |
| DtVreChatQML (DtPlayerStationApp &app, QObject *parent=nullptr) | |
| virtual | ~DtVreChatQML () override |
| virtual void | sendToSystemChannel (const std::string &message) |
| virtual bool | addChannel (const makVre::ChannelInfo &channelInfo, bool updateAvailableChannels=false) |
| virtual void | updateAvailableChannels () |
| virtual void | clearChannels () |
| virtual bool | isChannelActive (const QString &channelName, int force) |
| virtual const std::vector< ChannelInfo > & | getChannels () const |
| virtual void | switchToFirstAvailableChannel () |
| virtual void | setUsingCustomUsername (bool usingCustom) |
| virtual bool | isUsingCustomUsername () const |
| virtual QString | entityMarkingText () const |
| virtual void | setEntityMarkingText (QString val) |
| virtual int | entityForce () const |
| virtual void | setEntityForce (int val) |
| QString | entityRole () const |
| void | setEntityRole (QString val) |
| virtual void | updateUsername () |
| virtual void | sendSlashCommand (const QString &message) |
| virtual void | sendChatMessage (const QString &message, const QString &channel, const int force) |
| virtual bool | sendChannelCommand (const QString &channelCommand) |
| virtual Q_INVOKABLE void | send (const QString &message) |
| virtual Q_INVOKABLE void | cycleChannels (bool direction) |
| virtual Q_INVOKABLE QVariant | getChannelInfo (int idx) |
| virtual Q_INVOKABLE void | togglePinChat () |
| virtual QString | getCurrentUsername () |
| virtual DtVreChatModel * | getChat () |
Static Public Member Functions | |
| static std::string | convertTextToHTML (const std::string &inputText) |
Protected Attributes | |
| QString | myCurrentUsername |
| bool | myUsingCustomUsername |
| QString | myEntityMarkingText |
| QString | myEntityRole |
| int | myEntityForce |
| DtFilename | myCurrentChatConfigFile |
| DtFilename | myDefaultChatConfigFile |
| std::vector< ChannelInfo > | myChannels |
| int | myCurrentChannelIdx |
| bool | myPinChat |
| QScopedPointer< DtVreChatModel > | myChatModel |
| DtPlayerStationApp & | myApp |
Properties | |
| int | currentChannelIdx |
| bool | pinChat |
| QString | currentUsername |
| DtVreChatModel * | chatModel |
|
explicit |
Constructor.
| app | Reference to the player station application |
| parent | Parent QObject (default: nullptr) |
Creates a new chat QML interface associated with the specified application. The interface will be initialized with default settings and an empty chat model.
|
overridevirtual |
Virtual destructor.
Ensures proper cleanup of chat resources.
|
virtual |
Sends a message to the system channel.
| message | Text message to send to the system channel |
Sends a text message to the system notification channel, which is typically used for system events, errors, and information messages. These messages are visible to all users regardless of their channel settings.
|
static |
Converts plain text to HTML format for QML display.
| inputText | Plain text to convert |
Converts a plain text string to HTML format, handling special characters, links, and other formatting needed for proper display in QML text components.
|
virtual |
Adds a channel to the available channels list.
| channelInfo | Information about the channel to add |
| updateAvailableChannels | Whether to update the UI after adding the channel |
Adds a new communication channel to the chat system. If a channel with the same name and force already exists, it will be updated instead.
References updateAvailableChannels().
|
virtual |
Updates the list of available channels in the UI.
Refreshes the available channels list in the QML interface to reflect current channel state and availability.
Referenced by addChannel().
|
virtual |
Removes all channels from the chat system.
Clears all channels from the chat system, typically used when disconnecting from a session or changing scenarios.
|
virtual |
Checks if a channel is currently active.
| channelName | Name of the channel to check |
| force | Force identifier of the channel |
|
inlinevirtual |
Gets the list of all available channels.
References myChannels.
|
virtual |
Switches to the first available channel.
Selects the first available channel as the active channel. Used when initializing the chat or when the current channel becomes unavailable.
|
inlinevirtual |
Sets whether to use a custom username instead of entity name.
| usingCustom | True to use custom username, false to use entity name |
Controls whether the chat system uses a custom username specified by the user or automatically generates a username based on the entity information.
References myUsingCustomUsername.
|
inlinevirtual |
Checks if a custom username is being used.
References myUsingCustomUsername.
|
inlinevirtual |
Gets the entity marking text for username generation.
References myEntityMarkingText.
|
inlinevirtual |
Sets the entity marking text for username generation.
| val | New entity marking (call sign) text |
References myEntityMarkingText.
|
inlinevirtual |
Gets the entity force identifier for username generation.
References myEntityForce.
|
inlinevirtual |
Sets the entity force identifier for username generation.
| val | New entity force identifier |
References myEntityForce.
|
inline |
Gets the entity role text for username generation.
References myEntityRole.
|
inline |
Sets the entity role text for username generation.
| val | New entity role description |
References myEntityRole.
|
virtual |
Updates the username based on current settings.
Regenerates the username based on the current settings (custom or auto-generated). Auto-generated usernames typically combine entity marking, force, and role.
|
virtual |
Processes a slash command.
| message | Command message starting with a slash (/) |
Handles special commands that begin with a slash character, such as /help, /clear, /who, etc. This method is called from the send() method when a message begins with a slash.
|
virtual |
Sends a regular chat message to a specific channel.
| message | Text message to send |
| channel | Target channel name |
| force | Force identifier for the channel |
Sends a chat message to the specified channel. This method is called from the send() method for regular (non-command) messages.
|
virtual |
Processes a channel switching command.
| channelCommand | Command to switch channels (typically channel name) |
Handles commands to switch between communication channels. This can be called directly or from a slash command like /channel [name].
|
virtual |
Processes and sends a message or command.
| message | Text message or command to process |
Main entry point for processing messages entered by the user. This method determines whether the message is a command (starts with slash) or a regular message, and routes it to the appropriate handler. This method is invokable from QML.
|
virtual |
Cycles through available channels.
| direction | True to cycle forward, false to cycle backward |
Switches to the next or previous channel in the channel list based on the direction parameter. This method is invokable from QML.
|
virtual |
Gets information about a specific channel.
| idx | Index of the channel to retrieve information for |
Retrieves detailed information about a channel at the specified index. The returned QVariant can be used in QML to display channel properties. This method is invokable from QML.
|
virtual |
Toggles the pinned state of the chat window.
Switches between pinned (always visible) and unpinned (auto-hide) states for the chat window. This method is invokable from QML.
|
virtual |
Gets the current username.
|
virtual |
Gets the chat message model.
|
slot |
Sets the current username.
| username | New username to use in chat |
|
slot |
Sets the chat message model.
| model | New chat model to use |
|
signal |
Signal emitted when the username changes.
| username | New username |
|
signal |
Signal emitted when the active channel changes.
| channelIdx | Index of the new active channel |
|
signal |
Signal emitted when the chat model changes.
|
signal |
Signal emitted when the pinned state changes.
| pinned | New pinned state |
|
protected |
|
protected |
Referenced by isUsingCustomUsername(), and setUsingCustomUsername().
|
protected |
Referenced by entityMarkingText(), and setEntityMarkingText().
|
protected |
Referenced by entityRole(), and setEntityRole().
|
protected |
Referenced by entityForce(), and setEntityForce().
|
protected |
|
protected |
|
protected |
Referenced by getChannels().
|
protected |
|
protected |
|
protected |
|
protected |
| int makVre::DtVreChatQML::currentChannelIdx |
Index of the currently active chat channel.
| bool makVre::DtVreChatQML::pinChat |
Flag indicating if the chat window is pinned (always visible)
|
readwrite |
Current username for the chat system.
|
readwrite |
Model containing chat messages for display.