Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[22912]: Add IDL demangling functionality to the monitor #254

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ set(PROJECT_HEADERS
${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/Controller.h
${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/Engine.h
${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/io/csv.h
${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/io/ClipboardHandler.h
${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/model/dds/EndpointModelItem.h
${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/model/dds/LocatorModelItem.h
${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/model/dds/ParticipantModelItem.h
Expand Down
36 changes: 36 additions & 0 deletions include/fastdds_monitor/io/ClipboardHandler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#ifndef CLIPBOARDHANDLER_H
#define CLIPBOARDHANDLER_H

#include <QClipboard>
#include <QQmlEngine>
#include <QGuiApplication>

class ClipboardHandler : public QObject
{
Q_OBJECT

public:

explicit ClipboardHandler(
QObject* parent = nullptr)
: QObject(parent)
{
}

// Expose the clipboard object directly to QML
Q_INVOKABLE void setClipboardText(
const QString& text)
{
QClipboard* clipboard = QGuiApplication::clipboard();
clipboard->setText(text);
}

Q_INVOKABLE QString getClipboardText()
{
QClipboard* clipboard = QGuiApplication::clipboard();
return clipboard->text();
}

};

#endif // CLIPBOARDHANDLER_H
2 changes: 1 addition & 1 deletion qml/DomainGraphLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Item
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, 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 openLoadingGraphDialog() // let tab layout know that graph is about to be generated
signal initialized() // let tab layout know that graph has been generated

// Private properties
Expand Down
47 changes: 47 additions & 0 deletions qml/TabLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15

import Theme 1.0
import Clipboard 1.0

Item {
id: tabLayout
Expand Down Expand Up @@ -84,6 +85,10 @@ Item {
}
}

ClipboardHandler {
id: clipboardHandler
}

// stack layout (where idx referred to the tab, which would contain different views)
StackLayout {
id: stack_layout
Expand Down Expand Up @@ -342,13 +347,55 @@ Item {

MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
onWheel: {
if(wheel.angleDelta.y > 0){
vertical_bar.decrease()
}else{
vertical_bar.increase()
}
}
onPressed: {
if(mouse.button & Qt.RightButton) {
var start = idl_text.selectionStart
var end = idl_text.selectionEnd
idl_text.focus = true
contextMenu.popup()
idl_text.select(start, end)
}
}
}

Menu {
id: contextMenu
MenuItem {
text: "Copy"
onTriggered: {
if (clipboardHandler) {
let textToCopy = idl_text.selectedText.length > 0 ? idl_text.selectedText : idl_text.text
clipboardHandler.setClipboardText(textToCopy)
}else{
console.log("Clipboard not available")
}
}
}
MenuItem {
text: "Select All"
onTriggered: {
idl_text.selectAll()
}
}
MenuItem {
text: "Copy IDL title"
onTriggered: {
if (clipboardHandler) {
let textToCopy = tabLayout.tab_model_[current_]["title"]
clipboardHandler.setClipboardText(textToCopy)
}else{
console.log("Clipboard not available")
}
}
}
}

TextEdit
Expand Down
1 change: 1 addition & 0 deletions qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import QtGraphicalEffects 1.15
import QtQuick.Dialogs 1.2

import Theme 1.0
import Clipboard 1.0

ApplicationWindow {
id: mainApplicationView
Expand Down
20 changes: 20 additions & 0 deletions src/io/ClipboardHandler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <fastdds_monitor/io/ClipboardHandler.h>

ClipboardHandler::ClipboardHandler(
QObject* parent)
: QObject(parent)
{
}

void ClipboardHandler::setClipboardText(
const QString& text)
{
QClipboard* clipboard = QGuiApplication::clipboard();
clipboard->setText(text);
}

QString ClipboardHandler::getClipboardText()
{
QClipboard* clipboard = QGuiApplication::clipboard();
return clipboard->text();
}
6 changes: 6 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@
#include <QApplication>
#include <QDebug>
#include <QQmlApplicationEngine>
#include <QClipboard>
#include <QtQml>
#include <QQmlContext>
#include <QtQuick/QQuickView>

#include <fastdds_monitor/Engine.h>
#include <fastdds_monitor/io/ClipboardHandler.h>

int main(
int argc,
Expand All @@ -41,6 +44,9 @@ int main(
******************************************************************************************************************/

Engine engine;

qmlRegisterType<ClipboardHandler>("Clipboard", 1, 0, "ClipboardHandler");

QObject* topLevel = engine.enable();

QQuickWindow* window = qobject_cast<QQuickWindow*>(topLevel); \
Expand Down
Loading