diff options
author | maxim_productengine <mnikolenko@productengine.com> | 2018-05-31 14:59:31 +0300 |
---|---|---|
committer | maxim_productengine <mnikolenko@productengine.com> | 2018-05-31 14:59:31 +0300 |
commit | f2113a037c7215d0234652f6ae69c63e8b91df58 (patch) | |
tree | 89ef971c356cd0b1b707b99c1e155d4abcf2d28c /indra/newview | |
parent | 31bfc7ff47c95a9fc9c23ed101a07c071d07daaa (diff) |
MAINT-8700 Remove obsolete code and update 'Save texture' file dialog
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llfilepicker.h | 2 | ||||
-rw-r--r-- | indra/newview/llpreviewtexture.cpp | 25 | ||||
-rw-r--r-- | indra/newview/llpreviewtexture.h | 2 | ||||
-rw-r--r-- | indra/newview/llviewermenufile.cpp | 116 |
4 files changed, 15 insertions, 130 deletions
diff --git a/indra/newview/llfilepicker.h b/indra/newview/llfilepicker.h index 7914067976..2fc496a144 100644 --- a/indra/newview/llfilepicker.h +++ b/indra/newview/llfilepicker.h @@ -198,6 +198,4 @@ public: ~LLFilePicker(); }; -const std::string upload_pick(void* data); - #endif diff --git a/indra/newview/llpreviewtexture.cpp b/indra/newview/llpreviewtexture.cpp index 12bcd89cb0..9d8be4b2fe 100644 --- a/indra/newview/llpreviewtexture.cpp +++ b/indra/newview/llpreviewtexture.cpp @@ -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 diff --git a/indra/newview/llpreviewtexture.h b/indra/newview/llpreviewtexture.h index c156c48d0c..ad77d9e118 100644 --- a/indra/newview/llpreviewtexture.h +++ b/indra/newview/llpreviewtexture.h @@ -61,6 +61,8 @@ public: BOOL final, void* userdata ); void openToSave(); + + void saveTextureToFile(const std::vector<std::string>& filenames); static void onSaveAsBtn(void* data); diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index f676519153..dc05d98228 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -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) |