VR-Engage  2.2
Loading...
Searching...
No Matches
qmlActionMenu.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file qmlActionMenu.h
7//! \brief Defines the QML-based action menu interface for VR-Engage
8//!
9//! This file contains the DtQmlActionMenu class which provides the interface between
10//! the C++ menu system and the QML-based UI rendering. It handles the presentation
11//! of menu items, processing selections, and coordinating with the underlying menu logic.
12
13#pragma once
14
16
17#include <QStringList>
18#include <QtQuick/QQuickItem>
19
20
21namespace makVre
22{
23class DtMenu;
24
25//! \brief QML-based action menu interface for VR-Engage
26//!
27//! DtQmlActionMenu provides the bridge between the C++ menu system and the
28//! QML-based UI rendering. It exposes menu data to QML, processes user interactions,
29//! and coordinates with the underlying DtMenu objects. This class allows the menu
30//! system to use modern QML rendering while maintaining the C++ business logic.
31class PLAYERSTATION_DLL DtQmlActionMenu : public QQuickItem
32{
33public:
34 Q_OBJECT;
35
36 //! \brief QML-invokable method for handling button clicks
37 //! \param index Index of the clicked menu item
38 //!
39 //! Called from QML when a menu button is clicked. This method processes
40 //! the selection and triggers the appropriate action.
41 Q_INVOKABLE virtual void button_clicked(int index);
42
43 //! \brief QML-invokable method for selecting menu items
44 //! \param index Index of the selected menu item
45 //!
46 //! Called from QML when a menu item is selected but not yet activated.
47 //! This updates the selection state without triggering the action.
48 Q_INVOKABLE virtual void selectItem(int index);
49
50
51public:
52 //! \brief Constructor
53 //!
54 //! Creates a new QML action menu interface with default state.
56
57 //! \brief Virtual destructor
58 //!
59 //! Ensures proper cleanup of QML resources and connections.
60 virtual ~DtQmlActionMenu() override;
61
62 //! \brief Updates the menu data exposed to QML
63 //!
64 //! Refreshes the menu item data based on the current C++ menu state,
65 //! preparing it for display by the QML UI components.
67
68 //! \brief Initializes the QML document
69 //! \param rootItem Root QML item to attach the menu to
70 //!
71 //! Sets up the QML document and establishes connections between
72 //! C++ and QML components. This must be called before the menu can be displayed.
73 void initDoc(QQuickItem* rootItem);
74
75 //! \brief Sets the visibility of the menu
76 //! \param visible True to show the menu, false to hide it
77 //!
78 //! Controls whether the menu is visible in the UI.
79 void setVisible(bool visible);
80
81 //! \brief Sets the currently selected menu item
82 //! \param index Index of the menu item to select
83 //!
84 //! Updates the selection state in the menu without triggering the action.
85 void setSelectedMenuIndex(int index);
86
87 //! \brief Sets the menu title
88 //! \param title New title text for the menu
89 //!
90 //! Updates the title displayed at the top of the menu.
91 void setTitle(const QString& title);
92
93 //! \brief Sets the maximum number of visible menu items
94 //! \param len Maximum number of items to display
95 //!
96 //! Controls the maximum number of menu items that can be displayed at once.
97 //! If there are more items than this limit, scrolling will be enabled.
98 void setMaxMenuLength(const int len);
99
100 //! \brief List of menu item text strings
101 //!
102 //! Contains the text of each menu item to be displayed in the QML UI.
103 QStringList myMenus;
104
105 //! \brief List of menu item decorators
106 //!
107 //! Contains decorator strings (like icons or badges) for menu items.
108 QStringList myDecorators;
109
110 //! \brief Root QML item for the menu
111 //!
112 //! The top-level QML item that contains the entire menu UI.
113 QQuickItem* myRoot;
114
115 //! \brief Window object for the menu
116 //!
117 //! QML window object that contains the menu interface.
118 QObject* myWindow;
119
120 //! \brief QML menu object
121 //!
122 //! The specific QML object representing the menu within the window.
123 QObject* myMenuObject;
124
125 //! \brief Current C++ menu being displayed
126 //!
127 //! Pointer to the current DtMenu instance being presented in the QML UI.
129
130 //! \brief Initial visibility flag
131 //!
132 //! Controls whether the menu is visible when first initialized.
134};
135}; // namespace makVre
Core class for all interactive menus in VR-Engage.
Definition actionMenu.h:67
void setTitle(const QString &title)
Sets the menu title.
virtual Q_INVOKABLE void button_clicked(int index)
QML-invokable method for handling button clicks.
void initDoc(QQuickItem *rootItem)
Initializes the QML document.
void setVisible(bool visible)
Sets the visibility of the menu.
DtMenu * myCurrentMenu
Current C++ menu being displayed.
Definition qmlActionMenu.h:128
void updateMenuData()
Updates the menu data exposed to QML.
virtual ~DtQmlActionMenu() override
Virtual destructor.
QStringList myMenus
List of menu item text strings.
Definition qmlActionMenu.h:103
QStringList myDecorators
List of menu item decorators.
Definition qmlActionMenu.h:108
QObject * myMenuObject
QML menu object.
Definition qmlActionMenu.h:123
QObject * myWindow
Window object for the menu.
Definition qmlActionMenu.h:118
bool initVisible
Initial visibility flag.
Definition qmlActionMenu.h:133
DtQmlActionMenu()
Constructor.
virtual Q_INVOKABLE void selectItem(int index)
QML-invokable method for selecting menu items.
void setSelectedMenuIndex(int index)
Sets the currently selected menu item.
QQuickItem * myRoot
Root QML item for the menu.
Definition qmlActionMenu.h:113
void setMaxMenuLength(const int len)
Sets the maximum number of visible menu items.
Defines export macros for the VR-Engage Player Station library.
#define PLAYERSTATION_DLL
Definition export.h:24
Include export definitions for this library.
Definition glsVreMessageUtil.h:49