mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-17 19:54:33 -05:00
parent
2a62000b28
commit
1fd8923746
@ -19,6 +19,7 @@
|
|||||||
#include "NativeMessageInstaller.h"
|
#include "NativeMessageInstaller.h"
|
||||||
#include "BrowserSettings.h"
|
#include "BrowserSettings.h"
|
||||||
#include "config-keepassx.h"
|
#include "config-keepassx.h"
|
||||||
|
#include "core/Config.h"
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@ -209,8 +210,8 @@ QString NativeMessageInstaller::getNativeMessagePath(SupportedBrowsers browser)
|
|||||||
QString basePath;
|
QString basePath;
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
// If portable settings file exists save the JSON scripts to the application folder
|
// If portable settings file exists save the JSON scripts to the application folder
|
||||||
if (QFile::exists(QCoreApplication::applicationDirPath() + QStringLiteral("/keepassxc.ini"))) {
|
if (Config::isPortable()) {
|
||||||
basePath = QCoreApplication::applicationDirPath();
|
basePath = Config::portableConfigDir();
|
||||||
} else {
|
} else {
|
||||||
basePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
|
basePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
|
||||||
}
|
}
|
||||||
|
@ -512,20 +512,8 @@ void Config::init(const QString& configFileName, const QString& localConfigFileN
|
|||||||
QPair<QString, QString> Config::defaultConfigFiles()
|
QPair<QString, QString> Config::defaultConfigFiles()
|
||||||
{
|
{
|
||||||
// Check if we are running in portable mode, if so store the config files local to the app
|
// Check if we are running in portable mode, if so store the config files local to the app
|
||||||
#ifdef Q_OS_WIN
|
if (isPortable()) {
|
||||||
// Enable QFileInfo::isWritable check on Windows
|
return {portableConfigDir().append("/keepassxc.ini"), portableConfigDir().append("/keepassxc_local.ini")};
|
||||||
extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
|
|
||||||
qt_ntfs_permission_lookup++;
|
|
||||||
#endif
|
|
||||||
auto portablePath = QCoreApplication::applicationDirPath().append("/%1");
|
|
||||||
auto portableFile = portablePath.arg(".portable");
|
|
||||||
bool isPortable = QFile::exists(portableFile) && QFileInfo(portableFile).isWritable();
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
qt_ntfs_permission_lookup--;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (isPortable) {
|
|
||||||
return {portablePath.arg("config/keepassxc.ini"), portablePath.arg("config/keepassxc_local.ini")};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString configPath;
|
QString configPath;
|
||||||
@ -602,6 +590,27 @@ void Config::createTempFileInstance()
|
|||||||
tmpFile->setParent(m_instance);
|
tmpFile->setParent(m_instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Config::isPortable()
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
// Enable QFileInfo::isWritable check on Windows
|
||||||
|
extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
|
||||||
|
qt_ntfs_permission_lookup++;
|
||||||
|
#endif
|
||||||
|
auto portablePath = QCoreApplication::applicationDirPath().append("/%1");
|
||||||
|
auto portableFile = portablePath.arg(".portable");
|
||||||
|
auto isPortable = QFile::exists(portableFile) && QFileInfo(portableFile).isWritable();
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
qt_ntfs_permission_lookup--;
|
||||||
|
#endif
|
||||||
|
return isPortable;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Config::portableConfigDir()
|
||||||
|
{
|
||||||
|
return QCoreApplication::applicationDirPath().append("/config");
|
||||||
|
}
|
||||||
|
|
||||||
QList<Config::ShortcutEntry> Config::getShortcuts() const
|
QList<Config::ShortcutEntry> Config::getShortcuts() const
|
||||||
{
|
{
|
||||||
m_settings->beginGroup("Shortcuts");
|
m_settings->beginGroup("Shortcuts");
|
||||||
|
@ -225,6 +225,8 @@ public:
|
|||||||
static Config* instance();
|
static Config* instance();
|
||||||
static void createConfigFromFile(const QString& configFileName, const QString& localConfigFileName = {});
|
static void createConfigFromFile(const QString& configFileName, const QString& localConfigFileName = {});
|
||||||
static void createTempFileInstance();
|
static void createTempFileInstance();
|
||||||
|
static bool isPortable();
|
||||||
|
static QString portableConfigDir();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void changed(ConfigKey key);
|
void changed(ConfigKey key);
|
||||||
|
Loading…
Reference in New Issue
Block a user