annotate src/core/config.cc @ 310:a4257370de16

dep/animone: prepare for v1.0 release; it should be ready by now
author Paper <paper@paper.us.eu.org>
date Tue, 11 Jun 2024 04:38:51 -0400
parents 53e3c015a973
children b1f4d1867ab1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
1 /**
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
2 * config.cpp:
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
3 * parses the config... lol
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
4 **/
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
5 #include "core/config.h"
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
6 #include "core/anime.h"
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
7 #include "core/filesystem.h"
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents: 101
diff changeset
8 #include "core/ini.h"
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
9 #include "core/json.h"
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
10 #include "core/strings.h"
90
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
11 #include "gui/translate/anime.h"
c4bb49c2f6eb config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
12 #include "gui/translate/config.h"
147
6fdf0632c003 track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
13
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
14 #include "animone/player.h"
147
6fdf0632c003 track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
15
101
c537996cf67b *: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
16 #include <algorithm>
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
17 #include <cstdlib>
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
18 #include <cstring>
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
19 #include <filesystem>
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
20 #include <fstream>
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
21 #include <limits.h>
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
22
147
6fdf0632c003 track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
23 #include <QFile>
6fdf0632c003 track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
24 #include <QTextStream>
6fdf0632c003 track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
25
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 228
diff changeset
26 #include <iostream>
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 228
diff changeset
27
120
275da698697d config: template-ify INI
Paper <mrpapersonic@gmail.com>
parents: 118
diff changeset
28 /* I'll use an INI-based config file instead of using an
221
53211cb1e7f5 library: add initial library stuff
Paper <paper@paper.us.eu.org>
parents: 198
diff changeset
29 * XML file like Taiga.
224
7ca56c4ac0bc about: don't abuse QCoreApplication:tr
Paper <mrpapersonic@gmail.com>
parents: 223
diff changeset
30 *
7ca56c4ac0bc about: don't abuse QCoreApplication:tr
Paper <mrpapersonic@gmail.com>
parents: 223
diff changeset
31 * It technically isn't to spec, because I'm making these case-sensitive.
7ca56c4ac0bc about: don't abuse QCoreApplication:tr
Paper <mrpapersonic@gmail.com>
parents: 223
diff changeset
32 * Boohoo.
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
33 */
120
275da698697d config: template-ify INI
Paper <mrpapersonic@gmail.com>
parents: 118
diff changeset
34
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
35 int Config::Load() {
135
0a458cb26ff4 filesystem: move to using std::filesystem after C++17 switch
Paper <mrpapersonic@gmail.com>
parents: 120
diff changeset
36 std::filesystem::path cfg_path = Filesystem::GetConfigPath();
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents: 101
diff changeset
37
228
d030b30526d5 config: remove unused username parameter from anilist auth
Paper <mrpapersonic@gmail.com>
parents: 226
diff changeset
38 mINI::INIFile file(cfg_path.u8string());
101
c537996cf67b *: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
39 mINI::INIStructure ini;
c537996cf67b *: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
40 file.read(ini);
c537996cf67b *: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
41
276
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
42 service = Translate::ToService(INI::GetIniString(ini, "General", "Service", "None"));
120
275da698697d config: template-ify INI
Paper <mrpapersonic@gmail.com>
parents: 118
diff changeset
43
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
44 anime_list.score_format =
276
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
45 Translate::ToScoreFormat(INI::GetIniString(ini, "Anime List", "Score format", "POINT_100"));
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
46 anime_list.language =
276
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
47 Translate::ToLanguage(INI::GetIniString(ini, "Anime List", "Title language", "Romaji"));
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
48 anime_list.display_aired_episodes = INI::GetIniBool(ini, "Anime List", "Display only aired episodes", true);
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
49 anime_list.display_available_episodes =
276
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
50 INI::GetIniBool(ini, "Anime List", "Display only available episodes in library", true);
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
51 anime_list.highlight_anime_if_available =
276
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
52 INI::GetIniBool(ini, "Anime List", "Highlight anime if available", true);
183
01d259b9c89f pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents: 151
diff changeset
53
01d259b9c89f pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents: 151
diff changeset
54 if (anime_list.highlight_anime_if_available) // sanity check
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
55 anime_list.highlighted_anime_above_others =
276
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
56 INI::GetIniBool(ini, "Anime List", "Display highlighted anime above others", false);
183
01d259b9c89f pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents: 151
diff changeset
57 else
01d259b9c89f pages/torrents.cc: parse feed descriptions separately
Paper <mrpapersonic@gmail.com>
parents: 151
diff changeset
58 anime_list.highlighted_anime_above_others = false;
116
254b1d2b7096 settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
59
276
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
60 auth.anilist.auth_token = INI::GetIniString(ini, "Authentication/AniList", "Auth Token", "");
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
61 auth.anilist.user_id = INI::GetIniInteger<int>(ini, "Authentication/AniList", "User ID", 0);
120
275da698697d config: template-ify INI
Paper <mrpapersonic@gmail.com>
parents: 118
diff changeset
62
276
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
63 torrents.feed_link = INI::GetIniString(ini, "Torrents", "RSS feed",
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
64 "https://www.tokyotosho.info/rss.php?filter=1,11&zwnj=0");
116
254b1d2b7096 settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
65
276
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
66 recognition.detect_media_players = INI::GetIniBool(ini, "Recognition", "Detect media players", true);
135
0a458cb26ff4 filesystem: move to using std::filesystem after C++17 switch
Paper <mrpapersonic@gmail.com>
parents: 120
diff changeset
67
147
6fdf0632c003 track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
68 /* lots of dumb logic to import the player data */
6fdf0632c003 track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
69 {
6fdf0632c003 track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
70 /* load the player data */
6fdf0632c003 track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
71 QFile f(":/players.anisthesia");
6fdf0632c003 track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
72 if (!f.exists())
6fdf0632c003 track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
73 return false;
6fdf0632c003 track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
74
6fdf0632c003 track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
75 f.open(QFile::ReadOnly | QFile::Text);
6fdf0632c003 track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
76 QTextStream ts(&f);
6fdf0632c003 track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
77
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
78 std::vector<animone::Player> players;
147
6fdf0632c003 track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
79
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
80 if (!animone::ParsePlayersData(Strings::ToUtf8String(ts.readAll()), players))
147
6fdf0632c003 track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
81 return false;
6fdf0632c003 track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
82
6fdf0632c003 track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
83 recognition.players.reserve(players.size());
185
62e336597bb7 anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents: 183
diff changeset
84 for (const auto& player : players)
151
54744a48a7d7 last commit part 2: struct init with {} is valid syntax, actually
Paper <mrpapersonic@gmail.com>
parents: 150
diff changeset
85 recognition.players.push_back({true, player});
147
6fdf0632c003 track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
86 }
6fdf0632c003 track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
87
149
e41505d24733 players: filter out web browsers, they aren't even supported in animia yet
Paper <mrpapersonic@gmail.com>
parents: 147
diff changeset
88 for (auto& [enabled, player] : recognition.players) {
e41505d24733 players: filter out web browsers, they aren't even supported in animia yet
Paper <mrpapersonic@gmail.com>
parents: 147
diff changeset
89 switch (player.type) {
e41505d24733 players: filter out web browsers, they aren't even supported in animia yet
Paper <mrpapersonic@gmail.com>
parents: 147
diff changeset
90 default:
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
91 case animone::PlayerType::Default:
276
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
92 enabled = INI::GetIniBool(ini, "Recognition/Players", player.name, true);
149
e41505d24733 players: filter out web browsers, they aren't even supported in animia yet
Paper <mrpapersonic@gmail.com>
parents: 147
diff changeset
93 break;
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
94 case animone::PlayerType::WebBrowser:
276
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
95 enabled = INI::GetIniBool(ini, "Recognition/Browsers", player.name, true);
149
e41505d24733 players: filter out web browsers, they aren't even supported in animia yet
Paper <mrpapersonic@gmail.com>
parents: 147
diff changeset
96 break;
e41505d24733 players: filter out web browsers, they aren't even supported in animia yet
Paper <mrpapersonic@gmail.com>
parents: 147
diff changeset
97 }
e41505d24733 players: filter out web browsers, they aren't even supported in animia yet
Paper <mrpapersonic@gmail.com>
parents: 147
diff changeset
98 }
147
6fdf0632c003 track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
99
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 228
diff changeset
100 locale.RefreshAvailableLocales();
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
101 locale.SetActiveLocale(
276
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
102 QLocale(Strings::ToQString(INI::GetIniString(ini, "General", "Locale", "en_US"))));
116
254b1d2b7096 settings: add torrents page, make rss feed configurable
Paper <mrpapersonic@gmail.com>
parents: 108
diff changeset
103
276
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
104 theme.SetTheme(Translate::ToTheme(INI::GetIniString(ini, "Appearance", "Theme", "Default")));
101
c537996cf67b *: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
105
226
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents: 224
diff changeset
106 {
276
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
107 std::vector<std::string> v = Strings::Split(INI::GetIniString(ini, "Library", "Folders", ""), ";");
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 228
diff changeset
108 for (const auto& s : v)
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 228
diff changeset
109 if (!library.paths.count(s))
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 228
diff changeset
110 library.paths.insert(s);
226
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents: 224
diff changeset
111 }
f784b5b1914c settings: add library page
Paper <mrpapersonic@gmail.com>
parents: 224
diff changeset
112
276
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
113 library.real_time_monitor = INI::GetIniBool(ini, "Library", "Real-time monitor", true);
223
84e0a3c4737a library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents: 221
diff changeset
114
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
115 return 0;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
116 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
117
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 228
diff changeset
118 int Config::Save() {
135
0a458cb26ff4 filesystem: move to using std::filesystem after C++17 switch
Paper <mrpapersonic@gmail.com>
parents: 120
diff changeset
119 std::filesystem::path cfg_path = Filesystem::GetConfigPath();
0a458cb26ff4 filesystem: move to using std::filesystem after C++17 switch
Paper <mrpapersonic@gmail.com>
parents: 120
diff changeset
120 Filesystem::CreateDirectories(cfg_path);
101
c537996cf67b *: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
121
135
0a458cb26ff4 filesystem: move to using std::filesystem after C++17 switch
Paper <mrpapersonic@gmail.com>
parents: 120
diff changeset
122 mINI::INIFile file(cfg_path.string());
101
c537996cf67b *: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
123 mINI::INIStructure ini;
c537996cf67b *: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
124
276
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
125 ini["General"]["Service"] = Translate::ToString(service);
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
126 ini["General"]["Locale"] = Strings::ToUtf8String(locale.GetLocale().name());
120
275da698697d config: template-ify INI
Paper <mrpapersonic@gmail.com>
parents: 118
diff changeset
127
276
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
128 ini["Anime List"]["Score format"] = Translate::ToString(anime_list.score_format);
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
129 ini["Anime List"]["Title language"] = Translate::ToString(anime_list.language);
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
130 ini["Anime List"]["Display only aired episodes"] = Strings::ToUtf8String(anime_list.display_aired_episodes);
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
131 ini["Anime List"]["Display only available episodes in library"] = Strings::ToUtf8String(anime_list.display_available_episodes);
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
132 ini["Anime List"]["Highlight anime if available"] = Strings::ToUtf8String(anime_list.highlight_anime_if_available);
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
133 ini["Anime List"]["Display highlighted anime above others"] = Strings::ToUtf8String(anime_list.highlighted_anime_above_others);
120
275da698697d config: template-ify INI
Paper <mrpapersonic@gmail.com>
parents: 118
diff changeset
134
276
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
135 ini["Authentication/AniList"]["Auth Token"] = auth.anilist.auth_token;
286
53e3c015a973 anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents: 276
diff changeset
136 ini["Authentication/AniList"]["User ID"] = Strings::ToUtf8String(auth.anilist.user_id);
120
275da698697d config: template-ify INI
Paper <mrpapersonic@gmail.com>
parents: 118
diff changeset
137
276
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
138 ini["Appearance"]["Theme"] = Translate::ToString(theme.GetTheme());
120
275da698697d config: template-ify INI
Paper <mrpapersonic@gmail.com>
parents: 118
diff changeset
139
276
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
140 ini["Torrents"]["RSS feed"] = torrents.feed_link;
120
275da698697d config: template-ify INI
Paper <mrpapersonic@gmail.com>
parents: 118
diff changeset
141
276
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
142 ini["Recognition"]["Detect media players"] = Strings::ToUtf8String(recognition.detect_media_players);
101
c537996cf67b *: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
143
149
e41505d24733 players: filter out web browsers, they aren't even supported in animia yet
Paper <mrpapersonic@gmail.com>
parents: 147
diff changeset
144 for (const auto& [enabled, player] : recognition.players) {
276
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
145 const std::string section = (player.type == animone::PlayerType::WebBrowser) ? "Recognition/Players" : "Recognition/Browsers";
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
146 ini[section][player.name] = Strings::ToUtf8String(enabled);
149
e41505d24733 players: filter out web browsers, they aren't even supported in animia yet
Paper <mrpapersonic@gmail.com>
parents: 147
diff changeset
147 }
147
6fdf0632c003 track: use a bit of a more sane way to manage recognition
Paper <mrpapersonic@gmail.com>
parents: 135
diff changeset
148
276
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
149 ini["Library"]["Folders"] = Strings::Implode(library.paths, ";");
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
150 ini["Library"]["Real-time monitor"] = Strings::ToUtf8String(library.real_time_monitor);
223
84e0a3c4737a library: implement menu bar buttons
Paper <mrpapersonic@gmail.com>
parents: 221
diff changeset
151
102
b315f3759c56 *: big patch
Paper <mrpapersonic@gmail.com>
parents: 101
diff changeset
152 file.write(ini);
101
c537996cf67b *: multitude of config changes
Paper <mrpapersonic@gmail.com>
parents: 90
diff changeset
153
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
154 return 0;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
155 }