Skip to content

Commit

Permalink
Add new getters, refactor EntitiesMenu to allow dynamic load of menu …
Browse files Browse the repository at this point in the history
…options & add component tracker for menu messages customization

Signed-off-by: Carlosespicur <[email protected]>
  • Loading branch information
Carlosespicur committed Nov 15, 2024
1 parent 3930e38 commit e394a8c
Show file tree
Hide file tree
Showing 14 changed files with 209 additions and 36 deletions.
9 changes: 9 additions & 0 deletions include/fastdds_monitor/Controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,15 @@ public slots:
QString get_type_idl (
QString entity_id);

QString get_endpoint_topic_id(
QString endpoint_id);

QString get_domain_id(
QString entity_id);

QString get_name(
QString entity_id);

QString get_data_type_name(
QString entity_id);

Expand Down
12 changes: 12 additions & 0 deletions include/fastdds_monitor/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,10 @@ class Engine : public QQmlApplicationEngine
//! Retrive a string list containing the available data kinds.
std::vector<std::string> get_data_kinds();

//! Retrieve the name associated to a specific entity
std::string get_name(
const backend::EntityId& entity_id);

//! Retrieve the data type name associated to a specific entity
std::string get_data_type_name(
const backend::EntityId& entity_id);
Expand All @@ -534,6 +538,14 @@ class Engine : public QQmlApplicationEngine
std::string get_type_idl(
const backend::EntityId& entity_id);

//! Retrieve the topic id associated to a specific endpoint
models::EntityId get_endpoint_topic_id(
const models::EntityId& endpoint_id);

//! Retrieve the id of the domain associated to an entity (Domain, DomainParticipant, Topìc or Endpoints)
models::EntityId get_domain_id(
const models::EntityId& entity_id);

//! Returns whether the data kind entered requires a target entity to be defined.
bool data_kind_has_target(
const QString& data_kind);
Expand Down
8 changes: 8 additions & 0 deletions include/fastdds_monitor/backend/SyncBackendConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ class SyncBackendConnection
EntityInfo get_info(
EntityId id);

//! Get the id of the topic associated to an endpoint
backend::EntityId get_endpoint_topic_id(
backend::EntityId endpoint_id);

//! Get the id of the domain associated to an entity (Domain, DomainParticipant, Topìc or Endpoints)
backend::EntityId get_domain_id(
backend::EntityId entity_id);

//! Get the \c EntityKind of a given \c EntityId
EntityKind get_type(
backend::EntityId id);
Expand Down
14 changes: 7 additions & 7 deletions qml/DomainGraphLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Item

// Public signals
signal update_tab_name(string new_name, string new_icon, string stack_id) // Update tab name based on selected domain id
signal openEntitiesMenu(string domainEntityId, string entityId, string currentAlias, string entityKind)
signal openEntitiesMenu(string domainEntityId, string entityId, string currentAlias, string entityKind, int caller)
signal openTopicMenu(string domainEntityId, string domainId, string entityId, string currentAlias, string entityKind, int caller)
signal openLoadingGraphDialog() //l et tab layout know that graph is about to be generated
signal initialized() // let tab layout know that graph has been generated
Expand Down Expand Up @@ -246,7 +246,7 @@ Item
onClicked:
{
if(mouse.button & Qt.RightButton) {
openTopicMenu(domain_entity_id, domain_id, modelData["id"], modelData["alias"], modelData["kind"], panels.openTopicMenuCaller.domainGraph)
openTopicMenu(domain_entity_id, domain_id, modelData["id"], modelData["alias"], modelData["kind"], panels.openMenuCaller.domainGraph)
} else {
controller.topic_click(modelData["id"])
}
Expand Down Expand Up @@ -613,7 +613,7 @@ Item
onClicked:
{
if(mouse.button & Qt.RightButton) {
openEntitiesMenu(domain_entity_id, modelData["id"], modelData["alias"], modelData["kind"])
openEntitiesMenu(domain_entity_id, modelData["id"], modelData["alias"], modelData["kind"], openMenuCaller.domainGraph)
} else {
controller.host_click(modelData["id"])
}
Expand Down Expand Up @@ -757,7 +757,7 @@ Item
onClicked:
{
if(mouse.button & Qt.RightButton) {
openEntitiesMenu(domain_entity_id, modelData["id"], modelData["alias"], modelData["kind"])
openEntitiesMenu(domain_entity_id, modelData["id"], modelData["alias"], modelData["kind"], openMenuCaller.domainGraph)
} else {
controller.user_click(modelData["id"])
}
Expand Down Expand Up @@ -900,7 +900,7 @@ Item
onClicked:
{
if(mouse.button & Qt.RightButton) {
openEntitiesMenu(domain_entity_id, modelData["id"], modelData["alias"], modelData["kind"])
openEntitiesMenu(domain_entity_id, modelData["id"], modelData["alias"], modelData["kind"], openMenuCaller.domainGraph)
} else {
controller.process_click(modelData["id"])
}
Expand Down Expand Up @@ -1067,7 +1067,7 @@ Item
onClicked:
{
if(mouse.button & Qt.RightButton) {
openEntitiesMenu(domain_entity_id, modelData["id"], modelData["alias"], modelData["kind"])
openEntitiesMenu(domain_entity_id, modelData["id"], modelData["alias"], modelData["kind"], openMenuCaller.domainGraph)
} else {
controller.participant_click(modelData["id"])
}
Expand Down Expand Up @@ -1271,7 +1271,7 @@ Item
onClicked:
{
if(mouse.button & Qt.RightButton) {
openEntitiesMenu(domain_entity_id, modelData["id"], modelData["alias"], modelData["kind"])
openEntitiesMenu(domain_entity_id, modelData["id"], modelData["alias"], modelData["kind"], openMenuCaller.domainGraph)
} else {
controller.endpoint_click(modelData["id"])
}
Expand Down
96 changes: 89 additions & 7 deletions qml/EntitiesMenu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,101 @@ import Theme 1.0
/*
Menu containing the possible actions that can be performed on any DDS, physical and logical entity.
*/


Menu {
id: entitiesMenu
property string domainEntityId: ""
property string domainEntityId: ""
property string entityId: ""
property string currentAlias: ""
property string entityKind: ""
property string showGraphButtonName: ""

signal changeAlias(string domainEntityId, string entityId, string currentAlias, string entityKind)
signal filterEntityStatusLog(string entityId)
signal openTopicView(string domainEntityId, string domainId, string topicId)

//////////////////
// Menu options //
//////////////////

Component {
id: changeAlias

MenuItem {
text: "Change alias"
MouseArea {
hoverEnabled: true
anchors.fill: parent
onEntered: parent.highlighted = true
onExited: parent.highlighted = false
onPressed: {
console.log("[EntitiesMenu] domainEntityId: ", entitiesMenu.domainEntityId)
entitiesMenu.changeAlias(entitiesMenu.domainEntityId, entitiesMenu.entityId, entitiesMenu.currentAlias, entitiesMenu.entityKind)
entitiesMenu.close()
}
}
}
}

Component {
id: viewProblems

MenuItem {
text: "View Problems"
MouseArea {
hoverEnabled: true
anchors.fill: parent
onEntered: parent.highlighted = true
onExited: parent.highlighted = false
onPressed: {
entitiesMenu.filterEntityStatusLog(entitiesMenu.entityId)
entitiesMenu.close()
}
}
}
}

Component {
id: endpointsOption

MenuItem {
text: entitiesMenu.showGraphButtonName
MouseArea {
hoverEnabled: true
anchors.fill: parent
onEntered: parent.highlighted = true
onExited: parent.highlighted = false
onPressed: {
let domain = controller.get_name(entitiesMenu.domainEntityId)
let topicId = controller.get_endpoint_topic_id(entityId)
entitiesMenu.openTopicView(entitiesMenu.domainEntityId, domain, topicId)
entitiesMenu.close()
}
}
}
}

MenuItem {
text: "Change alias"
onTriggered: changeAlias(menu.domainEntityId, menu.entityId, menu.currentAlias, menu.entityKind)
// Print menu options depending on the entity kind
ListModel {
id: entityModel
}
MenuItem {
text: "View Problems"
onTriggered: filterEntityStatusLog(menu.entityId)

Repeater {
model: entityModel
delegate: Loader {
sourceComponent: available ? entity_option : null
}
}

// Update model if some property change implies graphic changes in UI
onEntityKindChanged: updateEntityModel()
onShowGraphButtonNameChanged: updateEntityModel()

function updateEntityModel() {
entityModel.clear()
entityModel.append({"available": entitiesMenu.entityKind === "DataWriter" || entitiesMenu.entityKind === "DataReader", "entity_option": endpointsOption})
entityModel.append({"available": true, "entity_option": changeAlias})
entityModel.append({"available": true, "entity_option": viewProblems})
}
}
6 changes: 3 additions & 3 deletions qml/EntityList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Rectangle {
}
onClicked: {
if(mouse.button & Qt.RightButton) {
openEntitiesMenu("", id, name, kind)
openEntitiesMenu(controller.get_domain_id(id), id, name, kind, openMenuCaller.leftPanel)
} else {
controller.participant_click(id)
}
Expand Down Expand Up @@ -173,7 +173,7 @@ Rectangle {
}
onClicked: {
if(mouse.button & Qt.RightButton) {
openEntitiesMenu("", id, name, kind)
openEntitiesMenu(controller.get_domain_id(id), id, name, kind, openMenuCaller.leftPanel)
} else {
controller.endpoint_click(id)
}
Expand Down Expand Up @@ -245,7 +245,7 @@ Rectangle {

onClicked: {
if(mouse.button & Qt.RightButton) {
openEntitiesMenu("", id, name, kind)
openEntitiesMenu(controller.get_domain_id(id), id, name, kind, openMenuCaller.leftPanel)
} else {
controller.locator_click(id)
}
Expand Down
26 changes: 19 additions & 7 deletions qml/LeftPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ RowLayout {
Issues
}

readonly property var openTopicMenuCaller: ({
logicalPanel: 0,
// Enum exposed in Panels.qml for Menu items message customization
readonly property var openMenuCaller: ({
leftPanel: 0,
domainGraph: 1
})

Expand Down Expand Up @@ -72,7 +73,10 @@ RowLayout {

EntitiesMenu {
id: entitiesMenu
}
onChangeAlias: leftPanel.changeAlias(domainEntityId, entityId, currentAlias, entityKind)
onFilterEntityStatusLog: leftPanel.filterEntityStatusLog(entityId)
onOpenTopicView: leftPanel.openTopicView(domainEntityId, domainId, topicId)
}

TopicMenu {
id: topicMenu
Expand All @@ -92,11 +96,19 @@ RowLayout {
aliasDialog.open()
}

function openEntitiesMenu(domainEntityId, entityId, currentAlias, entityKind) {
function openEntitiesMenu(domainEntityId, entityId, currentAlias, entityKind, caller) {
entitiesMenu.domainEntityId = domainEntityId
entitiesMenu.entityId = entityId
entitiesMenu.currentAlias = currentAlias
entitiesMenu.entityKind = entityKind

if (caller === openMenuCaller.domainGraph) {
entitiesMenu.showGraphButtonName = "Filter topic graph"
}
else {
entitiesMenu.showGraphButtonName = "Show topic graph"
}

entitiesMenu.popup()
}

Expand All @@ -107,11 +119,11 @@ RowLayout {
topicMenu.currentAlias = currentAlias
topicMenu.entityKind = entityKind

if (caller === openTopicMenuCaller.logicalPanel) {
topicMenu.showGraphButtonName = "Show topic graph"
if (caller === openMenuCaller.domainGraph) {
topicMenu.showGraphButtonName = "Filter topic graph"
}
else {
topicMenu.showGraphButtonName = "Filter topic graph"
topicMenu.showGraphButtonName = "Show topic graph"
}

topicMenu.popup()
Expand Down
4 changes: 2 additions & 2 deletions qml/LogicalView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Rectangle {
}
onClicked: {
if(mouse.button & Qt.RightButton) {
openEntitiesMenu(domainId, id, name, kind)
openEntitiesMenu(domainId, id, name, kind, openMenuCaller.leftPanel)
} else {
controller.domain_click(id)
}
Expand Down Expand Up @@ -167,7 +167,7 @@ Rectangle {

onClicked: {
if(mouse.button & Qt.RightButton) {
openTopicMenu(domainId, domainName, id, name, kind, openTopicMenuCaller.logicalPanel)
openTopicMenu(domainId, domainName, id, name, kind, openMenuCaller.leftPanel)
} else {
controller.topic_click(id)
}
Expand Down
10 changes: 5 additions & 5 deletions qml/Panels.qml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ RowLayout {
}
}
onOpenEntitiesMenu: {
panels.openEntitiesMenu(domainEntityId, entityId, currentAlias, entityKind)
panels.openEntitiesMenu(domainEntityId, entityId, currentAlias, entityKind, caller)
}
onOpenTopicMenu: {
panels.openTopicMenu(domainEntityId, domainId, entityId, currentAlias, entityKind, caller)
Expand Down Expand Up @@ -164,8 +164,8 @@ RowLayout {
}
}

// Expose LeftPanel openTopicMenuCaller enum to be used in other children components (e.g: DomainGraphView.qml)
property alias openTopicMenuCaller: leftPanel.openTopicMenuCaller
// Expose LeftPanel openMenuCaller enum to be used in other children components (e.g: DomainGraphView.qml)
property alias openMenuCaller: leftPanel.openMenuCaller

function createHistoricChart(dataKind){
tabs.chartsLayout_createHistoricChart(dataKind)
Expand Down Expand Up @@ -199,8 +199,8 @@ RowLayout {
leftPanel.changeExplorerEntityInfo(status)
}

function openEntitiesMenu(domainEntityId, entityId, currentAlias, entityKind) {
leftPanel.openEntitiesMenu(domainEntityId, entityId, currentAlias, entityKind)
function openEntitiesMenu(domainEntityId, entityId, currentAlias, entityKind, caller) {
leftPanel.openEntitiesMenu(domainEntityId, entityId, currentAlias, entityKind, caller)
}

function openTopicMenu(domainEntityId, domainId, entityId, currentAlias, entityKind, caller) {
Expand Down
6 changes: 3 additions & 3 deletions qml/PhysicalView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Rectangle {
}
onClicked: {
if(mouse.button & Qt.RightButton) {
openEntitiesMenu("", id, name, kind)
openEntitiesMenu("", id, name, kind, openMenuCaller.leftPanel)
} else {
controller.host_click(id)
}
Expand Down Expand Up @@ -174,7 +174,7 @@ Rectangle {
}
onClicked: {
if(mouse.button & Qt.RightButton) {
openEntitiesMenu("", id, name, kind)
openEntitiesMenu("", id, name, kind, openMenuCaller.leftPanel)
} else {
controller.user_click(id)
}
Expand Down Expand Up @@ -246,7 +246,7 @@ Rectangle {

onClicked: {
if(mouse.button & Qt.RightButton) {
openEntitiesMenu("", id, name, kind)
openEntitiesMenu("", id, name, kind, openMenuCaller.leftPanel)
} else {
controller.process_click(id)
}
Expand Down
Loading

0 comments on commit e394a8c

Please sign in to comment.