From e7882427e71ba7de0914feb74f82aba3b0f7901e Mon Sep 17 00:00:00 2001 From: Alfredo Monclus Date: Mon, 26 May 2025 10:40:51 -0600 Subject: [PATCH] Gui: property-editor add property copy context menu --- src/Gui/propertyeditor/PropertyEditor.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Gui/propertyeditor/PropertyEditor.cpp b/src/Gui/propertyeditor/PropertyEditor.cpp index 05d426de68..d86b5ab60a 100644 --- a/src/Gui/propertyeditor/PropertyEditor.cpp +++ b/src/Gui/propertyeditor/PropertyEditor.cpp @@ -26,6 +26,7 @@ #ifndef _PreComp_ #include #include +#include #include #include #include @@ -709,6 +710,7 @@ enum MenuAction MA_Touched, MA_EvalOnRestore, MA_CopyOnChange, + MA_Copy, }; void PropertyEditor::contextMenuEvent(QContextMenuEvent*) @@ -733,6 +735,15 @@ void PropertyEditor::contextMenuEvent(QContextMenuEvent*) break; } } + if (index.column() > 0) { + continue; + } + const QVariant valueToCopy = contextIndex.data(Qt::DisplayRole); + if (valueToCopy.isValid()) { + QAction* copyAction = menu.addAction(tr("Copy")); + copyAction->setData(QVariant(MA_Copy)); + menu.addSeparator(); + } } // add property @@ -848,6 +859,14 @@ void PropertyEditor::contextMenuEvent(QContextMenuEvent*) case MA_ShowHidden: PropertyView::setShowAll(action->isChecked()); return; + case MA_Copy: { + const QVariant valueToCopy = contextIndex.data(Qt::DisplayRole); + if (valueToCopy.isValid()) { + auto *clipboard = QApplication::clipboard(); + clipboard->setText(valueToCopy.toString()); + } + return; + } #define ACTION_CHECK(_name) \ case MA_##_name: \ for (auto prop : props) \