From 250a0396ac2c8af0a8139b50b55c81f036d37def Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Tue, 22 May 2018 14:24:09 +0300 Subject: MAINT-8635 Don't allow using 'close all windows' if modal toast is open --- indra/newview/llviewermenufile.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/newview/llviewermenufile.cpp') diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 90355b7166..e4525609c2 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -46,6 +46,7 @@ #include "llimagetga.h" #include "llinventorymodel.h" // gInventory #include "llresourcedata.h" +#include "lltoast.h" #include "llfloaterperms.h" #include "llstatusbar.h" #include "llviewercontrol.h" // gSavedSettings @@ -482,7 +483,7 @@ class LLFileEnableCloseWindow : public view_listener_t bool frontmost_fl_exists = (NULL != gFloaterView->getFrontmostClosableFloater()); bool frontmost_snapshot_fl_exists = (NULL != gSnapshotFloaterView->getFrontmostClosableFloater()); - return frontmost_fl_exists || frontmost_snapshot_fl_exists; + return !LLNotificationsUI::LLToast::isAlertToastShown() && (frontmost_fl_exists || frontmost_snapshot_fl_exists); } }; @@ -519,7 +520,7 @@ class LLFileEnableCloseAllWindows : public view_listener_t bool is_floaters_snapshot_opened = (floater_snapshot && floater_snapshot->isInVisibleChain()) || (floater_outfit_snapshot && floater_outfit_snapshot->isInVisibleChain()); bool open_children = gFloaterView->allChildrenClosed() && !is_floaters_snapshot_opened; - return !open_children; + return !open_children && !LLNotificationsUI::LLToast::isAlertToastShown(); } }; -- cgit v1.3 From 5219e6c455c92d789c25909d02bf094886fad3d9 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Tue, 17 Apr 2018 19:25:28 +0300 Subject: MAINT-8325 Fixed The Save Local dialog disconnects the viewer if you do not choose the save directory files within the first minute --- indra/llplugin/llpluginclassmedia.h | 2 + indra/newview/llfilepicker.cpp | 77 +++++++++++++++++++++++---------- indra/newview/llfilepicker.h | 4 +- indra/newview/llfloatermodelpreview.cpp | 12 ++++- indra/newview/llfloatermodelpreview.h | 2 +- indra/newview/llviewermedia.cpp | 75 ++++++++++++++++++-------------- indra/newview/llviewermedia.h | 4 +- indra/newview/llviewermenufile.cpp | 33 ++++++++++---- indra/newview/llviewermenufile.h | 18 +++++--- 9 files changed, 150 insertions(+), 77 deletions(-) (limited to 'indra/newview/llviewermenufile.cpp') diff --git a/indra/llplugin/llpluginclassmedia.h b/indra/llplugin/llpluginclassmedia.h index 3b3075c6bd..4f52afb317 100644 --- a/indra/llplugin/llpluginclassmedia.h +++ b/indra/llplugin/llpluginclassmedia.h @@ -317,6 +317,8 @@ public: // "init_history" message void initializeUrlHistory(const LLSD& url_history); + boost::shared_ptr getSharedPrt() { return boost::dynamic_pointer_cast(shared_from_this()); } // due to enable_shared_from_this + protected: LLPluginClassMediaOwner *mOwner; diff --git a/indra/newview/llfilepicker.cpp b/indra/newview/llfilepicker.cpp index 125a823e58..0f22b6200f 100644 --- a/indra/newview/llfilepicker.cpp +++ b/indra/newview/llfilepicker.cpp @@ -283,7 +283,7 @@ BOOL LLFilePicker::getOpenFile(ELoadFilter filter, bool blocking) return success; } -BOOL LLFilePicker::getMultipleOpenFiles(ELoadFilter filter) +BOOL LLFilePicker::getMultipleOpenFiles(ELoadFilter filter, bool blocking) { if( mLocked ) { @@ -310,9 +310,13 @@ BOOL LLFilePicker::getMultipleOpenFiles(ELoadFilter filter) setupFilter(filter); reset(); - - // Modal, so pause agent - send_agent_pause(); + + if (blocking) + { + // Modal, so pause agent + send_agent_pause(); + } + // NOTA BENE: hitting the file dialog triggers a window focus event, destroying the selection manager!! success = GetOpenFileName(&mOFN); // pauses until ok or cancel. if( success ) @@ -345,14 +349,18 @@ BOOL LLFilePicker::getMultipleOpenFiles(ELoadFilter filter) } } } - send_agent_resume(); + + if (blocking) + { + send_agent_resume(); + } // Account for the fact that the app has been stalled. LLFrameTimer::updateFrameTime(); return success; } -BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename) +BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename, bool blocking) { if( mLocked ) { @@ -540,8 +548,12 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename) reset(); - // Modal, so pause agent - send_agent_pause(); + if (blocking) + { + // Modal, so pause agent + send_agent_pause(); + } + { // NOTA BENE: hitting the file dialog triggers a window focus event, destroying the selection manager!! try @@ -559,7 +571,11 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename) } gKeyboard->resetKeys(); } - send_agent_resume(); + + if (blocking) + { + send_agent_resume(); + } // Account for the fact that the app has been stalled. LLFrameTimer::updateFrameTime(); @@ -809,7 +825,7 @@ BOOL LLFilePicker::getOpenFile(ELoadFilter filter, bool blocking) mPickOptions |= F_NAV_SUPPORT; } - if (blocking) + if (blocking) // always true for linux/mac { // Modal, so pause agent send_agent_pause(); @@ -834,7 +850,7 @@ BOOL LLFilePicker::getOpenFile(ELoadFilter filter, bool blocking) return success; } -BOOL LLFilePicker::getMultipleOpenFiles(ELoadFilter filter) +BOOL LLFilePicker::getMultipleOpenFiles(ELoadFilter filter, bool blocking) { if( mLocked ) return FALSE; @@ -852,13 +868,20 @@ BOOL LLFilePicker::getMultipleOpenFiles(ELoadFilter filter) mPickOptions |= F_FILE; mPickOptions |= F_MULTIPLE; - // Modal, so pause agent - send_agent_pause(); - + + if (blocking) // always true for linux/mac + { + // Modal, so pause agent + send_agent_pause(); + } + success = doNavChooseDialog(filter); - - send_agent_resume(); - + + if (blocking) + { + send_agent_resume(); + } + if (success) { if (!getFileCount()) @@ -872,7 +895,7 @@ BOOL LLFilePicker::getMultipleOpenFiles(ELoadFilter filter) return success; } -BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename) +BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename, bool blocking) { if( mLocked ) @@ -889,8 +912,11 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename) mPickOptions &= ~F_MULTIPLE; - // Modal, so pause agent - send_agent_pause(); + if (blocking) + { + // Modal, so pause agent + send_agent_pause(); + } success = doNavSaveDialog(filter, filename); @@ -900,7 +926,10 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename) success = false; } - send_agent_resume(); + if (blocking) + { + send_agent_resume(); + } // Account for the fact that the app has been stalled. LLFrameTimer::updateFrameTime(); @@ -1354,7 +1383,7 @@ BOOL LLFilePicker::getOpenFile( ELoadFilter filter, bool blocking ) return rtn; } -BOOL LLFilePicker::getMultipleOpenFiles( ELoadFilter filter ) +BOOL LLFilePicker::getMultipleOpenFiles( ELoadFilter filter, bool blocking) { BOOL rtn = FALSE; @@ -1438,7 +1467,7 @@ BOOL LLFilePicker::getOpenFile( ELoadFilter filter, bool blocking ) return TRUE; } -BOOL LLFilePicker::getMultipleOpenFiles( ELoadFilter filter ) +BOOL LLFilePicker::getMultipleOpenFiles( ELoadFilter filter, bool blocking) { // if local file browsing is turned off, return without opening dialog // (Even though this is a stub, I think we still should not return anything at all) @@ -1467,7 +1496,7 @@ BOOL LLFilePicker::getOpenFile( ELoadFilter filter ) return FALSE; } -BOOL LLFilePicker::getMultipleOpenFiles( ELoadFilter filter ) +BOOL LLFilePicker::getMultipleOpenFiles( ELoadFilter filter, bool blocking) { reset(); return FALSE; diff --git a/indra/newview/llfilepicker.h b/indra/newview/llfilepicker.h index b6e67375cd..7914067976 100644 --- a/indra/newview/llfilepicker.h +++ b/indra/newview/llfilepicker.h @@ -113,9 +113,9 @@ public: }; // open the dialog. This is a modal operation - BOOL getSaveFile( ESaveFilter filter = FFSAVE_ALL, const std::string& filename = LLStringUtil::null ); + BOOL getSaveFile( ESaveFilter filter = FFSAVE_ALL, const std::string& filename = LLStringUtil::null, bool blocking = true); BOOL getOpenFile( ELoadFilter filter = FFLOAD_ALL, bool blocking = true ); - BOOL getMultipleOpenFiles( ELoadFilter filter = FFLOAD_ALL ); + BOOL getMultipleOpenFiles( ELoadFilter filter = FFLOAD_ALL, bool blocking = true ); // Get the filename(s) found. getFirstFile() sets the pointer to // the start of the structure and allows the start of iteration. diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index da84a6b8f8..7a2ab37a0d 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -218,9 +218,17 @@ LLMeshFilePicker::LLMeshFilePicker(LLModelPreview* mp, S32 lod) mLOD = lod; } -void LLMeshFilePicker::notify(const std::string& filename) +void LLMeshFilePicker::notify(const std::vector& filenames) { - mMP->loadModel(mFile, mLOD); + if (filenames.size() > 0) + { + mMP->loadModel(filenames[0], mLOD); + } + else + { + //closes floater + mMP->loadModel(std::string(), mLOD); + } } void FindModel(LLModelLoader::scene& scene, const std::string& name_to_match, LLModel*& baseModelOut, LLMatrix4& matOut) diff --git a/indra/newview/llfloatermodelpreview.h b/indra/newview/llfloatermodelpreview.h index 0b2b7db2b6..53b03c6069 100644 --- a/indra/newview/llfloatermodelpreview.h +++ b/indra/newview/llfloatermodelpreview.h @@ -219,7 +219,7 @@ class LLMeshFilePicker : public LLFilePickerThread { public: LLMeshFilePicker(LLModelPreview* mp, S32 lod); - virtual void notify(const std::string& filename); + virtual void notify(const std::vector& filenames); private: LLModelPreview* mMP; diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 75108b3ef0..4334cbfda3 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -55,6 +55,7 @@ #include "llversioninfo.h" #include "llviewermediafocus.h" #include "llviewercontrol.h" +#include "llviewermenufile.h" // LLFilePickerThread #include "llviewernetwork.h" #include "llviewerparcelmedia.h" #include "llviewerparcelmgr.h" @@ -82,6 +83,43 @@ /*static*/ const char* LLViewerMedia::SHOW_MEDIA_OUTSIDE_PARCEL_SETTING = "MediaShowOutsideParcel"; +class LLMediaFilePicker : public LLFilePickerThread // deletes itself when done +{ +public: + LLMediaFilePicker(LLPluginClassMedia* plugin, LLFilePicker::ELoadFilter filter, bool get_multiple) + : LLFilePickerThread(filter, get_multiple), + mPlugin(plugin->getSharedPrt()) + { + } + + LLMediaFilePicker(LLPluginClassMedia* plugin, LLFilePicker::ESaveFilter filter, const std::string &proposed_name) + : LLFilePickerThread(filter, proposed_name), + mPlugin(plugin->getSharedPrt()) + { + } + + virtual void notify(const std::vector& filenames) + { + mPlugin->sendPickFileResponse(mResponses); + mPlugin = NULL; + } + +private: + boost::shared_ptr mPlugin; +}; + +void init_threaded_picker_load_dialog(LLPluginClassMedia* plugin, LLFilePicker::ELoadFilter filter, bool get_multiple) +{ + (new LLMediaFilePicker(plugin, filter, get_multiple))->getFile(); // will delete itself +} + +void init_threaded_picker_save_dialog(LLPluginClassMedia* plugin, LLFilePicker::ESaveFilter filter, std::string &proposed_name) +{ + (new LLMediaFilePicker(plugin, filter, proposed_name))->getFile(); // will delete itself +} + +/////////////////////////////////////////////////////////////////////////////// + // Move this to its own file. LLViewerMediaEventEmitter::~LLViewerMediaEventEmitter() @@ -1647,8 +1685,7 @@ void LLViewerMediaImpl::destroyMediaSource() if(mMediaSource) { mMediaSource->setDeleteOK(true) ; - delete mMediaSource; - mMediaSource = NULL; + mMediaSource = NULL; // shared pointer } } @@ -1840,7 +1877,7 @@ bool LLViewerMediaImpl::initializePlugin(const std::string& media_type) media_source->clear_cache(); } - mMediaSource = media_source; + mMediaSource.reset(media_source); mMediaSource->setDeleteOK(false) ; updateVolume(); @@ -3274,37 +3311,9 @@ void LLViewerMediaImpl::handleMediaEvent(LLPluginClassMedia* plugin, LLPluginCla case LLViewerMediaObserver::MEDIA_EVENT_PICK_FILE_REQUEST: { - LLFilePicker& picker = LLFilePicker::instance(); - std::vector responses; - - bool pick_multiple_files = plugin->getIsMultipleFilePick(); - if (pick_multiple_files == false) - { - picker.getOpenFile(LLFilePicker::FFLOAD_ALL); - - std::string filename = picker.getFirstFile(); - responses.push_back(filename); - } - else - { - if (picker.getMultipleOpenFiles()) - { - std::string filename = picker.getFirstFile(); - - responses.push_back(filename); - - while (!filename.empty()) - { - filename = picker.getNextFile(); + LL_DEBUGS("Media") << "Media event - file pick requested." << LL_ENDL; - if (!filename.empty()) - { - responses.push_back(filename); - } - } - } - } - plugin->sendPickFileResponse(responses); + init_threaded_picker_load_dialog(plugin, LLFilePicker::FFLOAD_ALL, plugin->getIsMultipleFilePick()); } break; diff --git a/indra/newview/llviewermedia.h b/indra/newview/llviewermedia.h index 6e18c4fecb..c52960dfcf 100644 --- a/indra/newview/llviewermedia.h +++ b/indra/newview/llviewermedia.h @@ -202,7 +202,7 @@ public: bool initializeMedia(const std::string& mime_type); bool initializePlugin(const std::string& media_type); void loadURI(); - LLPluginClassMedia* getMediaPlugin() { return mMediaSource; } + LLPluginClassMedia* getMediaPlugin() { return mMediaSource.get(); } void setSize(int width, int height); void showNotification(LLNotificationPtr notify); @@ -417,7 +417,7 @@ private: private: // a single media url with some data and an impl. - LLPluginClassMedia* mMediaSource; + boost::shared_ptr mMediaSource; F64 mZoomFactor; LLUUID mTextureId; bool mMovieImageHasMips; diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index e4525609c2..8160a3a139 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -135,18 +135,35 @@ void LLFilePickerThread::getFile() //virtual void LLFilePickerThread::run() { - LLFilePicker picker; #if LL_WINDOWS - if (picker.getOpenFile(mFilter, false)) + bool blocking = false; +#else + bool blocking = true; // modal +#endif + + LLFilePicker picker; + + if (mIsSaveDialog) { - mFile = picker.getFirstFile(); + if (picker.getSaveFile(mSaveFilter, mProposedName, blocking)) + { + mResponses.push_back(picker.getFirstFile()); + } } -#else - if (picker.getOpenFile(mFilter, true)) + else { - mFile = picker.getFirstFile(); + bool result = mIsGetMultiple ? picker.getMultipleOpenFiles(mLoadFilter, blocking) : picker.getOpenFile(mLoadFilter, blocking); + if (result) + { + std::string filename = picker.getFirstFile(); // consider copying mFiles directly + do + { + mResponses.push_back(filename); + filename = picker.getNextFile(); + } + while (mIsGetMultiple && !filename.empty()); + } } -#endif { LLMutexLock lock(sMutex); @@ -179,7 +196,7 @@ void LLFilePickerThread::clearDead() while (!sDeadQ.empty()) { LLFilePickerThread* thread = sDeadQ.front(); - thread->notify(thread->mFile); + thread->notify(thread->mResponses); delete thread; sDeadQ.pop(); } diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h index 6941b4dc0e..3e23940c3f 100644 --- a/indra/newview/llviewermenufile.h +++ b/indra/newview/llviewermenufile.h @@ -81,21 +81,29 @@ public: static void cleanupClass(); static void clearDead(); - std::string mFile; + std::vector mResponses; + std::string mProposedName; - LLFilePicker::ELoadFilter mFilter; + LLFilePicker::ELoadFilter mLoadFilter; + LLFilePicker::ESaveFilter mSaveFilter; + bool mIsSaveDialog; + bool mIsGetMultiple; - LLFilePickerThread(LLFilePicker::ELoadFilter filter) - : LLThread("file picker"), mFilter(filter) + LLFilePickerThread(LLFilePicker::ELoadFilter filter, bool get_multiple = false) + : LLThread("file picker"), mLoadFilter(filter), mIsSaveDialog(false), mIsGetMultiple(get_multiple) { + } + LLFilePickerThread(LLFilePicker::ESaveFilter filter, const std::string &proposed_name) + : LLThread("file picker"), mSaveFilter(filter), mIsSaveDialog(true), mProposedName(proposed_name) + { } void getFile(); virtual void run(); - virtual void notify(const std::string& filename) = 0; + virtual void notify(const std::vector& filenames) = 0; }; -- cgit v1.3 From 31bfc7ff47c95a9fc9c23ed101a07c071d07daaa Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Wed, 30 May 2018 18:31:30 +0300 Subject: MAINT-8700 FIXED The File dialog disconnects the viewer if you do not choose upload files within the first minute --- indra/newview/llfloaterautoreplacesettings.cpp | 108 ++++++----- indra/newview/llfloaterautoreplacesettings.h | 3 + indra/newview/llfloaterspellchecksettings.cpp | 16 +- indra/newview/llfloaterspellchecksettings.h | 1 + indra/newview/llpreviewscript.cpp | 48 ++--- indra/newview/llpreviewscript.h | 5 +- indra/newview/llviewermenufile.cpp | 253 +++++++++++++++++++------ indra/newview/llviewermenufile.h | 19 ++ 8 files changed, 303 insertions(+), 150 deletions(-) (limited to 'indra/newview/llviewermenufile.cpp') diff --git a/indra/newview/llfloaterautoreplacesettings.cpp b/indra/newview/llfloaterautoreplacesettings.cpp index 5830f2f711..ec05ba924c 100644 --- a/indra/newview/llfloaterautoreplacesettings.cpp +++ b/indra/newview/llfloaterautoreplacesettings.cpp @@ -54,6 +54,7 @@ #include "llhost.h" #include "llassetstorage.h" #include "roles_constants.h" +#include "llviewermenufile.h" // LLFilePickerReplyThread #include "llviewertexteditor.h" #include @@ -349,62 +350,58 @@ void LLFloaterAutoReplaceSettings::onDeleteEntry() // called when the Import List button is pressed void LLFloaterAutoReplaceSettings::onImportList() { - LLFilePicker& picker = LLFilePicker::instance(); - if( picker.getOpenFile( LLFilePicker::FFLOAD_XML) ) + (new LLFilePickerReplyThread(boost::bind(&LLFloaterAutoReplaceSettings::loadListFromFile, this, _1), LLFilePicker::FFLOAD_XML, false))->getFile(); +} + +void LLFloaterAutoReplaceSettings::loadListFromFile(const std::vector& filenames) +{ + llifstream file; + file.open(filenames[0].c_str()); + LLSD newList; + if (file.is_open()) { - llifstream file; - file.open(picker.getFirstFile().c_str()); - LLSD newList; - if (file.is_open()) - { - LLSDSerialize::fromXMLDocument(newList, file); - } - file.close(); + LLSDSerialize::fromXMLDocument(newList, file); + } + file.close(); - switch ( mSettings.addList(newList) ) - { - case LLAutoReplaceSettings::AddListOk: - mSelectedListName = LLAutoReplaceSettings::getListName(newList); + switch ( mSettings.addList(newList) ) + { + case LLAutoReplaceSettings::AddListOk: + mSelectedListName = LLAutoReplaceSettings::getListName(newList); - updateListNames(); - updateListNamesControls(); - updateReplacementsList(); - break; + updateListNames(); + updateListNamesControls(); + updateReplacementsList(); + break; - case LLAutoReplaceSettings::AddListDuplicateName: - { - std::string newName = LLAutoReplaceSettings::getListName(newList); - LL_WARNS("AutoReplace")<<"name '"<getFirstSelected()->getColumn(0)->getValue().asString(); - const LLSD* list = mSettings.exportList(listName); std::string listFileName = listName + ".xml"; - LLFilePicker& picker = LLFilePicker::instance(); - if( picker.getSaveFile( LLFilePicker::FFSAVE_XML, listFileName) ) - { - llofstream file; - file.open(picker.getFirstFile().c_str()); - LLSDSerialize::toPrettyXML(*list, file); - file.close(); - } + (new LLFilePickerReplyThread(boost::bind(&LLFloaterAutoReplaceSettings::saveListToFile, this, _1, listName), LLFilePicker::FFSAVE_XML, listFileName))->getFile(); +} + +void LLFloaterAutoReplaceSettings::saveListToFile(const std::vector& filenames, std::string listName) +{ + llofstream file; + const LLSD* list = mSettings.exportList(listName); + file.open(filenames[0].c_str()); + LLSDSerialize::toPrettyXML(*list, file); + file.close(); } void LLFloaterAutoReplaceSettings::onAddEntry() diff --git a/indra/newview/llfloaterautoreplacesettings.h b/indra/newview/llfloaterautoreplacesettings.h index 629aea3e3c..2109aa7026 100644 --- a/indra/newview/llfloaterautoreplacesettings.h +++ b/indra/newview/llfloaterautoreplacesettings.h @@ -112,6 +112,9 @@ private: bool selectedListIsLast(); void cleanUp(); + + void loadListFromFile(const std::vector& filenames); + void saveListToFile(const std::vector& filenames, std::string listName); }; #endif // LLFLOATERAUTOREPLACESETTINGS_H diff --git a/indra/newview/llfloaterspellchecksettings.cpp b/indra/newview/llfloaterspellchecksettings.cpp index 5124dae147..b87044ef5a 100644 --- a/indra/newview/llfloaterspellchecksettings.cpp +++ b/indra/newview/llfloaterspellchecksettings.cpp @@ -30,12 +30,13 @@ #include "llfilepicker.h" #include "llfloaterreg.h" #include "llfloaterspellchecksettings.h" +#include "llnotificationsutil.h" #include "llscrolllistctrl.h" #include "llsdserialize.h" #include "llspellcheck.h" #include "lltrans.h" #include "llviewercontrol.h" -#include "llnotificationsutil.h" +#include "llviewermenufile.h" // LLFilePickerReplyThread #include @@ -258,13 +259,12 @@ BOOL LLFloaterSpellCheckerImport::postBuild(void) void LLFloaterSpellCheckerImport::onBtnBrowse() { - LLFilePicker& file_picker = LLFilePicker::instance(); - if (!file_picker.getOpenFile(LLFilePicker::FFLOAD_DICTIONARY)) - { - return; - } + (new LLFilePickerReplyThread(boost::bind(&LLFloaterSpellCheckerImport::importSelectedDictionary, this, _1), LLFilePicker::FFLOAD_DICTIONARY, false))->getFile(); +} - std::string filepath = file_picker.getFirstFile(); +void LLFloaterSpellCheckerImport::importSelectedDictionary(const std::vector& filenames) +{ + std::string filepath = filenames[0]; const std::string extension = gDirUtilp->getExtension(filepath); if ("xcu" == extension) @@ -277,7 +277,7 @@ void LLFloaterSpellCheckerImport::onBtnBrowse() } getChild("dictionary_path")->setValue(filepath); - + mDictionaryDir = gDirUtilp->getDirName(filepath); mDictionaryBasename = gDirUtilp->getBaseFileName(filepath, true); getChild("dictionary_name")->setValue(mDictionaryBasename); diff --git a/indra/newview/llfloaterspellchecksettings.h b/indra/newview/llfloaterspellchecksettings.h index de59d83f24..f9bbefafb7 100644 --- a/indra/newview/llfloaterspellchecksettings.h +++ b/indra/newview/llfloaterspellchecksettings.h @@ -58,6 +58,7 @@ protected: void onBtnBrowse(); void onBtnCancel(); void onBtnOK(); + void importSelectedDictionary(const std::vector& filenames); std::string parseXcuFile(const std::string& file_path) const; std::string mDictionaryDir; diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 945f3c370c..d4eecaffce 100644 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -61,6 +61,7 @@ #include "llselectmgr.h" #include "llviewerinventory.h" #include "llviewermenu.h" +#include "llviewermenufile.h" // LLFilePickerReplyThread #include "llviewerobject.h" #include "llviewerobjectlist.h" #include "llviewerregion.h" @@ -1202,17 +1203,12 @@ BOOL LLScriptEdCore::handleKeyHere(KEY key, MASK mask) void LLScriptEdCore::onBtnLoadFromFile( void* data ) { - LLScriptEdCore* self = (LLScriptEdCore*) data; - - // TODO Maybe add a dialogue warning here if the current file has unsaved changes. - LLFilePicker& file_picker = LLFilePicker::instance(); - if( !file_picker.getOpenFile( LLFilePicker::FFLOAD_SCRIPT ) ) - { - //File picking cancelled by user, so nothing to do. - return; - } + (new LLFilePickerReplyThread(boost::bind(&LLScriptEdCore::loadScriptFromFile, _1, data), LLFilePicker::FFLOAD_SCRIPT, false))->getFile(); +} - std::string filename = file_picker.getFirstFile(); +void LLScriptEdCore::loadScriptFromFile(const std::vector& filenames, void* data) +{ + std::string filename = filenames[0]; llifstream fin(filename.c_str()); @@ -1220,8 +1216,8 @@ void LLScriptEdCore::onBtnLoadFromFile( void* data ) std::string text; std::string linetotal; while (!fin.eof()) - { - getline(fin,line); + { + getline(fin, line); text += line; if (!fin.eof()) { @@ -1231,7 +1227,8 @@ void LLScriptEdCore::onBtnLoadFromFile( void* data ) fin.close(); // Only replace the script if there is something to replace with. - if (text.length() > 0) + LLScriptEdCore* self = (LLScriptEdCore*)data; + if (self && (text.length() > 0)) { self->mEditor->selectAll(); LLWString script(utf8str_to_wstring(text)); @@ -1247,16 +1244,21 @@ void LLScriptEdCore::onBtnSaveToFile( void* userdata ) if( self->mSaveCallback ) { - LLFilePicker& file_picker = LLFilePicker::instance(); - if( file_picker.getSaveFile( LLFilePicker::FFSAVE_SCRIPT, self->mScriptName ) ) - { - std::string filename = file_picker.getFirstFile(); - std::string scriptText=self->mEditor->getText(); - llofstream fout(filename.c_str()); - fout<<(scriptText); - fout.close(); - self->mSaveCallback( self->mUserdata, FALSE ); - } + (new LLFilePickerReplyThread(boost::bind(&LLScriptEdCore::saveScriptToFile, _1, userdata), LLFilePicker::FFSAVE_SCRIPT, self->mScriptName))->getFile(); + } +} + +void LLScriptEdCore::saveScriptToFile(const std::vector& filenames, void* data) +{ + LLScriptEdCore* self = (LLScriptEdCore*)data; + if (self) + { + std::string filename = filenames[0]; + std::string scriptText = self->mEditor->getText(); + llofstream fout(filename.c_str()); + fout << (scriptText); + fout.close(); + self->mSaveCallback(self->mUserdata, FALSE); } } diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index a185d85889..69cf9d9158 100644 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -109,7 +109,10 @@ public: static void onBtnInsertSample(void*); static void onBtnInsertFunction(LLUICtrl*, void*); static void onBtnLoadFromFile(void*); - static void onBtnSaveToFile(void*); + static void onBtnSaveToFile(void*); + + static void loadScriptFromFile(const std::vector& filenames, void* data); + static void saveScriptToFile(const std::vector& filenames, void* data); static bool enableSaveToFileMenu(void* userdata); static bool enableLoadFromFileMenu(void* userdata); diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 8160a3a139..f676519153 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -203,6 +203,40 @@ void LLFilePickerThread::clearDead() } } +LLFilePickerReplyThread::LLFilePickerReplyThread(const file_picked_signal_t::slot_type& cb, LLFilePicker::ELoadFilter filter, bool get_multiple) + : LLFilePickerThread(filter, get_multiple), + mLoadFilter(filter), + mSaveFilter(LLFilePicker::FFSAVE_ALL), + mFilePickedSignal(NULL) +{ + mFilePickedSignal = new file_picked_signal_t(); + mFilePickedSignal->connect(cb); +} + +LLFilePickerReplyThread::LLFilePickerReplyThread(const file_picked_signal_t::slot_type& cb, LLFilePicker::ESaveFilter filter, const std::string &proposed_name) + : LLFilePickerThread(filter, proposed_name), + mLoadFilter(LLFilePicker::FFLOAD_ALL), + mSaveFilter(filter), + mFilePickedSignal(NULL) +{ + mFilePickedSignal = new file_picked_signal_t(); + mFilePickedSignal->connect(cb); +} + +LLFilePickerReplyThread::~LLFilePickerReplyThread() +{ + delete mFilePickedSignal; +} + +void LLFilePickerReplyThread::notify(const std::vector& filenames) +{ + if (filenames.empty()) return; + + if (mFilePickedSignal) + { + (*mFilePickedSignal)(filenames, mLoadFilter, mSaveFilter); + } +} //============================================================================ @@ -249,6 +283,150 @@ std::string build_extensions_string(LLFilePicker::ELoadFilter filter) } } + +const bool check_file_extension(const std::string& filename, LLFilePicker::ELoadFilter type) +{ + 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 false; + } + 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 > tokenizer; + boost::char_separator 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 false; + } + }//end else (non-null extension) + return true; +} + +const void upload_single_file(const std::vector& filenames, LLFilePicker::ELoadFilter type) +{ + std::string filename = filenames[0]; + if (!check_file_extension(filename, type)) return; + + if (!filename.empty()) + { + 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; + } + else + { + LLFloaterReg::showInstance("upload_sound", LLSD(filename)); + } + } + if (type == LLFilePicker::FFLOAD_IMAGE) + { + LLFloaterReg::showInstance("upload_image", LLSD(filename)); + } + if (type == LLFilePicker::FFLOAD_ANIM) + { + if (filename.rfind(".anim") != std::string::npos) + { + LLFloaterReg::showInstance("upload_anim_anim", LLSD(filename)); + } + else + { + LLFloaterReg::showInstance("upload_anim_bvh", LLSD(filename)); + } + } + } + return; +} + + +const void upload_bulk(const std::vector& filenames, LLFilePicker::ELoadFilter type) +{ + // TODO: + // Check user balance for entire cost + // Charge user entire cost + // Loop, uploading + // If an upload fails, refund the user for that one + // + // Also fix single upload to charge first, then refund + + S32 expected_upload_cost = LLGlobalEconomy::getInstance()->getPriceUpload(); + for (std::vector::const_iterator in_iter = filenames.begin(); in_iter != filenames.end(); ++in_iter) + { + std::string filename = (*in_iter); + if (!check_file_extension(filename, type)) continue; + + std::string name = gDirUtilp->getBaseFileName(filename, true); + std::string asset_name = name; + LLStringUtil::replaceNonstandardASCII(asset_name, '?'); + LLStringUtil::replaceChar(asset_name, '|', '?'); + LLStringUtil::stripNonprintable(asset_name); + LLStringUtil::trim(asset_name); + + LLResourceUploadInfo::ptr_t uploadInfo(new LLNewFileResourceUploadInfo( + filename, + asset_name, + asset_name, 0, + LLFolderType::FT_NONE, LLInventoryType::IT_NONE, + LLFloaterPerms::getNextOwnerPerms("Uploads"), + LLFloaterPerms::getGroupPerms("Uploads"), + LLFloaterPerms::getEveryonePerms("Uploads"), + expected_upload_cost)); + + upload_new_resource(uploadInfo, NULL, NULL); + } +} + /** char* upload_pick(void* data) @@ -369,12 +547,12 @@ class LLFileUploadImage : public view_listener_t { bool handleEvent(const LLSD& userdata) { - std::string filename = upload_pick((void *)LLFilePicker::FFLOAD_IMAGE); - if (!filename.empty()) + if (gAgentCamera.cameraMouselook()) { - LLFloaterReg::showInstance("upload_image", LLSD(filename)); + gAgentCamera.changeCameraToDefault(); } - return TRUE; + (new LLFilePickerReplyThread(boost::bind(&upload_single_file, _1, _2), LLFilePicker::FFLOAD_IMAGE, false))->getFile(); + return true; } }; @@ -396,11 +574,11 @@ class LLFileUploadSound : public view_listener_t { bool handleEvent(const LLSD& userdata) { - std::string filename = upload_pick((void*)LLFilePicker::FFLOAD_WAV); - if (!filename.empty()) + if (gAgentCamera.cameraMouselook()) { - LLFloaterReg::showInstance("upload_sound", LLSD(filename)); + gAgentCamera.changeCameraToDefault(); } + (new LLFilePickerReplyThread(boost::bind(&upload_single_file, _1, _2), LLFilePicker::FFLOAD_WAV, false))->getFile(); return true; } }; @@ -409,18 +587,11 @@ class LLFileUploadAnim : public view_listener_t { bool handleEvent(const LLSD& userdata) { - const std::string filename = upload_pick((void*)LLFilePicker::FFLOAD_ANIM); - if (!filename.empty()) + if (gAgentCamera.cameraMouselook()) { - if (filename.rfind(".anim") != std::string::npos) - { - LLFloaterReg::showInstance("upload_anim_anim", LLSD(filename)); - } - else - { - LLFloaterReg::showInstance("upload_anim_bvh", LLSD(filename)); - } + gAgentCamera.changeCameraToDefault(); } + (new LLFilePickerReplyThread(boost::bind(&upload_single_file, _1, _2), LLFilePicker::FFLOAD_ANIM, false))->getFile(); return true; } }; @@ -429,55 +600,11 @@ class LLFileUploadBulk : public view_listener_t { bool handleEvent(const LLSD& userdata) { - if( gAgentCamera.cameraMouselook() ) + if (gAgentCamera.cameraMouselook()) { gAgentCamera.changeCameraToDefault(); } - - // TODO: - // Check extensions for uploadability, cost - // Check user balance for entire cost - // Charge user entire cost - // Loop, uploading - // If an upload fails, refund the user for that one - // - // Also fix single upload to charge first, then refund - - LLFilePicker& picker = LLFilePicker::instance(); - if (picker.getMultipleOpenFiles()) - { - std::string filename = picker.getFirstFile(); - S32 expected_upload_cost = LLGlobalEconomy::getInstance()->getPriceUpload(); - - while (!filename.empty()) - { - std::string name = gDirUtilp->getBaseFileName(filename, true); - - std::string asset_name = name; - LLStringUtil::replaceNonstandardASCII( asset_name, '?' ); - LLStringUtil::replaceChar(asset_name, '|', '?'); - LLStringUtil::stripNonprintable(asset_name); - LLStringUtil::trim(asset_name); - - LLResourceUploadInfo::ptr_t uploadInfo(new LLNewFileResourceUploadInfo( - filename, - asset_name, - asset_name, 0, - LLFolderType::FT_NONE, LLInventoryType::IT_NONE, - LLFloaterPerms::getNextOwnerPerms("Uploads"), - LLFloaterPerms::getGroupPerms("Uploads"), - LLFloaterPerms::getEveryonePerms("Uploads"), - expected_upload_cost)); - - upload_new_resource(uploadInfo, NULL, NULL); - - filename = picker.getNextFile(); - } - } - else - { - LL_INFOS() << "Couldn't import objects from file" << LL_ENDL; - } + (new LLFilePickerReplyThread(boost::bind(&upload_bulk, _1, _2), LLFilePicker::FFLOAD_ALL, true))->getFile(); return true; } }; diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h index 3e23940c3f..15bbdd1e2d 100644 --- a/indra/newview/llviewermenufile.h +++ b/indra/newview/llviewermenufile.h @@ -107,4 +107,23 @@ public: }; +class LLFilePickerReplyThread : public LLFilePickerThread +{ +public: + + typedef boost::signals2::signal& filenames, LLFilePicker::ELoadFilter load_filter, LLFilePicker::ESaveFilter save_filter)> file_picked_signal_t; + + LLFilePickerReplyThread(const file_picked_signal_t::slot_type& cb, LLFilePicker::ELoadFilter filter, bool get_multiple); + LLFilePickerReplyThread(const file_picked_signal_t::slot_type& cb, LLFilePicker::ESaveFilter filter, const std::string &proposed_name); + ~LLFilePickerReplyThread(); + + virtual void notify(const std::vector& filenames); + +private: + LLFilePicker::ELoadFilter mLoadFilter; + LLFilePicker::ESaveFilter mSaveFilter; + file_picked_signal_t* mFilePickedSignal; +}; + + #endif -- cgit v1.3 From f2113a037c7215d0234652f6ae69c63e8b91df58 Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Thu, 31 May 2018 14:59:31 +0300 Subject: MAINT-8700 Remove obsolete code and update 'Save texture' file dialog --- indra/newview/llfilepicker.h | 2 - indra/newview/llpreviewtexture.cpp | 25 ++++---- indra/newview/llpreviewtexture.h | 2 + indra/newview/llviewermenufile.cpp | 116 ------------------------------------- 4 files changed, 15 insertions(+), 130 deletions(-) (limited to 'indra/newview/llviewermenufile.cpp') 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& filenames) +{ + const LLInventoryItem* item = getItem(); + if (item && mPreviewToSave) { mPreviewToSave = FALSE; LLFloaterReg::showTypedInstance("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& 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& 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 > tokenizer; - boost::char_separator 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) -- cgit v1.3