Mercurial > minori
comparison src/core/config.cc @ 231:69f4768a820c
chore: merge divergent branches
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Sat, 13 Jan 2024 09:43:41 -0500 |
parents | d030b30526d5 |
children | c130f47f6f48 |
comparison
equal
deleted
inserted
replaced
230:2f5a9247e501 | 231:69f4768a820c |
---|---|
23 #include <QFile> | 23 #include <QFile> |
24 #include <QTextStream> | 24 #include <QTextStream> |
25 | 25 |
26 /* I'll use an INI-based config file instead of using an | 26 /* I'll use an INI-based config file instead of using an |
27 * XML file like Taiga. | 27 * XML file like Taiga. |
28 * | |
29 * It technically isn't to spec, because I'm making these case-sensitive. | |
30 * Boohoo. | |
28 */ | 31 */ |
29 | 32 |
30 int Config::Load() { | 33 int Config::Load() { |
31 std::filesystem::path cfg_path = Filesystem::GetConfigPath(); | 34 std::filesystem::path cfg_path = Filesystem::GetConfigPath(); |
32 | 35 |
33 mINI::INIFile file(cfg_path.string()); | 36 mINI::INIFile file(cfg_path.u8string()); |
34 mINI::INIStructure ini; | 37 mINI::INIStructure ini; |
35 file.read(ini); | 38 file.read(ini); |
36 | 39 |
37 service = Translate::ToService(INI::GetIniValue<std::string>(ini, "General", "Service", "None")); | 40 service = Translate::ToService(INI::GetIniValue<std::string>(ini, "General", "Service", "None")); |
38 | 41 |
88 | 91 |
89 locale.SetActiveLocale(QLocale(Strings::ToQString(INI::GetIniValue<std::string>(ini, "General", "Locale", "en_US")))); | 92 locale.SetActiveLocale(QLocale(Strings::ToQString(INI::GetIniValue<std::string>(ini, "General", "Locale", "en_US")))); |
90 | 93 |
91 theme.SetTheme(Translate::ToTheme(INI::GetIniValue<std::string>(ini, "Appearance", "Theme", "Default"))); | 94 theme.SetTheme(Translate::ToTheme(INI::GetIniValue<std::string>(ini, "Appearance", "Theme", "Default"))); |
92 | 95 |
96 { | |
97 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()), | |
99 std::make_move_iterator(v.end())); | |
100 } | |
101 | |
102 library.real_time_monitor = INI::GetIniValue<bool>(ini, "Library", "Real-time monitor", true); | |
103 | |
93 return 0; | 104 return 0; |
94 } | 105 } |
95 | 106 |
96 int Config::Save() const { | 107 int Config::Save() const { |
97 std::filesystem::path cfg_path = Filesystem::GetConfigPath(); | 108 std::filesystem::path cfg_path = Filesystem::GetConfigPath(); |
129 INI::SetIniValue(ini, "Recognition/Browsers", player.name, enabled); | 140 INI::SetIniValue(ini, "Recognition/Browsers", player.name, enabled); |
130 break; | 141 break; |
131 } | 142 } |
132 } | 143 } |
133 | 144 |
145 INI::SetIniValue(ini, "Library", "Folders", Strings::Implode(library.paths, ";")); | |
146 INI::SetIniValue(ini, "Library", "Real-time monitor", library.real_time_monitor); | |
147 | |
134 file.write(ini); | 148 file.write(ini); |
135 | 149 |
136 return 0; | 150 return 0; |
137 } | 151 } |