Automated merge with ssh://hg.lindenlab.com/viewer/viewer-2-0/

meow-7.2.2
Eric M. Tulla (BigPapi) 2009-12-09 20:25:18 -05:00
commit c971462f6e
7 changed files with 79 additions and 54 deletions

View File

@ -33,6 +33,7 @@
#include "llviewerprecompiledheaders.h"
#include "llpanelmaininventory.h"
#include "llagent.h"
#include "lldndbutton.h"
#include "llfilepicker.h"
#include "llfloaterinventory.h"
@ -863,7 +864,6 @@ void LLPanelMainInventory::initListCommandsHandlers()
mEnableCallbackRegistrar.add("Inventory.GearDefault.Enable", boost::bind(&LLPanelMainInventory::isActionEnabled, this, _2));
mMenuGearDefault = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_inventory_gear_default.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
mMenuAdd = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_inventory_add.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
}
void LLPanelMainInventory::updateListCommands()
@ -909,6 +909,22 @@ void LLPanelMainInventory::onClipboardAction(const LLSD& userdata)
getActivePanel()->getRootFolder()->doToSelected(getActivePanel()->getModel(),command_name);
}
void LLPanelMainInventory::saveTexture(const LLSD& userdata)
{
LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem();
if (!current_item)
{
return;
}
const LLUUID& item_id = current_item->getListener()->getUUID();
LLPreviewTexture* preview_texture = LLFloaterReg::showTypedInstance<LLPreviewTexture>("preview_texture", LLSD(item_id), TAKE_FOCUS_YES);
if (preview_texture)
{
preview_texture->openToSave();
}
}
void LLPanelMainInventory::onCustomAction(const LLSD& userdata)
{
if (!isActionEnabled(userdata))
@ -953,18 +969,7 @@ void LLPanelMainInventory::onCustomAction(const LLSD& userdata)
}
if (command_name == "save_texture")
{
LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem();
if (!current_item)
{
return;
}
const LLUUID& item_id = current_item->getListener()->getUUID();
LLPreviewTexture* preview_texture = LLFloaterReg::showTypedInstance<LLPreviewTexture>("preview_texture", LLSD(item_id), TAKE_FOCUS_YES);
if (preview_texture)
{
preview_texture->openToSave();
}
saveTexture(userdata);
}
// This doesn't currently work, since the viewer can't change an assetID an item.
if (command_name == "regenerate_link")
@ -1008,6 +1013,40 @@ void LLPanelMainInventory::onCustomAction(const LLSD& userdata)
}
}
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)
{
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;
}
LLInventoryType::EType curr_type = current_item->getListener()->getInventoryType();
return can_save && (curr_type == LLInventoryType::IT_TEXTURE || curr_type == LLInventoryType::IT_SNAPSHOT);
}
}
return false;
}
BOOL LLPanelMainInventory::isActionEnabled(const LLSD& userdata)
{
const std::string command_name = userdata.asString();
@ -1035,12 +1074,7 @@ BOOL LLPanelMainInventory::isActionEnabled(const LLSD& userdata)
}
if (command_name == "save_texture")
{
LLFolderViewItem* current_item = getActivePanel()->getRootFolder()->getCurSelectedItem();
if (current_item)
{
return (current_item->getListener()->getInventoryType() == LLInventoryType::IT_TEXTURE);
}
return FALSE;
return isSaveTextureEnabled(userdata);
}
if (command_name == "find_original")
{

View File

@ -110,6 +110,8 @@ protected:
void doCreate(const LLSD& userdata);
void resetFilters();
void setSortBy(const LLSD& userdata);
void saveTexture(const LLSD& userdata);
bool isSaveTextureEnabled(const LLSD& userdata);
private:
LLFloaterInventoryFinder* getFinder();

View File

@ -145,6 +145,9 @@ BOOL LLPreviewTexture::postBuild()
childSetVisible("Discard", false);
}
childSetAction("save_tex_btn", LLPreviewTexture::onSaveAsBtn, this);
childSetVisible("save_tex_btn", canSaveAs());
if (!mCopyToInv)
{
const LLInventoryItem* item = getItem();
@ -164,6 +167,13 @@ BOOL LLPreviewTexture::postBuild()
return LLPreview::postBuild();
}
// static
void LLPreviewTexture::onSaveAsBtn(void* data)
{
LLPreviewTexture* self = (LLPreviewTexture*)data;
self->saveAs();
}
void LLPreviewTexture::draw()
{
if (mUpdateDimensions)

View File

@ -58,7 +58,6 @@ public:
virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
virtual void onFocusReceived();
static void saveToFile(void* userdata);
static void onFileLoadedForSave(
BOOL success,
LLViewerFetchedTexture *src_vi,
@ -68,6 +67,8 @@ public:
BOOL final,
void* userdata );
void openToSave();
static void onSaveAsBtn(void* data);
protected:
void init();
/* virtual */ BOOL postBuild();

View File

@ -71,15 +71,6 @@
// system libraries
#include <boost/tokenizer.hpp>
class LLFileEnableSaveAs : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
{
bool new_value = gFloaterView->getFrontmost() && gFloaterView->getFrontmost()->canSaveAs();
return new_value;
}
};
class LLFileEnableUpload : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
@ -386,19 +377,6 @@ class LLFileCloseAllWindows : public view_listener_t
}
};
class LLFileSaveTexture : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
{
LLFloater* top = gFloaterView->getFrontmost();
if (top)
{
top->saveAs();
}
return true;
}
};
class LLFileTakeSnapshotToDisk : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
@ -1050,10 +1028,10 @@ void init_menu_file()
view_listener_t::addCommit(new LLFileCloseAllWindows(), "File.CloseAllWindows");
view_listener_t::addEnable(new LLFileEnableCloseWindow(), "File.EnableCloseWindow");
view_listener_t::addEnable(new LLFileEnableCloseAllWindows(), "File.EnableCloseAllWindows");
view_listener_t::addCommit(new LLFileSaveTexture(), "File.SaveTexture");
view_listener_t::addCommit(new LLFileTakeSnapshotToDisk(), "File.TakeSnapshotToDisk");
view_listener_t::addCommit(new LLFileQuit(), "File.Quit");
view_listener_t::addEnable(new LLFileEnableUpload(), "File.EnableUpload");
view_listener_t::addEnable(new LLFileEnableSaveAs(), "File.EnableSaveAs");
// "File.SaveTexture" moved to llpanelmaininventory so that it can be properly handled.
}

View File

@ -61,7 +61,16 @@
name="Discard"
top_delta="0"
width="100" />
<text
<button
follows="left|bottom"
height="22"
label="Save As"
layout="topleft"
left_pad="5"
name="save_tex_btn"
top_delta="0"
width="100" />
<text
type="string"
length="1"
follows="left|bottom"

View File

@ -1200,15 +1200,6 @@
function="ToggleControl"
parameter="CompressSnapshotsToDisk" />
</menu_item_check>
<menu_item_call
label="Save Texture As"
layout="topleft"
name="Save Texture As">
<menu_item_call.on_click
function="File.SaveTexture" />
<menu_item_call.on_enable
function="File.EnableSaveAs" />
</menu_item_call>
<menu_item_separator
layout="topleft" />
<menu