refactor: unify Coredir to SettingsPath
This commit is contained in:
@ -28,7 +28,6 @@ add_library(${target} STATIC
|
||||
Logger.h
|
||||
messages.cpp
|
||||
messages.h
|
||||
paths.h
|
||||
string_utils.h
|
||||
style_utils.h
|
||||
styles.h
|
||||
|
||||
@ -8,7 +8,6 @@
|
||||
|
||||
#include "common/Settings.h"
|
||||
#include "gui/ipc/DaemonIpcClient.h"
|
||||
#include "gui/paths.h"
|
||||
#include "tls/TlsUtility.h"
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
@ -133,7 +132,7 @@ bool CoreProcess::Deps::fileExists(const QString &path) const
|
||||
|
||||
QString CoreProcess::Deps::getProfileRoot() const
|
||||
{
|
||||
return deskflow::gui::paths::configDir().absolutePath();
|
||||
return Settings::settingsPath();
|
||||
}
|
||||
|
||||
//
|
||||
@ -596,10 +595,8 @@ QString CoreProcess::persistServerConfig() const
|
||||
return Settings::value(Settings::Server::ExternalConfigFile).toString();
|
||||
}
|
||||
|
||||
const auto configDir = paths::configDir(true);
|
||||
const auto configDirPath = configDir.absolutePath();
|
||||
|
||||
QFile configFile(configDirPath + "/" + kServerConfigFilename);
|
||||
const auto configFilePath = QStringLiteral("%1/%2").arg(Settings::settingsPath(), kServerConfigFilename);
|
||||
QFile configFile(configFilePath);
|
||||
if (!configFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||
qFatal("failed to open core config file for write: %s", qPrintable(configFile.fileName()));
|
||||
}
|
||||
|
||||
@ -6,8 +6,8 @@
|
||||
|
||||
#include "diagnostic.h"
|
||||
|
||||
#include "common/Settings.h"
|
||||
#include "config/ConfigScopes.h"
|
||||
#include "paths.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
|
||||
#include "dotenv.h"
|
||||
|
||||
#include "paths.h"
|
||||
#include "common/Settings.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
@ -49,7 +49,7 @@ void dotenv(const QString &filename)
|
||||
// if nothing in current dir, then try the config dir.
|
||||
// this makes it a bit easier for engineers in the field to have an easily
|
||||
// predictable location for the .env file.
|
||||
const auto orgDir = paths::configDir();
|
||||
const auto orgDir = QDir(Settings::settingsPath());
|
||||
|
||||
filePath = orgDir.filePath(filename);
|
||||
if (!open(file, filePath)) {
|
||||
|
||||
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2024 Symless Ltd.
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/Settings.h"
|
||||
|
||||
#include <QDir>
|
||||
|
||||
namespace deskflow::gui::paths {
|
||||
|
||||
/**
|
||||
* @brief Gets the org config dir (parent of app config dir).
|
||||
*/
|
||||
inline QDir configDir(const bool persist = false)
|
||||
{
|
||||
const QDir configDir(Settings::settingsPath());
|
||||
|
||||
// HACK: since we have the org name set to the app name, the config dir is
|
||||
// confusing. make this simple by using the org dir instead.
|
||||
// use `filePath("..")` instead of `cdUp` to avoid the existence check.
|
||||
const QDir orgDir = configDir.filePath("..");
|
||||
|
||||
if (persist) {
|
||||
const auto orgDirPath = orgDir.absolutePath();
|
||||
if (!QDir().mkpath(orgDirPath)) {
|
||||
qFatal("failed to persist config dir: %s", qPrintable(orgDirPath));
|
||||
}
|
||||
}
|
||||
|
||||
return orgDir.absolutePath();
|
||||
}
|
||||
|
||||
} // namespace deskflow::gui::paths
|
||||
Reference in New Issue
Block a user