VR-Engage  2.3
Loading...
Searching...
No Matches
vreBaseUI.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file vreBaseUI.h
7//! \brief Defines the thin base class for VR-Engage QML page components
8//!
9//! DtVreBaseUI provides a minimal foundation for QML-backed UI pages.
10//! It handles QML file loading, root item management, visibility control,
11//! main-content visibility, and connection-page navigation (back/escape).
12//! Header and footer ownership lives in the shared DtVreHeaderFooterUI class;
13//! pages access it through headerFooterUI().
14
15#pragma once
16
20
21#include <QObject>
22
23class QQuickItem;
24
25namespace makVre
26{
29
30//! \brief Thin base class for VR-Engage QML UI pages
31//!
32//! Loads a QML file, stores the root item, and provides visibility,
33//! main-content visibility, and connection-page back-navigation.
34//! Derived classes implement initMain() for page-specific setup and
35//! tick() for per-frame updates. Access the shared header/footer
36//! through headerFooterUI().
37class PLAYERSTATION_DLL DtVreBaseUI : public QObject
38{
39 Q_OBJECT
40
41public:
42 //! \brief Constructor
43 //! \param app Reference to the player station application
44 //! \param file Path to the QML file defining the UI (relative to UI root)
45 //! \param target_window Name of the target window (empty for default)
46 //!
47 //! Loads the specified QML file asynchronously. When loading completes,
48 //! the callback sets myRoot, calls initMain(), connects to the shared
49 //! header/footer, and hides the page.
50 DtVreBaseUI(DtPlayerStationApp& app, const std::string& file, const std::string& target_window = "");
51
52 //! \brief Virtual destructor
53 virtual ~DtVreBaseUI() override;
54
55 //! \brief Initializes page-specific QML elements
56 //!
57 //! Called once from the QML load callback after myRoot is set.
58 //! Derived classes set up QML context properties, signal connections,
59 //! and initial element state here.
60 virtual void initMain() = 0;
61
62 //! \brief Per-frame update
63 //! \param dt Seconds since the last frame
64 virtual void tick(double dt) = 0;
65
66 //! \brief Visibility control
67 //! @{
68
69 //! \brief Sets the visibility of this page
70 //! \param visible True to show, false to hide
71 //!
72 //! Toggles the root QML item visibility, enabled state, and focus.
73 virtual void setVisibility(bool visible);
74
75 //! \brief Checks whether this page is visible
76 //! \return True if the root QML item is visible
77 virtual bool isVisible();
78
79 //! \brief Hides the page
80 virtual void close();
81
82 //! \brief Shows the page
83 virtual void open();
84 //! @}
85
86 //! \brief Main content visibility
87 //! @{
88 virtual bool isMainContentVisible();
89 virtual void setMainContentVisibility(bool visible);
90 //! @}
91
92 //! \brief Connection-page back-navigation handlers
93 //! @{
94
95 //! \brief Handles back-button messages while the connection page is open
96 //! \param msg The UIBackButtonClickedMessage
97 //! \return EATEN if the connection page was visible, IGNORED otherwise
99
100 //! \brief Handles escape messages while the connection page is open
101 //! \param msg The EscapeMessage
102 //! \return EATEN if the connection page was visible, IGNORED otherwise
104 //! @}
105
106 //! \brief Provides access to the root QML item
107 //! \return A non-owning pointer to the root QQuickItem, or nullptr if not loaded
108 QQuickItem* root();
109
110 //! \brief Provides access to the shared header/footer UI
111 //! \return A non-owning pointer to the DtVreHeaderFooterUI instance, or nullptr
113
114protected:
115 //! \brief Called after initMain() in the QML load callback
116 //!
117 //! Connects this page to the shared DtVreHeaderFooterUI signals
118 //! (connectionClicked, popupOpened, popupClosed, appModeChanged).
119 //! Override in DtVreHeaderFooterUI to skip self-connection.
120 virtual void connectToHeaderFooter();
121
122 //! \brief Default handler for the connection-clicked signal
123 //!
124 //! Opens the SelectConnectionPage and registers back/escape handlers
125 //! so the user can return to this page. Override in derived classes
126 //! for custom behavior (e.g., hiding a panel before navigating).
127 virtual void onConnectionClicked();
128
129 //! \brief Default handler for popup-opened signal
130 //!
131 //! Called when any popup (settings, help, exit) opens in the shared
132 //! header/footer. Base implementation does nothing.
133 virtual void onPopupOpened();
134
135 //! \brief Default handler for popup-closed signal
136 //!
137 //! Called when any popup closes. Base implementation does nothing.
138 virtual void onPopupClosed();
139
140 //! \brief Default handler for application-mode-changed signal
141 //! \param newAppMode The new application mode identifier
142 //! \param oldAppMode The previous application mode identifier
143 //!
144 //! Called when the application mode changes. Base implementation
145 //! does nothing. Override in pages that show mode-dependent UI.
146 virtual void onAppModeChanged(const std::string& newAppMode, const std::string& oldAppMode);
147
148protected:
149 //! \brief Reference to the player station application
151
152 //! \brief Pointer to the root QML item (set asynchronously after load)
153 QQuickItem* myRoot;
154
155 //! \brief Target window name (empty for default)
156 std::string myTargetWindow;
157
158 //! \brief Relative path to the QML file
159 std::string myTargetFile;
160
161 //! \brief Object name of the main content element in QML
162 std::string myMainContentId;
163
164private:
165 //! \brief Cached pointer to the shared header/footer UI
167};
168} // namespace makVre
Main singleton responsible for managing QML files in the VREngage system.
Top-level class representing the VR-Engage application.
Definition playerStationApp.h:155
std::string myTargetWindow
Target window name (empty for default)
Definition vreBaseUI.h:156
virtual void open()
Shows the page.
virtual void onAppModeChanged(const std::string &newAppMode, const std::string &oldAppMode)
Default handler for application-mode-changed signal.
std::string myMainContentId
Object name of the main content element in QML.
Definition vreBaseUI.h:162
virtual ~DtVreBaseUI() override
Virtual destructor.
virtual void close()
Hides the page.
std::string myTargetFile
Relative path to the QML file.
Definition vreBaseUI.h:159
DtPlayerStationApp & myApp
Reference to the player station application.
Definition vreBaseUI.h:150
DtVreHeaderFooterUI * myHeaderFooterUI
Cached pointer to the shared header/footer UI.
Definition vreBaseUI.h:166
virtual bool isMainContentVisible()
Main content visibility.
virtual void setVisibility(bool visible)
Visibility control.
virtual void initMain()=0
Initializes page-specific QML elements.
DtVreMessageResult handleBackButtonClicked(DtVreMessage *msg)
Connection-page back-navigation handlers.
QQuickItem * myRoot
Pointer to the root QML item (set asynchronously after load)
Definition vreBaseUI.h:153
virtual void tick(double dt)=0
Per-frame update.
DtVreHeaderFooterUI * headerFooterUI()
Provides access to the shared header/footer UI.
virtual void onConnectionClicked()
Default handler for the connection-clicked signal.
virtual void onPopupClosed()
Default handler for popup-closed signal.
virtual bool isVisible()
Checks whether this page is visible.
virtual void connectToHeaderFooter()
Called after initMain() in the QML load callback.
DtVreBaseUI(DtPlayerStationApp &app, const std::string &file, const std::string &target_window="")
Constructor.
virtual void onPopupOpened()
Default handler for popup-opened signal.
virtual void setMainContentVisibility(bool visible)
Main content visibility.
QQuickItem * root()
Provides access to the root QML item.
DtVreMessageResult handleEscapeMessage(DtVreMessage *msg)
Handles escape messages while the connection page is open.
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
Defines export macros for the VR-Engage Player Station library.
#define PLAYERSTATION_DLL
Definition export.h:24
!
Definition glsVreMessageUtil.h:50
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
Defines the base class for all VREngage messages.