Gui: property-editor add property copy context menu
This commit is contained in:
committed by
Kacper Donat
parent
13e7952ccc
commit
e7882427e7
@@ -26,6 +26,7 @@
|
||||
#ifndef _PreComp_
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
#include <QInputDialog>
|
||||
#include <QHeaderView>
|
||||
#include <QMenu>
|
||||
@@ -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) \
|
||||
|
||||
Reference in New Issue
Block a user