MAINT-8700 Remove obsolete code and update 'Save texture' file dialog
parent
31bfc7ff47
commit
f2113a037c
|
|
@ -198,6 +198,4 @@ public:
|
|||
~LLFilePicker();
|
||||
};
|
||||
|
||||
const std::string upload_pick(void* data);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@
|
|||
#include "lltextureview.h"
|
||||
#include "llui.h"
|
||||
#include "llviewerinventory.h"
|
||||
#include "llviewermenufile.h" // LLFilePickerReplyThread
|
||||
#include "llviewertexture.h"
|
||||
#include "llviewertexturelist.h"
|
||||
#include "lluictrlfactory.h"
|
||||
|
|
@ -293,27 +294,27 @@ void LLPreviewTexture::saveAs()
|
|||
if( mLoadingFullImage )
|
||||
return;
|
||||
|
||||
LLFilePicker& file_picker = LLFilePicker::instance();
|
||||
const LLInventoryItem* item = getItem() ;
|
||||
if( !file_picker.getSaveFile( LLFilePicker::FFSAVE_TGAPNG, item ? LLDir::getScrubbedFileName(item->getName()) : LLStringUtil::null) )
|
||||
{
|
||||
// User canceled or we failed to acquire save file.
|
||||
return;
|
||||
}
|
||||
if(mPreviewToSave)
|
||||
std::string filename = getItem() ? LLDir::getScrubbedFileName(getItem()->getName()) : LLStringUtil::null;
|
||||
(new LLFilePickerReplyThread(boost::bind(&LLPreviewTexture::saveTextureToFile, this, _1), LLFilePicker::FFSAVE_TGAPNG, filename))->getFile();
|
||||
}
|
||||
|
||||
void LLPreviewTexture::saveTextureToFile(const std::vector<std::string>& filenames)
|
||||
{
|
||||
const LLInventoryItem* item = getItem();
|
||||
if (item && mPreviewToSave)
|
||||
{
|
||||
mPreviewToSave = FALSE;
|
||||
LLFloaterReg::showTypedInstance<LLPreviewTexture>("preview_texture", item->getUUID());
|
||||
}
|
||||
|
||||
// remember the user-approved/edited file name.
|
||||
mSaveFileName = file_picker.getFirstFile();
|
||||
mSaveFileName = filenames[0];
|
||||
mLoadingFullImage = TRUE;
|
||||
getWindow()->incBusyCount();
|
||||
|
||||
mImage->forceToSaveRawImage(0) ;//re-fetch the raw image if the old one is removed.
|
||||
mImage->setLoadedCallback( LLPreviewTexture::onFileLoadedForSave,
|
||||
0, TRUE, FALSE, new LLUUID( mItemUUID ), &mCallbackTextureList );
|
||||
mImage->forceToSaveRawImage(0);//re-fetch the raw image if the old one is removed.
|
||||
mImage->setLoadedCallback(LLPreviewTexture::onFileLoadedForSave,
|
||||
0, TRUE, FALSE, new LLUUID(mItemUUID), &mCallbackTextureList);
|
||||
}
|
||||
|
||||
// virtual
|
||||
|
|
|
|||
|
|
@ -61,6 +61,8 @@ public:
|
|||
BOOL final,
|
||||
void* userdata );
|
||||
void openToSave();
|
||||
|
||||
void saveTextureToFile(const std::vector<std::string>& filenames);
|
||||
|
||||
static void onSaveAsBtn(void* data);
|
||||
|
||||
|
|
|
|||
|
|
@ -427,122 +427,6 @@ const void upload_bulk(const std::vector<std::string>& filenames, LLFilePicker::
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
char* upload_pick(void* data)
|
||||
|
||||
If applicable, brings up a file chooser in which the user selects a file
|
||||
to upload for a particular task. If the file is valid for the given action,
|
||||
returns the string to the full path filename, else returns NULL.
|
||||
Data is the load filter for the type of file as defined in LLFilePicker.
|
||||
**/
|
||||
const std::string upload_pick(void* data)
|
||||
{
|
||||
if( gAgentCamera.cameraMouselook() )
|
||||
{
|
||||
gAgentCamera.changeCameraToDefault();
|
||||
// This doesn't seem necessary. JC
|
||||
// display();
|
||||
}
|
||||
|
||||
LLFilePicker::ELoadFilter type;
|
||||
if(data)
|
||||
{
|
||||
type = (LLFilePicker::ELoadFilter)((intptr_t)data);
|
||||
}
|
||||
else
|
||||
{
|
||||
type = LLFilePicker::FFLOAD_ALL;
|
||||
}
|
||||
|
||||
LLFilePicker& picker = LLFilePicker::instance();
|
||||
if (!picker.getOpenFile(type))
|
||||
{
|
||||
LL_INFOS() << "Couldn't import objects from file" << LL_ENDL;
|
||||
return std::string();
|
||||
}
|
||||
|
||||
|
||||
const std::string& filename = picker.getFirstFile();
|
||||
std::string ext = gDirUtilp->getExtension(filename);
|
||||
|
||||
//strincmp doesn't like NULL pointers
|
||||
if (ext.empty())
|
||||
{
|
||||
std::string short_name = gDirUtilp->getBaseFileName(filename);
|
||||
|
||||
// No extension
|
||||
LLSD args;
|
||||
args["FILE"] = short_name;
|
||||
LLNotificationsUtil::add("NoFileExtension", args);
|
||||
return std::string();
|
||||
}
|
||||
else
|
||||
{
|
||||
//so there is an extension
|
||||
//loop over the valid extensions and compare to see
|
||||
//if the extension is valid
|
||||
|
||||
//now grab the set of valid file extensions
|
||||
std::string valid_extensions = build_extensions_string(type);
|
||||
|
||||
BOOL ext_valid = FALSE;
|
||||
|
||||
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
|
||||
boost::char_separator<char> sep(" ");
|
||||
tokenizer tokens(valid_extensions, sep);
|
||||
tokenizer::iterator token_iter;
|
||||
|
||||
//now loop over all valid file extensions
|
||||
//and compare them to the extension of the file
|
||||
//to be uploaded
|
||||
for( token_iter = tokens.begin();
|
||||
token_iter != tokens.end() && ext_valid != TRUE;
|
||||
++token_iter)
|
||||
{
|
||||
const std::string& cur_token = *token_iter;
|
||||
|
||||
if (cur_token == ext || cur_token == "*.*")
|
||||
{
|
||||
//valid extension
|
||||
//or the acceptable extension is any
|
||||
ext_valid = TRUE;
|
||||
}
|
||||
}//end for (loop over all tokens)
|
||||
|
||||
if (ext_valid == FALSE)
|
||||
{
|
||||
//should only get here if the extension exists
|
||||
//but is invalid
|
||||
LLSD args;
|
||||
args["EXTENSION"] = ext;
|
||||
args["VALIDS"] = valid_extensions;
|
||||
LLNotificationsUtil::add("InvalidFileExtension", args);
|
||||
return std::string();
|
||||
}
|
||||
}//end else (non-null extension)
|
||||
|
||||
//valid file extension
|
||||
|
||||
//now we check to see
|
||||
//if the file is actually a valid image/sound/etc.
|
||||
if (type == LLFilePicker::FFLOAD_WAV)
|
||||
{
|
||||
// pre-qualify wavs to make sure the format is acceptable
|
||||
std::string error_msg;
|
||||
if (check_for_invalid_wav_formats(filename,error_msg))
|
||||
{
|
||||
LL_INFOS() << error_msg << ": " << filename << LL_ENDL;
|
||||
LLSD args;
|
||||
args["FILE"] = filename;
|
||||
LLNotificationsUtil::add( error_msg, args );
|
||||
return std::string();
|
||||
}
|
||||
}//end if a wave/sound file
|
||||
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
class LLFileUploadImage : public view_listener_t
|
||||
{
|
||||
bool handleEvent(const LLSD& userdata)
|
||||
|
|
|
|||
Loading…
Reference in New Issue