diff options
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llfolderviewitem.cpp | 6 | ||||
-rw-r--r-- | indra/newview/llfolderviewitem.h | 4 | ||||
-rw-r--r-- | indra/newview/llinventorybridge.cpp | 20 | ||||
-rw-r--r-- | indra/newview/llinventorybridge.h | 1 | ||||
-rw-r--r-- | indra/newview/llpanelmaininventory.cpp | 24 | ||||
-rw-r--r-- | indra/newview/llpreviewtexture.cpp | 22 | ||||
-rw-r--r-- | indra/newview/llviewerinventory.cpp | 19 | ||||
-rw-r--r-- | indra/newview/llviewerinventory.h | 3 |
8 files changed, 59 insertions, 40 deletions
diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp index 5bef306485..fe793fbcb8 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/newview/llfolderviewitem.cpp @@ -40,6 +40,7 @@ #include "llinventoryfilter.h" #include "llpanel.h" #include "llviewercontrol.h" // gSavedSettings +#include "llviewerinventory.h" #include "llviewerwindow.h" // Argh, only for setCursor() // linden library includes @@ -603,6 +604,11 @@ const std::string& LLFolderViewItem::getSearchableLabel() const return mSearchableLabel; } +LLViewerInventoryItem * LLFolderViewItem::getInventoryItem(void) +{ + return gInventory.getItem(getListener()->getUUID()); +} + std::string LLFolderViewItem::getName( void ) const { if(mListener) diff --git a/indra/newview/llfolderviewitem.h b/indra/newview/llfolderviewitem.h index 0ea031108b..43a5fd8de5 100644 --- a/indra/newview/llfolderviewitem.h +++ b/indra/newview/llfolderviewitem.h @@ -45,6 +45,7 @@ class LLFolderViewListenerFunctor; class LLInventoryFilter; class LLMenuGL; class LLUIImage; +class LLViewerInventoryItem; // These are grouping of inventory types. // Order matters when sorting system folders to the top. @@ -281,6 +282,9 @@ public: const LLFolderViewEventListener* getListener( void ) const { return mListener; } LLFolderViewEventListener* getListener( void ) { return mListener; } + + // Gets the inventory item if it exists (null otherwise) + LLViewerInventoryItem * getInventoryItem(void); // just rename the object. void rename(const std::string& new_name); diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 3746e9cfeb..52ebefabea 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -3150,6 +3150,22 @@ void LLTextureBridge::openItem() } } +bool LLTextureBridge::canSaveTexture(void) +{ + const LLInventoryModel* model = getInventoryModel(); + if(!model) + { + return false; + } + + const LLViewerInventoryItem *item = model->getItem(mUUID); + if (item) + { + return item->checkPermissionsSet(PERM_ITEM_UNRESTRICTED); + } + return false; +} + void LLTextureBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { lldebugs << "LLTextureBridge::buildContextMenu()" << llendl; @@ -3174,6 +3190,10 @@ void LLTextureBridge::buildContextMenu(LLMenuGL& menu, U32 flags) items.push_back(std::string("Texture Separator")); items.push_back(std::string("Save As")); + if (!canSaveTexture()) + { + disabled_items.push_back(std::string("Save As")); + } } hide_context_entries(menu, items, disabled_items); } diff --git a/indra/newview/llinventorybridge.h b/indra/newview/llinventorybridge.h index 63be9dcdb8..5e4e89a71b 100644 --- a/indra/newview/llinventorybridge.h +++ b/indra/newview/llinventorybridge.h @@ -377,6 +377,7 @@ public: protected: LLTextureBridge(LLInventoryPanel* inventory, const LLUUID& uuid, LLInventoryType::EType type) : LLItemBridge(inventory, uuid), mInvType(type) {} + bool canSaveTexture(void); LLInventoryType::EType mInvType; }; diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index 9d73fbf21a..cef21e85d6 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -1018,28 +1018,10 @@ bool LLPanelMainInventory::isSaveTextureEnabled(const LLSD& userdata) LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem(); if (current_item) { - bool can_save = false; - LLInventoryItem *item = gInventory.getItem(current_item->getListener()->getUUID()); - if(item) + LLViewerInventoryItem *inv_item = current_item->getInventoryItem(); + if(inv_item) { - const LLPermissions& perm = item->getPermissions(); - U32 mask = PERM_NONE; - if(perm.getOwner() == gAgent.getID()) - { - mask = perm.getMaskBase(); - } - else if(gAgent.isInGroup(perm.getGroup())) - { - mask = perm.getMaskGroup(); - } - else - { - mask = perm.getMaskEveryone(); - } - if((mask & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED) - { - can_save = true; - } + bool can_save = inv_item->checkPermissionsSet(PERM_ITEM_UNRESTRICTED); LLInventoryType::EType curr_type = current_item->getListener()->getInventoryType(); return can_save && (curr_type == LLInventoryType::IT_TEXTURE || curr_type == LLInventoryType::IT_SNAPSHOT); } diff --git a/indra/newview/llpreviewtexture.cpp b/indra/newview/llpreviewtexture.cpp index 86475fe2dc..26694ac433 100644 --- a/indra/newview/llpreviewtexture.cpp +++ b/indra/newview/llpreviewtexture.cpp @@ -76,29 +76,12 @@ LLPreviewTexture::LLPreviewTexture(const LLSD& key) mAspectRatio(0.f), mPreviewToSave(FALSE) { - const LLInventoryItem *item = getItem(); + const LLViewerInventoryItem *item = static_cast<const LLViewerInventoryItem*>(getItem()); if(item) { mShowKeepDiscard = item->getPermissions().getCreator() != gAgent.getID(); mImageID = item->getAssetUUID(); - const LLPermissions& perm = item->getPermissions(); - U32 mask = PERM_NONE; - if(perm.getOwner() == gAgent.getID()) - { - mask = perm.getMaskBase(); - } - else if(gAgent.isInGroup(perm.getGroup())) - { - mask = perm.getMaskGroup(); - } - else - { - mask = perm.getMaskEveryone(); - } - if((mask & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED) - { - mIsCopyable = TRUE; - } + mIsCopyable = item->checkPermissionsSet(PERM_ITEM_UNRESTRICTED); } else // not an item, assume it's an asset id { @@ -586,6 +569,7 @@ void LLPreviewTexture::loadAsset() mImage->forceToSaveRawImage(0) ; mAssetStatus = PREVIEW_ASSET_LOADING; updateDimensions(); + childSetVisible("save_tex_btn", canSaveAs()); } LLPreview::EAssetStatus LLPreviewTexture::getAssetStatus() diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 9856cb2b7f..78cee15384 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -1379,6 +1379,25 @@ LLViewerInventoryCategory *LLViewerInventoryItem::getLinkedCategory() const return NULL; } +bool LLViewerInventoryItem::checkPermissionsSet(PermissionMask mask) const +{ + const LLPermissions& perm = getPermissions(); + PermissionMask curr_mask = PERM_NONE; + if(perm.getOwner() == gAgent.getID()) + { + curr_mask = perm.getMaskBase(); + } + else if(gAgent.isInGroup(perm.getGroup())) + { + curr_mask = perm.getMaskGroup(); + } + else + { + curr_mask = perm.getMaskEveryone(); + } + return ((curr_mask & mask) == mask); +} + //---------- void LLViewerInventoryItem::onCallingCardNameLookup(const LLUUID& id, const std::string& first_name, const std::string& last_name) diff --git a/indra/newview/llviewerinventory.h b/indra/newview/llviewerinventory.h index 0156e7dab1..412a2c66e6 100644 --- a/indra/newview/llviewerinventory.h +++ b/indra/newview/llviewerinventory.h @@ -158,6 +158,9 @@ public: bool getIsBrokenLink() const; // true if the baseitem this points to doesn't exist in memory. LLViewerInventoryItem *getLinkedItem() const; LLViewerInventoryCategory *getLinkedCategory() const; + + // Checks the items permissions (for owner, group, or everyone) and returns true if all mask bits are set. + bool checkPermissionsSet(PermissionMask mask) const; // callback void onCallingCardNameLookup(const LLUUID& id, const std::string& first_name, const std::string& last_name); |