VR-Engage  2.3
Loading...
Searching...
No Matches
vreChatWindow.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file vreChatWindow.h
7//! \brief Defines the chat window component for in-application communication
8//!
9//! This file contains the classes that implement the chat functionality in VR-Engage,
10//! including the chat window UI, message handling, channel management, and text
11//! formatting. The chat system allows users to communicate with other participants
12//! in a simulation session through configurable channels.
13
14#pragma once
15
20
21#include <string>
22#include <vector>
23
24#include <QObject>
25
26class QQuickItem;
27
28namespace makVre
29{
31
32//! \brief Main chat window manager for VR-Engage
33//!
34//! DtVreChatWindow manages the chat window user interface in VR-Engage,
35//! including its visibility, position, and content. It serves as the primary
36//! interface between the application and the chat functionality, coordinating
37//! message handling, configuration loading, and UI state management. This class
38//! uses the DtVreChatQML class to bridge between C++ and the QML-based UI.
40{
41 Q_OBJECT;
42
43public:
44 //! \brief Constructor
45 //! \param app Reference to the player station application
46 //!
47 //! Creates a new chat window manager associated with the specified application.
48 //! The constructor initializes the chat UI and establishes necessary connections
49 //! to the message system for handling chat-related messages.
51
52 //! \brief Virtual destructor
53 //!
54 //! Ensures proper cleanup of chat window resources.
55 virtual ~DtVreChatWindow() override;
56
57 //! \brief Sets the visibility of the chat window
58 //! \param visible True to show the window, false to hide it
59 //!
60 //! Controls the visibility of the entire chat window. This affects the
61 //! root object of the chat UI, not individual components within it.
62 virtual void setVisibility(bool visible);
63
64 //! \brief Checks if the chat window is currently visible
65 //! \return True if the chat window is visible, false otherwise
66 virtual bool isVisible() const override;
67
68 //! \brief Checks if the full chat window is visible
69 //! \return True if the full chat window is visible, false if minimized or hidden
70 //!
71 //! Determines if the chat window is fully visible, as opposed to being
72 //! minimized or showing only a notification area.
73 virtual bool isFullChatVisible() const override;
74
75 //! \brief Closes the chat window
76 //!
77 //! Hides the chat window and performs any necessary cleanup.
78 virtual void close() override;
79
80 //! \brief Opens the chat window
81 //!
82 //! Shows the chat window and ensures it's properly initialized.
83 virtual void open() override;
84
85 //! \brief Opens the chat window or gives it focus if already open
86 //!
87 //! If the chat window is already open, this gives it focus. Otherwise,
88 //! it opens the window. This is typically used when the user invokes
89 //! the chat functionality through a hotkey or menu option.
90 virtual void openOrFocus() override;
91
92 //! \brief Toggles the pinned state of the chat window
93 //!
94 //! Switches between pinned (always visible) and unpinned (auto-hide) states
95 //! for the chat window. This affects how the chat behaves when the user
96 //! interacts with other parts of the application.
97 virtual void togglePinChat() override;
98
99 // DtChatWindowInterface implementations that delegate to myChatObject
100 virtual void send(const std::string& message) override;
101 virtual void sendChatMessage(const std::string& message,
102 const std::string& channel, int force) override;
103 virtual void sendToSystemChannel(const std::string& message) override;
104 virtual bool isChannelActive(const std::string& channelName, int force) const override;
105 virtual bool addChannel(const std::string& channelName, int force,
106 bool active, const std::vector<std::string>& entities) override;
107 virtual void updateAvailableChannels() override;
108 virtual void clearChannels() override;
109 virtual void setEntityMarkingText(const std::string& text) override;
110 virtual void setEntityForce(int force) override;
111 virtual void setEntityRole(const std::string& role) override;
112 virtual void updateUsername() override;
113 virtual void displayReceivedMessage(const std::string& username, int force,
114 const std::string& channel, const std::string& message) override;
115
116 //! \brief Gets the chat QML object
117 //! \return Pointer to the chat QML interface, or nullptr if not available
118 //!
119 //! Provides access to the underlying DtVreChatQML object that manages
120 //! the chat functionality. The caller does not take ownership of the
121 //! returned pointer and should not delete it.
123
124 //! \brief Updates the chat window position based on application state
125 //! \param state Current application state identifier
126 //!
127 //! Adjusts the position of the chat window based on the current state
128 //! of the application. Different states may require different positioning
129 //! to avoid interfering with other UI elements.
130 virtual void updatePositionFromState(const std::string& state) override;
131
132 //! \brief Checks if the chat window is allowed to be shown
133 //!
134 //! Indicates whether the chat window has permission to be displayed. This is
135 //! separate from whether it is currently visible. The chat may be allowed but
136 //! not currently shown, or may be disallowed entirely.
137 //!
138 //! \return True if the chat window is allowed to be shown, false otherwise
139 virtual bool isShowingAllowed() const override { return myCanShowChatWindow; }
140
141 //! \brief Sets whether the chat window is allowed to be shown
142 //!
143 //! Controls whether the chat window has permission to be displayed. When set to
144 //! false, the chat window cannot be opened regardless of user actions. This does
145 //! not affect the current visibility state directly.
146 //!
147 //! \param canShow True to allow the chat window to be shown, false to disallow
148 virtual void setShowingAllowed(const bool canShow) override { myCanShowChatWindow = canShow; }
149
150protected:
151 //! \brief Chat QML interface object
152 //!
153 //! Manages the bridge between C++ and QML for chat functionality.
154 std::unique_ptr<DtVreChatQML> myChatObject;
155
156 //! \brief Root QML item for the chat window
157 //!
158 //! The top-level QML item that contains the entire chat window UI.
159 QQuickItem* myRoot;
160
161 //! \brief Reference to the player station application
162 //!
163 //! Provides access to application services during chat operations.
165
166 //! \brief Whether the chat window can be shown
167 //!
168 //! Stores whether the chat window is permitted to be displayed. This is used to
169 //! control chat window availability based on player station state transitions.
170 //!
171 //! Default value is false.
172 //! \see isShowingAllowed()
173 //! \see setShowingAllowed()
175
176};
177
178} // namespace makVre
Pure abstract interface for the chat window component.
Definition vreChatWindowInterface.h:28
Top-level class representing the VR-Engage application.
Definition playerStationApp.h:155
QML interface for the VR-Engage chat system.
Definition vreChatQML.h:84
virtual void setEntityRole(const std::string &role) override
Sets the entity role used for username generation.
DtVreChatWindow(DtPlayerStationApp &app)
Constructor.
virtual bool addChannel(const std::string &channelName, int force, bool active, const std::vector< std::string > &entities) override
Adds a channel to the available channels list.
virtual void send(const std::string &message) override
Sends a message or slash command to the chat system.
virtual void setShowingAllowed(const bool canShow) override
Sets whether the chat window is allowed to be shown.
Definition vreChatWindow.h:148
virtual void sendChatMessage(const std::string &message, const std::string &channel, int force) override
Sends a chat message to a specific channel.
DtVreChatQML * getChatObject()
Gets the chat QML object.
bool myCanShowChatWindow
Whether the chat window can be shown.
Definition vreChatWindow.h:174
virtual void togglePinChat() override
Toggles the pinned state of the chat window.
virtual void close() override
Closes the chat window.
virtual void openOrFocus() override
Opens the chat window or gives it focus if already open.
virtual void setEntityMarkingText(const std::string &text) override
Sets the entity marking text used for username generation.
std::unique_ptr< DtVreChatQML > myChatObject
Chat QML interface object.
Definition vreChatWindow.h:154
virtual void setEntityForce(int force) override
Sets the entity force identifier used for channel filtering.
virtual void updateUsername() override
Regenerates the displayed username from current settings.
virtual void updateAvailableChannels() override
Refreshes the active-channel list based on current entity state.
QQuickItem * myRoot
Root QML item for the chat window.
Definition vreChatWindow.h:159
virtual void open() override
Opens the chat window.
DtPlayerStationApp & myApp
Reference to the player station application.
Definition vreChatWindow.h:164
virtual bool isVisible() const override
Checks if the chat window is currently visible.
virtual bool isShowingAllowed() const override
Checks if the chat window is allowed to be shown.
Definition vreChatWindow.h:139
virtual void setVisibility(bool visible)
Sets the visibility of the chat window.
virtual ~DtVreChatWindow() override
Virtual destructor.
virtual bool isChannelActive(const std::string &channelName, int force) const override
Checks whether a channel is currently active.
virtual void clearChannels() override
Removes all channels from the chat system.
virtual bool isFullChatVisible() const override
Checks if the full chat window is visible.
virtual void sendToSystemChannel(const std::string &message) override
Sends a message to the system (notification) channel.
virtual void updatePositionFromState(const std::string &state) override
Updates the chat window position based on application state.
virtual void displayReceivedMessage(const std::string &username, int force, const std::string &channel, const std::string &message) override
Displays an incoming chat message received over the network.
Defines export macros for the VR-Engage Player Station library.
#define PLAYERSTATION_DLL
Definition export.h:24
!
Definition glsVreMessageUtil.h:50
Defines ChannelInfo and DtVreChatQML, the QML interface for the VR-Engage chat system.
Declares the DtChatWindowInterface pure abstract interface.
Defines the data model for the chat window in VR-Engage.