Mercurial > minori
diff src/core/config.cc @ 369:47c9f8502269
*: clang-format all the things
I've edited the formatting a bit. Now pointer asterisks (and reference
ampersands) are on the variable instead of the type, as well as having
newlines for function braces (but nothing else)
author | Paper <paper@tflc.us> |
---|---|
date | Fri, 25 Jul 2025 10:16:02 -0400 |
parents | a7d4e5107531 |
children |
line wrap: on
line diff
--- a/src/core/config.cc Fri Jul 25 10:05:23 2025 -0400 +++ b/src/core/config.cc Fri Jul 25 10:16:02 2025 -0400 @@ -25,7 +25,8 @@ /* NOTE: This config file is prone to breakage, as Minori is alpha software and * as such nothing is constant. */ -int Config::Load() { +int Config::Load() +{ std::filesystem::path cfg_path = Filesystem::GetConfigPath(); std::ifstream ifs(cfg_path, std::ios_base::binary); @@ -36,7 +37,7 @@ try { data = toml::parse(ifs); - } catch (const std::exception& ex) { + } catch (const std::exception &ex) { std::cerr << "config: failed to parse toml with error " << ex.what() << std::endl; return 0; } @@ -45,26 +46,28 @@ locale.RefreshAvailableLocales(); locale.SetActiveLocale(QLocale(Strings::ToQString(toml::find_or(data, "General", "Locale", "en_US")))); - anime_list.score_format = Translate::ToScoreFormat(toml::find_or(data, "Anime List", "Score format", "100-point")); anime_list.language = Translate::ToLanguage(toml::find_or(data, "Anime List", "Title language", "Romaji")); anime_list.display_aired_episodes = toml::find_or(data, "Anime List", "Display only aired episodes", true); - anime_list.display_available_episodes = toml::find_or(data, "Anime List", "Display only available episodes in library", true); + anime_list.display_available_episodes = + toml::find_or(data, "Anime List", "Display only available episodes in library", true); anime_list.highlight_anime_if_available = toml::find_or(data, "Anime List", "Highlight anime if available", true); anime_list.highlighted_anime_above_others = - (anime_list.highlight_anime_if_available) - ? toml::find_or(data, "Anime List", "Display highlighted anime above others", false) - : false; + (anime_list.highlight_anime_if_available) + ? toml::find_or(data, "Anime List", "Display highlighted anime above others", false) + : false; auth.anilist.auth_token = toml::find_or(data, "Authentication/AniList", "Auth Token", ""); auth.anilist.user_id = toml::find_or(data, "Authentication/AniList", "User ID", 0); auth.kitsu.access_token = toml::find_or(data, "Authentication/Kitsu", "Access Token", ""); - auth.kitsu.access_token_expiration = toml::find_or(data, "Authentication/Kitsu", "Access Token Expiration", static_cast<Time::Timestamp>(0)); + auth.kitsu.access_token_expiration = + toml::find_or(data, "Authentication/Kitsu", "Access Token Expiration", static_cast<Time::Timestamp>(0)); auth.kitsu.refresh_token = toml::find_or(data, "Authentication/Kitsu", "Refresh Token", ""); auth.kitsu.user_id = toml::find_or(data, "Authentication/Kitsu", "User ID", ""); - torrents.feed_link = toml::find_or(data, "Torrents", "RSS feed", "https://www.tokyotosho.info/rss.php?filter=1,11&zwnj=0"); + torrents.feed_link = + toml::find_or(data, "Torrents", "RSS feed", "https://www.tokyotosho.info/rss.php?filter=1,11&zwnj=0"); recognition.detect_media_players = toml::find_or(data, "Recognition", "Detect media players", true); @@ -82,11 +85,11 @@ return false; recognition.players.reserve(players.size()); - for (const auto& player : players) + for (const auto &player : players) recognition.players.push_back({true, player}); } - for (auto& [enabled, player] : recognition.players) { + for (auto &[enabled, player] : recognition.players) { switch (player.type) { default: case animone::PlayerType::Default: @@ -98,13 +101,12 @@ } } - theme.SetTheme(Translate::ToTheme(toml::find_or(data, "Appearance", "Theme", "Default"))); if (data.contains("Library") && data["Library"].contains("Folders")) { - const toml::value& folders = toml::find(data, "Library", "Folders"); + const toml::value &folders = toml::find(data, "Library", "Folders"); std::vector<std::string> v = toml::get_or<std::vector<std::string>>(folders, {}); - for (const auto& s : v) + for (const auto &s : v) if (!library.paths.count(s)) library.paths.insert(s); } @@ -114,7 +116,8 @@ return 0; } -int Config::Save() { +int Config::Save() +{ std::filesystem::path cfg_path = Filesystem::GetConfigPath(); Filesystem::CreateDirectories(cfg_path); @@ -127,8 +130,9 @@ data["Library"]["Folders"] = library.paths; data["Library"]["Real-time monitor"] = library.real_time_monitor; - for (const auto& [enabled, player] : recognition.players) { - const std::string section = (player.type == animone::PlayerType::WebBrowser) ? "Recognition/Players" : "Recognition/Browsers"; + for (const auto &[enabled, player] : recognition.players) { + const std::string section = + (player.type == animone::PlayerType::WebBrowser) ? "Recognition/Players" : "Recognition/Browsers"; data[section][player.name] = enabled; }