comparison src/core/config.cc @ 250:c130f47f6f48

*: many many changes e.g. the search page is actually implemented now!
author Paper <paper@paper.us.eu.org>
date Sun, 04 Feb 2024 21:17:17 -0500
parents d030b30526d5
children 862d0d8619f6
comparison
equal deleted inserted replaced
249:6b2441c776dd 250:c130f47f6f48
20 #include <fstream> 20 #include <fstream>
21 #include <limits.h> 21 #include <limits.h>
22 22
23 #include <QFile> 23 #include <QFile>
24 #include <QTextStream> 24 #include <QTextStream>
25
26 #include <iostream>
25 27
26 /* I'll use an INI-based config file instead of using an 28 /* I'll use an INI-based config file instead of using an
27 * XML file like Taiga. 29 * XML file like Taiga.
28 * 30 *
29 * It technically isn't to spec, because I'm making these case-sensitive. 31 * It technically isn't to spec, because I'm making these case-sensitive.
87 enabled = INI::GetIniValue<bool>(ini, "Recognition/Browsers", player.name, true); 89 enabled = INI::GetIniValue<bool>(ini, "Recognition/Browsers", player.name, true);
88 break; 90 break;
89 } 91 }
90 } 92 }
91 93
94 locale.RefreshAvailableLocales();
92 locale.SetActiveLocale(QLocale(Strings::ToQString(INI::GetIniValue<std::string>(ini, "General", "Locale", "en_US")))); 95 locale.SetActiveLocale(QLocale(Strings::ToQString(INI::GetIniValue<std::string>(ini, "General", "Locale", "en_US"))));
93 96
94 theme.SetTheme(Translate::ToTheme(INI::GetIniValue<std::string>(ini, "Appearance", "Theme", "Default"))); 97 theme.SetTheme(Translate::ToTheme(INI::GetIniValue<std::string>(ini, "Appearance", "Theme", "Default")));
95 98
96 { 99 {
97 std::vector<std::string> v = Strings::Split(INI::GetIniValue<std::string>(ini, "Library", "Folders", ""), ";"); 100 std::vector<std::string> v = Strings::Split(INI::GetIniValue<std::string>(ini, "Library", "Folders", ""), ";");
98 library.paths = std::set(std::make_move_iterator(v.begin()), 101 for (const auto& s : v)
99 std::make_move_iterator(v.end())); 102 if (!library.paths.count(s))
103 library.paths.insert(s);
100 } 104 }
101 105
102 library.real_time_monitor = INI::GetIniValue<bool>(ini, "Library", "Real-time monitor", true); 106 library.real_time_monitor = INI::GetIniValue<bool>(ini, "Library", "Real-time monitor", true);
103 107
104 return 0; 108 return 0;
105 } 109 }
106 110
107 int Config::Save() const { 111 int Config::Save() {
108 std::filesystem::path cfg_path = Filesystem::GetConfigPath(); 112 std::filesystem::path cfg_path = Filesystem::GetConfigPath();
109 Filesystem::CreateDirectories(cfg_path); 113 Filesystem::CreateDirectories(cfg_path);
110 114
111 mINI::INIFile file(cfg_path.string()); 115 mINI::INIFile file(cfg_path.string());
112 mINI::INIStructure ini; 116 mINI::INIStructure ini;