mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-12-18 09:52:46 -05:00
Add support for portable config settings (#645)
* Add support for portable config settings * Use applicationDirPath instead of currentPath
This commit is contained in:
parent
b75b9fb7d6
commit
8d70167acf
1 changed files with 35 additions and 31 deletions
|
|
@ -60,6 +60,11 @@ Config::Config(const QString& fileName, QObject* parent)
|
||||||
Config::Config(QObject* parent)
|
Config::Config(QObject* parent)
|
||||||
: 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 userPath;
|
||||||
QString homePath = QDir::homePath();
|
QString homePath = QDir::homePath();
|
||||||
|
|
||||||
|
|
@ -69,11 +74,9 @@ Config::Config(QObject* parent)
|
||||||
if (env.isEmpty()) {
|
if (env.isEmpty()) {
|
||||||
userPath = homePath;
|
userPath = homePath;
|
||||||
userPath += "/.config";
|
userPath += "/.config";
|
||||||
}
|
} else if (env[0] == '/') {
|
||||||
else if (env[0] == '/') {
|
|
||||||
userPath = QFile::decodeName(env);
|
userPath = QFile::decodeName(env);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
userPath = homePath;
|
userPath = homePath;
|
||||||
userPath += '/';
|
userPath += '/';
|
||||||
userPath += QFile::decodeName(env);
|
userPath += QFile::decodeName(env);
|
||||||
|
|
@ -94,6 +97,7 @@ Config::Config(QObject* parent)
|
||||||
|
|
||||||
init(userPath);
|
init(userPath);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Config::~Config()
|
Config::~Config()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue