Add support for portable config settings (#645)

* Add support for portable config settings

* Use applicationDirPath instead of currentPath
This commit is contained in:
Jonathan White 2017-06-19 10:49:03 -04:00 committed by louib
parent b75b9fb7d6
commit 8d70167acf

View File

@ -60,6 +60,11 @@ Config::Config(const QString& fileName, QObject* parent)
Config::Config(QObject* parent)
: QObject(parent)
{
// Check if portable config is present. If not, find it in user's directory
QString portablePath = QCoreApplication::applicationDirPath() + "/keepassxc.ini";
if (QFile::exists(portablePath)) {
init(portablePath);
} else {
QString userPath;
QString homePath = QDir::homePath();
@ -69,11 +74,9 @@ Config::Config(QObject* parent)
if (env.isEmpty()) {
userPath = homePath;
userPath += "/.config";
}
else if (env[0] == '/') {
} else if (env[0] == '/') {
userPath = QFile::decodeName(env);
}
else {
} else {
userPath = homePath;
userPath += '/';
userPath += QFile::decodeName(env);
@ -94,6 +97,7 @@ Config::Config(QObject* parent)
init(userPath);
}
}
Config::~Config()
{