From 869c8728bc22f614e53fbcc70b0e55c71d93a0b6 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Tue, 24 Apr 2018 17:16:15 +0300 Subject: MAINT-8427 Make snapshot path consistant over sessions --- .../newview/app_settings/settings_per_account.xml | 22 +++++++++++++ indra/newview/llviewerwindow.cpp | 36 ++++++++++++++-------- indra/newview/llviewerwindow.h | 11 ++----- 3 files changed, 48 insertions(+), 21 deletions(-) diff --git a/indra/newview/app_settings/settings_per_account.xml b/indra/newview/app_settings/settings_per_account.xml index 92e61d2e86..3d4bd659f1 100644 --- a/indra/newview/app_settings/settings_per_account.xml +++ b/indra/newview/app_settings/settings_per_account.xml @@ -392,5 +392,27 @@ Value + SnapshotBaseDir + + Comment + Path to last snapshot save location + Persist + 1 + Type + String + Value + + + SnapshotBaseName + + Comment + Pattern for naming snapshots + Persist + 1 + Type + String + Value + Snapshot + diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index a6a083ec6b..2d92f394dd 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -261,10 +261,8 @@ static const F32 MIN_UI_SCALE = 0.75f; static const F32 MAX_UI_SCALE = 7.0f; static const F32 MIN_DISPLAY_SCALE = 0.75f; -std::string LLViewerWindow::sSnapshotBaseName; -std::string LLViewerWindow::sSnapshotDir; - -std::string LLViewerWindow::sMovieBaseName; +static LLCachedControl sSnapshotBaseName(LLCachedControl(gSavedPerAccountSettings, "SnapshotBaseName", "Snapshot")); +static LLCachedControl sSnapshotDir(LLCachedControl(gSavedPerAccountSettings, "SnapshotBaseDir", "")); LLTrace::SampleStatHandle<> LLViewerWindow::sMouseVelocityStat("Mouse Velocity"); @@ -1694,11 +1692,6 @@ LLViewerWindow::LLViewerWindow(const Params& p) LL_INFOS() << "NOTE: ALL NOTIFICATIONS THAT OCCUR WILL GET ADDED TO IGNORE LIST FOR LATER RUNS." << LL_ENDL; } - // Default to application directory. - LLViewerWindow::sSnapshotBaseName = "Snapshot"; - LLViewerWindow::sMovieBaseName = "SLmovie"; - resetSnapshotLoc(); - /* LLWindowCallbacks* callbacks, @@ -1877,6 +1870,11 @@ void LLViewerWindow::showSystemUIScaleFactorChanged() LLNotificationsUtil::add("SystemUIScaleFactorChanged", LLSD(), LLSD(), onSystemUIScaleFactorChanged); } +std::string LLViewerWindow::getLastSnapshotDir() +{ + return sSnapshotDir; +} + //static bool LLViewerWindow::onSystemUIScaleFactorChanged(const LLSD& notification, const LLSD& response) { @@ -4401,11 +4399,12 @@ BOOL LLViewerWindow::saveImageNumbered(LLImageFormatted *image, BOOL force_picke // Copy the directory + file name std::string filepath = picker.getFirstFile(); - LLViewerWindow::sSnapshotBaseName = gDirUtilp->getBaseFileName(filepath, true); - LLViewerWindow::sSnapshotDir = gDirUtilp->getDirName(filepath); + gSavedPerAccountSettings.setString("SnapshotBaseName", gDirUtilp->getBaseFileName(filepath, true)); + gSavedPerAccountSettings.setString("SnapshotBaseDir", gDirUtilp->getDirName(filepath)); } - if(LLViewerWindow::sSnapshotDir.empty()) + std::string snapshot_dir = sSnapshotDir; + if(snapshot_dir.empty()) { return FALSE; } @@ -4452,7 +4451,7 @@ BOOL LLViewerWindow::saveImageNumbered(LLImageFormatted *image, BOOL force_picke void LLViewerWindow::resetSnapshotLoc() { - sSnapshotDir.clear(); + gSavedPerAccountSettings.setString("SnapshotBaseDir", std::string()); } // static @@ -4506,6 +4505,17 @@ void LLViewerWindow::playSnapshotAnimAndSound() send_sound_trigger(LLUUID(gSavedSettings.getString("UISndSnapshot")), 1.0f); } +BOOL LLViewerWindow::isSnapshotLocSet() const +{ + std::string snapshot_dir = sSnapshotDir; + return !snapshot_dir.empty(); +} + +void LLViewerWindow::resetSnapshotLoc() const +{ + gSavedPerAccountSettings.setString("SnapshotBaseDir", std::string()); +} + BOOL LLViewerWindow::thumbnailSnapshot(LLImageRaw *raw, S32 preview_width, S32 preview_height, BOOL show_ui, BOOL do_rebuild, LLSnapshotModel::ESnapshotLayerType type) { return rawSnapshot(raw, preview_width, preview_height, FALSE, FALSE, show_ui, do_rebuild, type); diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index 38178fa910..c01921641c 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -350,8 +350,8 @@ public: BOOL rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_height, BOOL keep_window_aspect = TRUE, BOOL is_texture = FALSE, BOOL show_ui = TRUE, BOOL do_rebuild = FALSE, LLSnapshotModel::ESnapshotLayerType type = LLSnapshotModel::SNAPSHOT_TYPE_COLOR, S32 max_size = MAX_SNAPSHOT_IMAGE_SIZE); BOOL thumbnailSnapshot(LLImageRaw *raw, S32 preview_width, S32 preview_height, BOOL show_ui, BOOL do_rebuild, LLSnapshotModel::ESnapshotLayerType type); - BOOL isSnapshotLocSet() const { return ! sSnapshotDir.empty(); } - void resetSnapshotLoc() const { sSnapshotDir.clear(); } + BOOL isSnapshotLocSet() const; + void resetSnapshotLoc() const; BOOL saveImageNumbered(LLImageFormatted *image, BOOL force_picker, BOOL& insufficient_memory); // Reset the directory where snapshots are saved. @@ -419,7 +419,7 @@ public: bool getSystemUIScaleFactorChanged() { return mSystemUIScaleFactorChanged; } static void showSystemUIScaleFactorChanged(); - static std::string getLastSnapshotDir() { return sSnapshotDir; } + static std::string getLastSnapshotDir(); private: bool shouldShowToolTipFor(LLMouseHandler *mh); @@ -504,11 +504,6 @@ private: boost::scoped_ptr mWindowListener; boost::scoped_ptr mViewerWindowListener; - static std::string sSnapshotBaseName; - static std::string sSnapshotDir; - - static std::string sMovieBaseName; - // Object temporarily hovered over while dragging LLPointer mDragHoveredObject; -- cgit v1.2.3