Merge pull request #2787 from p4r4digm/screenshot-path

Added setting to change the directory screenshots are stored in
This commit is contained in:
Bret Curtis 2020-05-04 17:11:49 +02:00 committed by GitHub
commit b8c467e2e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 2 deletions

View File

@ -658,7 +658,6 @@ private:
}; };
// Initialise and enter main loop. // Initialise and enter main loop.
void OMW::Engine::go() void OMW::Engine::go()
{ {
assert (!mContentFiles.empty()); assert (!mContentFiles.empty());
@ -687,7 +686,8 @@ void OMW::Engine::go()
mViewer->setUseConfigureAffinity(false); mViewer->setUseConfigureAffinity(false);
#endif #endif
mScreenCaptureOperation = new WriteScreenshotToFileOperation(mCfgMgr.getUserDataPath().string(), mScreenCaptureOperation = new WriteScreenshotToFileOperation(
mCfgMgr.getScreenshotPath().string(),
Settings::Manager::getString("screenshot format", "General")); Settings::Manager::getString("screenshot format", "General"));
mScreenCaptureHandler = new osgViewer::ScreenCaptureHandler(mScreenCaptureOperation); mScreenCaptureHandler = new osgViewer::ScreenCaptureHandler(mScreenCaptureOperation);

View File

@ -32,6 +32,14 @@ ConfigurationManager::ConfigurationManager(bool silent)
boost::filesystem::create_directories(mFixedPath.getUserDataPath()); boost::filesystem::create_directories(mFixedPath.getUserDataPath());
mLogPath = mFixedPath.getUserConfigPath(); mLogPath = mFixedPath.getUserConfigPath();
mScreenshotPath = mFixedPath.getUserDataPath() / "screenshots";
// probably not necessary but validate the creation of the screenshots directory and fallback to the original behavior if it fails
boost::system::error_code dirErr;
if (!boost::filesystem::create_directories(mScreenshotPath, dirErr) && !boost::filesystem::is_directory(mScreenshotPath)) {
mScreenshotPath = mFixedPath.getUserDataPath();
}
} }
ConfigurationManager::~ConfigurationManager() ConfigurationManager::~ConfigurationManager()
@ -196,4 +204,9 @@ const boost::filesystem::path& ConfigurationManager::getLogPath() const
return mLogPath; return mLogPath;
} }
const boost::filesystem::path& ConfigurationManager::getScreenshotPath() const
{
return mScreenshotPath;
}
} /* namespace Cfg */ } /* namespace Cfg */

View File

@ -41,6 +41,7 @@ struct ConfigurationManager
const boost::filesystem::path& getCachePath() const; const boost::filesystem::path& getCachePath() const;
const boost::filesystem::path& getLogPath() const; const boost::filesystem::path& getLogPath() const;
const boost::filesystem::path& getScreenshotPath() const;
private: private:
typedef Files::FixedPath<> FixedPathType; typedef Files::FixedPath<> FixedPathType;
@ -57,6 +58,7 @@ struct ConfigurationManager
FixedPathType mFixedPath; FixedPathType mFixedPath;
boost::filesystem::path mLogPath; boost::filesystem::path mLogPath;
boost::filesystem::path mScreenshotPath;
TokensMappingContainer mTokensMapping; TokensMappingContainer mTokensMapping;