Skip to content

Commit

Permalink
Add "Edit As" context menu for editing objects using a base type editor
Browse files Browse the repository at this point in the history
This can be useful if only the PRC editor is available for the object's
exact type, but one of the base types has a dedicated graphical editor.
This way, at least part of the object can be edited graphically.
  • Loading branch information
dgelessus committed Mar 7, 2024
1 parent a4e21ae commit 28482df
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/PrpShop/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,24 @@ void PrpShopMain::treeContextMenu(const QPoint& pos)
} else if (item->type() == QPlasmaTreeItem::kTypeKO) {
menu.addAction(fActions[kTreeEdit]);
menu.addAction(fActions[kTreeEditPRC]);
QMenu* editAsMenu = menu.addMenu(tr("Edit A&s"));
editAsMenu->setEnabled(false);
for (short type : pqGetValidKOTypes()) {
if (item->obj()->ClassInstance(type)) {
if (type != item->obj()->ClassIndex()) {
// Enable the Edit As submenu only if it has at least one "interesting" entry,
// i. e. not just the default editor.
editAsMenu->setEnabled(true);
}
editAsMenu->addAction(
pqGetTypeIcon(type),
pqGetFriendlyClassName(type),
[this, item, type]() {
editCreatable(item->obj(), type);
}
);
}
}
menu.addAction(fActions[kTreeEditHex]);
menu.addAction(fActions[kTreePreview]);
menu.addAction(fActions[kTreeViewTargets]);
Expand Down

0 comments on commit 28482df

Please sign in to comment.