Commit b3f9dce4 authored by Mathieu Westphal's avatar Mathieu Westphal

Fixing location of User-Settings.json and user servers.pvsc

1. Using pqSettings location to provide User Setting path in pqCoreUtilities::getParaViewUserDirectory()
2. Emulating QSettings use of XDG_CONFIG_HOME in vtkInitializationHelper::GetUserSettingsDirectory()
3. Use of pqCoreUtilities::getParaViewUserDirectory in pqServerConfigurationCollection::userServers()
parent c56525a7
......@@ -384,20 +384,35 @@ std::string vtkInitializationHelper::GetUserSettingsDirectory()
}
directoryPath += applicationName + separator;
#else
const char* home = getenv("HOME");
if (!home)
std::string directoryPath;
std::string separator("/");
// Emulating QSettings behavior.
const char* xdgConfigHome = getenv("XDG_CONFIG_HOME");
if (xdgConfigHome && strlen(xdgConfigHome) > 0)
{
return std::string();
directoryPath = xdgConfigHome;
if (directoryPath[directoryPath.size() - 1] != separator[0])
{
directoryPath += separator;
}
}
std::string separator("/");
std::string directoryPath(home);
if (directoryPath[directoryPath.size()-1] != separator[0])
else
{
directoryPath.append(separator);
const char* home = getenv("HOME");
if (!home)
{
return std::string();
}
directoryPath = home;
if (directoryPath[directoryPath.size() - 1] != separator[0])
{
directoryPath += separator;
}
directoryPath += ".config/";
}
directoryPath += ".config" + separator + organizationName + separator;
directoryPath += organizationName + separator;
#endif
return directoryPath;
}
......
......@@ -77,18 +77,8 @@ QWidget* pqCoreUtilities::findMainWindow()
//-----------------------------------------------------------------------------
QString pqCoreUtilities::getParaViewUserDirectory()
{
QString settingsRoot;
#if defined(Q_OS_WIN)
settingsRoot = QString::fromLocal8Bit(getenv("APPDATA"));
#else
settingsRoot = QString::fromLocal8Bit(getenv("HOME")) +
QDir::separator() + QString::fromLocal8Bit(".config");
#endif
QString settingsPath = QString("%2%1%3");
settingsPath = settingsPath.arg(QDir::separator());
settingsPath = settingsPath.arg(settingsRoot);
settingsPath = settingsPath.arg(QApplication::organizationName());
return settingsPath;
pqSettings* settings = pqApplicationCore::instance()->settings();
return QFileInfo(settings->fileName()).path();
}
//-----------------------------------------------------------------------------
......
......@@ -31,6 +31,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
========================================================================*/
#include "pqServerConfigurationCollection.h"
#include "pqCoreUtilities.h"
#include "pqOptions.h"
#include "pqServerConfiguration.h"
#include "pqServerResource.h"
......@@ -50,19 +51,7 @@ namespace
// get path to user-servers
static QString userServers()
{
QString settingsRoot;
#if defined(Q_OS_WIN)
settingsRoot = QString::fromLocal8Bit(getenv("APPDATA"));
#else
settingsRoot = QString::fromLocal8Bit(getenv("HOME")) +
QDir::separator() + QString::fromLocal8Bit(".config");
#endif
QString settingsPath = QString("%2%1%3%1%4");
settingsPath = settingsPath.arg(QDir::separator());
settingsPath = settingsPath.arg(settingsRoot);
settingsPath = settingsPath.arg(QApplication::organizationName());
settingsPath = settingsPath.arg("servers.pvsc");
return settingsPath;
return pqCoreUtilities::getParaViewUserDirectory() + "/servers.pvsc";
}
// get path to shared system servers.
......
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