From 54d84229371dfda8a8d535f6f2c0a69a891d6440 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 1 Aug 2018 16:06:23 +0200 Subject: [PATCH] FIRE-22851: Show texture "Save as" file picker subsequently instead all at once --- indra/newview/llinventoryfunctions.cpp | 6 ++++ indra/newview/llpreviewtexture.cpp | 49 ++++++++++++++++++++++---- indra/newview/llpreviewtexture.h | 11 ++++-- 3 files changed, 57 insertions(+), 9 deletions(-) diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index 914b2bd18d..17c315dcf7 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -2677,6 +2677,12 @@ void LLInventoryAction::doToSelected(LLInventoryModel* model, LLFolderView* root { LLAppearanceMgr::instance().removeItemsFromAvatar(ids); } + // FIRE-22851: Show texture "Save as" file picker subsequently instead all at once + else if (action == "save_as") // "save_as" is only available for textures as of 01/08/2018 + { + LLPreviewTexture::saveMultiple(ids); + } + // else { std::set::iterator set_iter; diff --git a/indra/newview/llpreviewtexture.cpp b/indra/newview/llpreviewtexture.cpp index 08cba5c71c..07c1bcdb9b 100644 --- a/indra/newview/llpreviewtexture.cpp +++ b/indra/newview/llpreviewtexture.cpp @@ -383,21 +383,32 @@ BOOL LLPreviewTexture::canSaveAs() const // virtual void LLPreviewTexture::saveAs() { - // Allow to use user-defined default save format for textures + // FIRE-22851: Show texture "Save as" file picker subsequently instead all at once // saveAs(LLPreviewTexture::FORMAT_TGA); + saveAs(uuid_vec_t()); + // +} + +// FIRE-22851: Show texture "Save as" file picker subsequently instead all at once +void LLPreviewTexture::saveAs(uuid_vec_t remaining_ids) +{ + // Allow to use user-defined default save format for textures if (!gSavedSettings.getBOOL("FSTextureDefaultSaveAsFormat")) { - saveAs(LLPreviewTexture::FORMAT_TGA); + saveAs(LLPreviewTexture::FORMAT_TGA, remaining_ids); } else { - saveAs(LLPreviewTexture::FORMAT_PNG); + saveAs(LLPreviewTexture::FORMAT_PNG, remaining_ids); } // - } +// -void LLPreviewTexture::saveAs(EFileformatType format) +// FIRE-22851: Show texture "Save as" file picker subsequently instead all at once +//void LLPreviewTexture::saveAs(EFileformatType format) +void LLPreviewTexture::saveAs(EFileformatType format, uuid_vec_t remaining_ids) +// { if (mLoadingFullImage) return; @@ -422,13 +433,13 @@ void LLPreviewTexture::saveAs(EFileformatType format) //std::string filename = getItem() ? LLDir::getScrubbedFileName(getItem()->getName()) : LLStringUtil::null; //(new LLFilePickerReplyThread(boost::bind(&LLPreviewTexture::saveTextureToFile, this, _1), LLFilePicker::FFSAVE_TGAPNG, filename))->getFile(); std::string filename = getItem() ? checkFileExtension(LLDir::getScrubbedFileName(getItem()->getName()), format) : LLStringUtil::null; - (new LLFilePickerReplyThread(boost::bind(&LLPreviewTexture::saveTextureToFile, this, _1, format, callback), saveFilter, filename))->getFile(); + (new LLFilePickerReplyThread(boost::bind(&LLPreviewTexture::saveTextureToFile, this, _1, format, callback, remaining_ids), saveFilter, filename))->getFile(); // } // Undo MAINT-2897 and use our own texture format selection //void LLPreviewTexture::saveTextureToFile(const std::vector& filenames) -void LLPreviewTexture::saveTextureToFile(const std::vector& filenames, EFileformatType format, loaded_callback_func callback) +void LLPreviewTexture::saveTextureToFile(const std::vector& filenames, EFileformatType format, loaded_callback_func callback, uuid_vec_t remaining_ids) // { const LLInventoryItem* item = getItem(); @@ -452,6 +463,9 @@ void LLPreviewTexture::saveTextureToFile(const std::vector& filenam mImage->setLoadedCallback(callback, // 0, TRUE, FALSE, new LLUUID(mItemUUID), &mCallbackTextureList); + + // FIRE-22851: Show texture "Save as" file picker subsequently instead all at once + saveMultiple(remaining_ids); } // virtual @@ -1137,3 +1151,24 @@ void LLPreviewTexture::onButtonRefresh() destroy_texture(mImageID); } // + +// FIRE-22851: Show texture "Save as" file picker subsequently instead all at once +//static +void LLPreviewTexture::saveMultiple(uuid_vec_t ids) +{ + if (ids.empty()) + { + return; + } + + LLUUID next_id = ids.front(); + ids.erase(ids.begin()); + + LLPreviewTexture* preview_texture = LLFloaterReg::getTypedInstance("preview_texture", next_id); + if (preview_texture) + { + preview_texture->openToSave(); + preview_texture->saveAs(ids); + } +} +// diff --git a/indra/newview/llpreviewtexture.h b/indra/newview/llpreviewtexture.h index 2c8341f322..4b24690a32 100644 --- a/indra/newview/llpreviewtexture.h +++ b/indra/newview/llpreviewtexture.h @@ -55,7 +55,11 @@ public: virtual BOOL canSaveAs() const; virtual void saveAs(); - void saveAs(EFileformatType format); + // FIRE-22851: Show texture "Save as" file picker subsequently instead all at once + //void saveAs(EFileformatType format); + virtual void saveAs(uuid_vec_t remaining_ids); + void saveAs(EFileformatType format, uuid_vec_t remaining_ids = uuid_vec_t()); + // Undo MAINT-2897 and use our own texture format selection //void saveTextureToFile(const std::vector& filenames); - void saveTextureToFile(const std::vector& filenames, EFileformatType format, loaded_callback_func callback); + void saveTextureToFile(const std::vector& filenames, EFileformatType format, loaded_callback_func callback, uuid_vec_t remaining_ids = uuid_vec_t()); // static void onSaveAsBtn(LLUICtrl* ctrl, void* data); @@ -103,6 +107,9 @@ public: // FIRE-20150: Add refresh button to texture preview void onButtonRefresh(); + // FIRE-22851: Show texture "Save as" file picker subsequently instead all at once + static void saveMultiple(uuid_vec_t ids); + protected: void init(); void populateRatioList();