diff --git a/src/lib/gui/CMakeLists.txt b/src/lib/gui/CMakeLists.txt index 3b7f30779..a489026b8 100644 --- a/src/lib/gui/CMakeLists.txt +++ b/src/lib/gui/CMakeLists.txt @@ -28,7 +28,6 @@ add_library(${target} STATIC Logger.h messages.cpp messages.h - paths.h string_utils.h style_utils.h styles.h diff --git a/src/lib/gui/core/CoreProcess.cpp b/src/lib/gui/core/CoreProcess.cpp index 335869516..8c339650e 100644 --- a/src/lib/gui/core/CoreProcess.cpp +++ b/src/lib/gui/core/CoreProcess.cpp @@ -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())); } diff --git a/src/lib/gui/diagnostic.cpp b/src/lib/gui/diagnostic.cpp index 577f22aa9..a6f4771a0 100644 --- a/src/lib/gui/diagnostic.cpp +++ b/src/lib/gui/diagnostic.cpp @@ -6,8 +6,8 @@ #include "diagnostic.h" +#include "common/Settings.h" #include "config/ConfigScopes.h" -#include "paths.h" #include #include diff --git a/src/lib/gui/dotenv.cpp b/src/lib/gui/dotenv.cpp index 66411f91b..ea63a7764 100644 --- a/src/lib/gui/dotenv.cpp +++ b/src/lib/gui/dotenv.cpp @@ -6,7 +6,7 @@ #include "dotenv.h" -#include "paths.h" +#include "common/Settings.h" #include #include @@ -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)) { diff --git a/src/lib/gui/paths.h b/src/lib/gui/paths.h deleted file mode 100644 index 9fbaa2814..000000000 --- a/src/lib/gui/paths.h +++ /dev/null @@ -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 - -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