#include "config.hpp" #include #include #include namespace fs = std::filesystem; KotoConfig::KotoConfig() { // Define our application's config location auto configDir = QDir(QStandardPaths::writableLocation(QStandardPaths::StandardLocation::AppConfigLocation)); auto configDirPath = configDir.absolutePath(); fs::path filePath {}; auto configPathStd = configDirPath.toStdString(); filePath /= configPathStd; filePath /= "config.toml"; auto data = toml::parse(filePath); std::optional ui_prefs; if (data.contains("preferences.ui")) { auto ui_prefs_at = data.at("preferences.ui"); if (ui_prefs_at.is_table()) ui_prefs = ui_prefs_at.as_table(); } auto prefs = KotoUiPreferences(ui_prefs); this->i_uiPreferences = &prefs; this->i_libraries = {}; for (const auto& lib_value : toml::find>(data, "libraries")) { auto lib = KotoLibraryConfig(lib_value); this->i_libraries.push_back(lib); } } KotoConfig::~KotoConfig() {} KotoUiPreferences* KotoConfig::getUiPreferences() { return this->i_uiPreferences; } std::vector KotoConfig::getLibraries() { return this->i_libraries; }