GlobalSettingStation.h
#ifndef GPGFRONTEND_GLOBALSETTINGSTATION_H
#define GPGFRONTEND_GLOBALSETTINGSTATION_H
#include "GpgFrontendBuildInstallInfo.h"
#include "core/GpgFrontendCore.h"
#include "core/GpgFunctionObject.h"
namespace GpgFrontend {
class GPGFRONTEND_CORE_EXPORT GlobalSettingStation
: public SingletonFunctionObject<GlobalSettingStation> {
public:
explicit GlobalSettingStation(
int channel = SingletonFunctionObject::GetDefaultChannel()) noexcept;
~GlobalSettingStation() noexcept override;
libconfig::Setting &GetUISettings() noexcept { return ui_cfg_.getRoot(); }
[[nodiscard]] std::filesystem::path GetAppDir() const { return app_path_; }
[[nodiscard]] std::filesystem::path GetAppDataPath() const {
return app_data_path_;
}
[[nodiscard]] std::filesystem::path GetLogDir() const {
return app_log_path_;
}
[[nodiscard]] std::filesystem::path GetStandaloneDatabaseDir() const {
auto db_path = app_configure_path_ / "db";
if (!std::filesystem::exists(db_path)) {
std::filesystem::create_directory(db_path);
}
return db_path;
}
[[nodiscard]] std::filesystem::path GetAppConfigPath() const {
return app_configure_path_;
}
[[nodiscard]] std::filesystem::path GetStandaloneGpgBinDir() const {
return app_resource_path_ / "gpg1.4" / "gpg";
}
[[nodiscard]] std::filesystem::path GetLocaleDir() const {
return app_locale_path_;
}
[[nodiscard]] std::filesystem::path GetResourceDir() const {
return app_resource_path_;
}
[[nodiscard]] std::filesystem::path GetCertsDir() const {
return app_resource_path_ / "certs";
}
void SyncSettings() noexcept;
private:
std::filesystem::path app_path_ = QCoreApplication::applicationDirPath()
.toStdString();
std::filesystem::path app_data_path_ =
QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)
.toStdString();
std::filesystem::path app_log_path_ =
app_data_path_ / "logs";
std::filesystem::path app_data_objs_path_ =
app_data_path_ / "objs";
#ifdef LINUX_INSTALL_BUILD
std::filesystem::path app_resource_path_ =
std::filesystem::path(APP_LOCALSTATE_PATH) /
"gpgfrontend";
#else
std::filesystem::path app_resource_path_ =
RESOURCE_DIR_BOOST_PATH(app_path_);
#endif
#ifdef LINUX_INSTALL_BUILD
std::filesystem::path app_locale_path_ =
std::string(APP_LOCALE_PATH);
#else
std::filesystem::path app_locale_path_ =
app_resource_path_ / "locales";
#endif
std::filesystem::path app_configure_path_ =
QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)
.toStdString();
std::filesystem::path ui_config_dir_path_ =
app_configure_path_ /
"UserInterface";
std::filesystem::path ui_config_path_ =
ui_config_dir_path_ / "ui.cfg";
libconfig::Config ui_cfg_;
void init_app_secure_key();
};
} // namespace GpgFrontend
#endif // GPGFRONTEND_GLOBALSETTINGSTATION_H
GpgFrontend::SingletonFunctionObject< GlobalSettingStation >
GpgFrontend::GlobalSettingStation::SyncSettings
void SyncSettings() noexcept
sync the settings to the file
Definition: GlobalSettingStation.cpp:33
GpgFrontend
Definition: CoreCommonUtil.cpp:29
GpgFrontend::GlobalSettingStation::app_log_path_
std::filesystem::path app_log_path_
Program Data Location.
Definition: GlobalSettingStation.h:150
GpgFrontend::GlobalSettingStation::GetUISettings
libconfig::Setting & GetUISettings() noexcept
Definition: GlobalSettingStation.h:63
GpgFrontend::GlobalSettingStation::ui_config_path_
std::filesystem::path ui_config_path_
UI Configure File Location.
Definition: GlobalSettingStation.h:178
GpgFrontend::GlobalSettingStation::GetCertsDir
std::filesystem::path GetCertsDir() const
Get the Certs Dir object.
Definition: GlobalSettingStation.h:134
GpgFrontend::GlobalSettingStation::GetLocaleDir
std::filesystem::path GetLocaleDir() const
Get the Locale Dir object.
Definition: GlobalSettingStation.h:116
GpgFrontend::GlobalSettingStation::GetResourceDir
std::filesystem::path GetResourceDir() const
Get the Resource Dir object.
Definition: GlobalSettingStation.h:125
GpgFrontend::GlobalSettingStation::GetStandaloneDatabaseDir
std::filesystem::path GetStandaloneDatabaseDir() const
Get the Standalone Database Dir object.
Definition: GlobalSettingStation.h:90
GpgFrontend::GlobalSettingStation::app_data_path_
std::filesystem::path app_data_path_
Program Data Location.
Definition: GlobalSettingStation.h:147
GpgFrontend::GlobalSettingStation::ui_config_dir_path_
std::filesystem::path ui_config_dir_path_
Configure File Directory Location.
Definition: GlobalSettingStation.h:175
GpgFrontend::GlobalSettingStation::app_path_
std::filesystem::path app_path_
Program Location.
Definition: GlobalSettingStation.h:145
GpgFrontend::GlobalSettingStation::app_locale_path_
std::filesystem::path app_locale_path_
Program Data Location.
Definition: GlobalSettingStation.h:168
GpgFrontend::GlobalSettingStation
Definition: GlobalSettingStation.h:42
GpgFrontend::GlobalSettingStation::~GlobalSettingStation
~GlobalSettingStation() noexcept override
Destroy the Global Setting Station object.
GpgFrontend::GlobalSettingStation::GlobalSettingStation
GlobalSettingStation(int channel=SingletonFunctionObject::GetDefaultChannel()) noexcept
Construct a new Global Setting Station object.
Definition: GlobalSettingStation.cpp:46
GpgFrontend::SingletonFunctionObject::GetDefaultChannel
static int GetDefaultChannel()
Get the Default Channel object.
Definition: GpgFunctionObject.h:232
GpgFrontend::GlobalSettingStation::app_configure_path_
std::filesystem::path app_configure_path_
Program Configure Location.
Definition: GlobalSettingStation.h:172
GpgFrontend::GlobalSettingStation::GetStandaloneGpgBinDir
std::filesystem::path GetStandaloneGpgBinDir() const
Get the Standalone Gpg Bin Dir object.
Definition: GlobalSettingStation.h:107
GpgFrontend::GlobalSettingStation::GetLogDir
std::filesystem::path GetLogDir() const
Get the Log Dir object.
Definition: GlobalSettingStation.h:81
GpgFrontend::GlobalSettingStation::ui_cfg_
libconfig::Config ui_cfg_
UI Configure File.
Definition: GlobalSettingStation.h:181
GpgFrontend::GlobalSettingStation::GetAppDir
std::filesystem::path GetAppDir() const
Get the App Dir object.
Definition: GlobalSettingStation.h:70