From 36509c76e6bd2351b2158f5fa7c9efad7caba89b Mon Sep 17 00:00:00 2001 From: saturneric Date: Thu, 4 Jan 2024 21:17:27 +0800 Subject: feat: switch to portable mode by adding a txt file under bin path --- src/core/function/GlobalSettingStation.cpp | 41 +++++++++++++++++------------- 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'src/core/function/GlobalSettingStation.cpp') diff --git a/src/core/function/GlobalSettingStation.cpp b/src/core/function/GlobalSettingStation.cpp index be500907..e3970a6a 100644 --- a/src/core/function/GlobalSettingStation.cpp +++ b/src/core/function/GlobalSettingStation.cpp @@ -44,6 +44,21 @@ class GlobalSettingStation::Impl { */ explicit Impl() noexcept { SPDLOG_INFO("app path: {}", app_path_.u8string()); + auto protable_file_path = app_path_ / "PORTABLE.txt"; + if (std::filesystem::exists(protable_file_path)) { + SPDLOG_INFO( + "dectected protable mode, reconfiguring config and data path..."); + + app_configure_path_ = app_path_.parent_path(); + config_dir_path_ = app_configure_path_ / "conf"; + main_config_path_ = config_dir_path_ / "main.cfg"; + module_config_path_ = config_dir_path_ / "module.cfg"; + + app_data_path_ = app_path_.parent_path(); + app_log_path_ = app_data_path_ / "logs"; + app_data_objs_path_ = app_data_path_ / "data_objs"; + } + SPDLOG_INFO("app configure path: {}", app_configure_path_.u8string()); SPDLOG_INFO("app data path: {}", app_data_path_.u8string()); SPDLOG_INFO("app log path: {}", app_log_path_.u8string()); @@ -162,15 +177,6 @@ class GlobalSettingStation::Impl { return app_configure_path_; } - /** - * @brief Get the Standalone Gpg Bin Dir object - * - * @return std::filesystem::path - */ - [[nodiscard]] auto GetStandaloneGpgBinDir() const -> std::filesystem::path { - return app_resource_path_ / "gpg1.4" / "gpg"; - } - /** * @brief Get the Locale Dir object * @@ -220,8 +226,10 @@ class GlobalSettingStation::Impl { .parent_path(); std::filesystem::path app_data_path_ = - QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) - .toStdString(); ///< Program Data Location + std::filesystem::path{ + QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + .toStdString()} / + "GpgFrontend"; ///< Program Data Location std::filesystem::path app_log_path_ = app_data_path_ / "logs"; ///< Program Data Location @@ -247,8 +255,10 @@ class GlobalSettingStation::Impl { #endif std::filesystem::path app_configure_path_ = - QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) - .toStdString(); ///< Program Configure Location + std::filesystem::path{ + QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + .toStdString()} / + "GpgFrontend"; ///< Program Configure Location std::filesystem::path config_dir_path_ = app_configure_path_ / "conf"; ///< Configure File Directory Location std::filesystem::path main_config_path_ = @@ -299,11 +309,6 @@ auto GlobalSettingStation::GetAppConfigPath() const -> std::filesystem::path { return p_->GetAppConfigPath(); } -auto GlobalSettingStation::GetStandaloneGpgBinDir() const - -> std::filesystem::path { - return p_->GetStandaloneGpgBinDir(); -} - auto GlobalSettingStation::GetLocaleDir() const -> std::filesystem::path { return p_->GetLocaleDir(); } -- cgit v1.2.3