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

Add "Edit As" context menu for editing objects using a base type editor #83

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
20 changes: 20 additions & 0 deletions src/PrpShop/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,26 @@ 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)) {
QAction* action = editAsMenu->addAction(
pqGetTypeIcon(type),
pqGetFriendlyClassName(type),
[this, item, type]() {
editCreatable(item->obj(), type);
}
);
if (type == item->obj()->ClassIndex()) {
editAsMenu->setDefaultAction(action);
} else {
// Enable the Edit As submenu only if it has at least one "interesting" entry,
// i. e. not just the default editor.
editAsMenu->setEnabled(true);
}
}
}
menu.addAction(fActions[kTreeEditHex]);
menu.addAction(fActions[kTreePreview]);
menu.addAction(fActions[kTreeViewTargets]);
Expand Down
4 changes: 2 additions & 2 deletions src/PrpShop/PRP/QCreatable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@ QCreatable* pqMakeCreatableForm(plCreatable* pCre, QWidget* parent, int forceTyp
return new QDynamicTextMap(pCre, parent);
case kFadeOpacityMod:
return new QFadeOpacityMod(pCre, parent);
case kInterfaceInfoModifier:
return new QInterfaceInfoModifier(pCre, parent);
case kGMaterial:
return new QMaterial(pCre, parent);
case kGUIButtonMod:
Expand Down Expand Up @@ -206,6 +204,8 @@ QCreatable* pqMakeCreatableForm(plCreatable* pCre, QWidget* parent, int forceTyp
return new QGUIUpDownPairMod(pCre, parent);
case kImageLibMod:
return new QImageLibMod(pCre, parent);
case kInterfaceInfoModifier:
return new QInterfaceInfoModifier(pCre, parent);
case kLayer:
return new QLayer(pCre, parent);
case kLayerAnimation:
Expand Down
6 changes: 3 additions & 3 deletions src/PrpShop/QPlasmaUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,18 +590,18 @@ std::vector<short> pqGetValidKOTypes()
k2WayWinAudible, kAudible, kAudibleNull, kAudioInterface, kAvLadderMod,
kCollisionDetector, kCoordinateInterface, kCubicEnvironmap,
kDetectorModifier, kDirectShadowMaster, kDrawInterface, kDynamicTextMap,
kFadeOpacityMod, kGUIButtonMod, kGUICheckBoxCtrl, kGUIClickMapCtrl,
kFadeOpacityMod, kGMaterial, kGUIButtonMod, kGUICheckBoxCtrl, kGUIClickMapCtrl,
kGUIDialogMod, kGUIDragBarCtrl, kGUIDraggableMod, kGUIDynDisplayCtrl,
kGUIEditBoxMod, kGUIKnobCtrl, kGUIListBoxMod, kGUIMenuItem,
kGUIMultiLineEditCtrl, kGUIPopUpMenu, kGUIProgressCtrl,
kGUIRadioGroupCtrl, kGUISkin, kGUITextBoxMod, kGUIUpDownPairMod,
kImageLibMod, kInterfaceInfoModifier, kLayer, kLayerAnimation,
kLayerAVI, kLayerBink, kLayerDepth, kLayerLinkAnimation, kLayerMovie,
kLayerSDLAnimation, kGMaterial, kMaintainersMarkerModifier, kMipmap,
kLayerSDLAnimation, kMaintainersMarkerModifier, kMipmap,
kMsgForwarder, kMultistageBehMod, kOneShotMod, kPanicLinkRegion,
kPickingDetector, kPointShadowMaster, kPythonFileMod, kSceneNode,
kSceneObject, kSeekPointMod, kShadowMaster, kSimulationInterface, kSound,
kSoundBuffer, kSpawnModifier, kSubworldRegionDetector, kWinAudible,
kSoundBuffer, kSpawnModifier, kSubworldRegionDetector, kSynchedObject, kWinAudible,
kWin32LinkSound, kWin32Sound, kWin32StaticSound, kWin32StreamingSound,
};
static size_t s_numTypes = sizeof(s_typeList) / sizeof(s_typeList[0]);
Expand Down