Merge pull request #361 from secondlife/SL-20167

SL-20167: Grey out the clipboard when copying the material is not allowed
master
cosmic-linden 2023-09-06 15:13:11 -07:00 committed by GitHub
commit 52d973e955
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 3 deletions

View File

@ -1953,6 +1953,32 @@ bool LLMaterialEditor::canSaveObjectsMaterial()
return can_use_objects_material(func, std::vector({PERM_COPY, PERM_MODIFY}), permissions, item_out);
}
bool LLMaterialEditor::canClipboardObjectsMaterial()
{
if (LLSelectMgr::getInstance()->getSelection()->getObjectCount() != 1)
{
return false;
}
struct LLSelectedTEGetNullMat : public LLSelectedTEFunctor
{
bool apply(LLViewerObject* objectp, S32 te_index)
{
return objectp->getRenderMaterialID(te_index).isNull();
}
} null_func;
if (LLSelectMgr::getInstance()->getSelection()->applyToTEs(&null_func))
{
return true;
}
LLSelectedTEGetMatData func(true);
LLPermissions permissions;
LLViewerInventoryItem* item_out;
return can_use_objects_material(func, std::vector({PERM_COPY, PERM_MODIFY, PERM_TRANSFER}), permissions, item_out);
}
void LLMaterialEditor::saveObjectsMaterialAs()
{
LLSelectedTEGetMatData func(true);

View File

@ -115,6 +115,7 @@ class LLMaterialEditor : public LLPreview, public LLVOInventoryListener
static bool canModifyObjectsMaterial();
static bool canSaveObjectsMaterial();
static bool canClipboardObjectsMaterial();
static void saveObjectsMaterialAs();
static void onCopyObjectsMaterialAsMsgCallback(const LLSD& notification, const LLSD& response, const LLPermissions& permissions, const LLUUID& object_id, const LLUUID& item_id);
static void onSaveObjectsMaterialAsMsgCallback(const LLSD& notification, const LLSD& response, const LLPermissions& permissions);

View File

@ -1975,7 +1975,8 @@ void LLPanelFace::updateCopyTexButton()
LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getFirstObject();
mMenuClipboardTexture->setEnabled(objectp && objectp->getPCode() == LL_PCODE_VOLUME && objectp->permModify()
&& !objectp->isPermanentEnforced() && !objectp->isInventoryPending()
&& (LLSelectMgr::getInstance()->getSelection()->getObjectCount() == 1));
&& (LLSelectMgr::getInstance()->getSelection()->getObjectCount() == 1)
&& LLMaterialEditor::canClipboardObjectsMaterial());
std::string tooltip = (objectp && objectp->isInventoryPending()) ? LLTrans::getString("LoadingContents") : getString("paste_options");
mMenuClipboardTexture->setToolTip(tooltip);
}
@ -4147,7 +4148,8 @@ void LLPanelFace::onCopyTexture()
|| objectp->getPCode() != LL_PCODE_VOLUME
|| !objectp->permModify()
|| objectp->isPermanentEnforced()
|| selected_count > 1)
|| selected_count > 1
|| !LLMaterialEditor::canClipboardObjectsMaterial())
{
return;
}
@ -4342,7 +4344,8 @@ void LLPanelFace::onPasteTexture()
|| objectp->getPCode() != LL_PCODE_VOLUME
|| !objectp->permModify()
|| objectp->isPermanentEnforced()
|| selected_count > 1)
|| selected_count > 1
|| !LLMaterialEditor::canClipboardObjectsMaterial())
{
// not supposed to happen
LL_WARNS() << "Failed to paste texture due to missing or wrong selection" << LL_ENDL;