Commit fbc98680 authored by Cory Quammen's avatar Cory Quammen

Fixed where branded applications save their settings

Now settings are saved to a directory with the branded application
name.

Change-Id: I2a9f99d47d43e2567588eab0b1bac71cac64a9b7
parent e5e547a5
......@@ -44,6 +44,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqOptions.h"
#include "pqPVApplicationCore.h"
#include "pqSettings.h"
#include "vtkInitializationHelper.h"
#include "vtkPVPluginTracker.h"
#ifdef Q_WS_X11
......@@ -75,6 +76,8 @@ pq@BPC_NAME@Initializer::~pq@BPC_NAME@Initializer()
//-----------------------------------------------------------------------------
bool pq@BPC_NAME@Initializer::Initialize(int argc, char* argv[])
{
vtkInitializationHelper::SetApplicationName("@BPC_APPLICATION_NAME@");
this->PVApp = new pqPVApplicationCore (argc, argv);
// Attach custom event filter
......@@ -90,7 +93,7 @@ bool pq@BPC_NAME@Initializer::Initialize(int argc, char* argv[])
#ifndef BUILD_SHARED_LIBS
@ui_resource_init@
#endif
#endif
pqSettings *settings = this->PVApp->settings();
bool show_splash = false;
......
......@@ -83,7 +83,11 @@ std::string ListAttachedMonitors()
} // end anon namespace
bool vtkInitializationHelper::LoadSettingsFilesDuringInitialization = true;
bool vtkInitializationHelper::SaveUserSettingsFileDuringFinalization = false;
std::string vtkInitializationHelper::ApplicationName = "ParaView";
//----------------------------------------------------------------------------
void vtkInitializationHelper::SetLoadSettingsFilesDuringInitialization(bool val)
{
......@@ -105,6 +109,18 @@ bool vtkInitializationHelper::GetLoadSettingsFilesDuringInitialization()
return vtkInitializationHelper::LoadSettingsFilesDuringInitialization;
}
//----------------------------------------------------------------------------
void vtkInitializationHelper::SetApplicationName(const std::string & appName)
{
vtkInitializationHelper::ApplicationName = appName;
}
//----------------------------------------------------------------------------
std::string vtkInitializationHelper::GetApplicationName()
{
return vtkInitializationHelper::ApplicationName;
}
//----------------------------------------------------------------------------
void vtkInitializationHelper::Initialize(const char* executable, int type)
{
......@@ -326,6 +342,7 @@ bool vtkInitializationHelper::LoadSettings()
//----------------------------------------------------------------------------
std::string vtkInitializationHelper::GetUserSettingsDirectory()
{
std::string applicationName(vtkInitializationHelper::GetApplicationName());
#if defined(WIN32)
const char* appData = getenv("APPDATA");
if (!appData)
......@@ -333,12 +350,12 @@ std::string vtkInitializationHelper::GetUserSettingsDirectory()
return std::string();
}
std::string separator("\\");
std::string fileName(appData);
if (fileName[fileName.size()-1] != separator[0])
std::string directoryPath(appData);
if (directoryPath[directoryPath.size()-1] != separator[0])
{
fileName.append(separator);
directoryPath.append(separator);
}
fileName += "ParaView" + separator;
directoryPath += applicationName + separator;
#else
const char* home = getenv("HOME");
if (!home)
......@@ -346,15 +363,15 @@ std::string vtkInitializationHelper::GetUserSettingsDirectory()
return std::string();
}
std::string separator("/");
std::string fileName(home);
if (fileName[fileName.size()-1] != separator[0])
std::string directoryPath(home);
if (directoryPath[directoryPath.size()-1] != separator[0])
{
fileName.append(separator);
directoryPath.append(separator);
}
fileName += ".config" + separator + "ParaView" + separator;
directoryPath += ".config" + separator + applicationName + separator;
#endif
return fileName;
return directoryPath;
}
//----------------------------------------------------------------------------
......
......@@ -65,6 +65,12 @@ public:
static void SetLoadSettingsFilesDuringInitialization(bool);
static bool GetLoadSettingsFilesDuringInitialization();
// Description:
// Sets the name of the application. This is "ParaView" by default, but
// can be different for branded applications.
static void SetApplicationName(const std::string & appName);
static std::string GetApplicationName();
protected:
vtkInitializationHelper() {};
virtual ~vtkInitializationHelper() {};
......@@ -81,8 +87,12 @@ protected:
private:
vtkInitializationHelper(const vtkInitializationHelper&); // Not implemented
void operator=(const vtkInitializationHelper&); // Not implemented
static bool LoadSettingsFilesDuringInitialization;
static bool SaveUserSettingsFileDuringFinalization;
static std::string ApplicationName;
};
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment