refactor: unify Coredir to SettingsPath
This commit is contained in:
parent
5355c9080b
commit
80f814a2da
5 changed files with 6 additions and 47 deletions
|
|
@ -28,7 +28,6 @@ add_library(${target} STATIC
|
||||||
Logger.h
|
Logger.h
|
||||||
messages.cpp
|
messages.cpp
|
||||||
messages.h
|
messages.h
|
||||||
paths.h
|
|
||||||
string_utils.h
|
string_utils.h
|
||||||
style_utils.h
|
style_utils.h
|
||||||
styles.h
|
styles.h
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
#include "common/Settings.h"
|
#include "common/Settings.h"
|
||||||
#include "gui/ipc/DaemonIpcClient.h"
|
#include "gui/ipc/DaemonIpcClient.h"
|
||||||
#include "gui/paths.h"
|
|
||||||
#include "tls/TlsUtility.h"
|
#include "tls/TlsUtility.h"
|
||||||
|
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
|
|
@ -133,7 +132,7 @@ bool CoreProcess::Deps::fileExists(const QString &path) const
|
||||||
|
|
||||||
QString CoreProcess::Deps::getProfileRoot() 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();
|
return Settings::value(Settings::Server::ExternalConfigFile).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto configDir = paths::configDir(true);
|
const auto configFilePath = QStringLiteral("%1/%2").arg(Settings::settingsPath(), kServerConfigFilename);
|
||||||
const auto configDirPath = configDir.absolutePath();
|
QFile configFile(configFilePath);
|
||||||
|
|
||||||
QFile configFile(configDirPath + "/" + kServerConfigFilename);
|
|
||||||
if (!configFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
if (!configFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||||
qFatal("failed to open core config file for write: %s", qPrintable(configFile.fileName()));
|
qFatal("failed to open core config file for write: %s", qPrintable(configFile.fileName()));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
#include "diagnostic.h"
|
#include "diagnostic.h"
|
||||||
|
|
||||||
|
#include "common/Settings.h"
|
||||||
#include "config/ConfigScopes.h"
|
#include "config/ConfigScopes.h"
|
||||||
#include "paths.h"
|
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#include "dotenv.h"
|
#include "dotenv.h"
|
||||||
|
|
||||||
#include "paths.h"
|
#include "common/Settings.h"
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
@ -49,7 +49,7 @@ void dotenv(const QString &filename)
|
||||||
// if nothing in current dir, then try the config dir.
|
// 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
|
// this makes it a bit easier for engineers in the field to have an easily
|
||||||
// predictable location for the .env file.
|
// predictable location for the .env file.
|
||||||
const auto orgDir = paths::configDir();
|
const auto orgDir = QDir(Settings::settingsPath());
|
||||||
|
|
||||||
filePath = orgDir.filePath(filename);
|
filePath = orgDir.filePath(filename);
|
||||||
if (!open(file, filePath)) {
|
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
|
|
||||||
Loading…
Reference in a new issue