annotate src/gui/translate/config.cc @ 187:9613d72b097e

*: multiple performance improvements like marking `static const` when it makes sense... date: change old stupid heap-based method to a structure which should make copying the thing actually make a copy. also many performance-based changes, like removing the std::tie dependency and forward-declaring nlohmann json *: replace every instance of QString::fromUtf8 to Strings::ToQString. the main difference is that our function will always convert exactly what is in the string, while some other times it would only convert up to the nearest NUL byte
author Paper <mrpapersonic@gmail.com>
date Wed, 06 Dec 2023 13:43:54 -0500
parents 29e2840d9b7b
children 71832ffe425a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
91
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
1 #include "core/config.h"
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
2 #include "gui/translate/config.h"
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
3
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
4 namespace Translate {
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
5
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
6 Themes ToTheme(const std::string& theme) {
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
7 const std::unordered_map<std::string, Themes> map = {
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
8 {"Default", Themes::OS },
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
9 {"Light", Themes::LIGHT},
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
10 {"Dark", Themes::DARK }
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
11 };
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
12
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
13 if (map.find(theme) == map.end())
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
14 return Themes::OS;
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
15 return map.at(theme);
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
16 }
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
17
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
18 std::string ToString(const Themes& theme) {
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
19 switch (theme) {
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
20 default:
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
21 case Themes::OS: return "Default";
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
22 case Themes::LIGHT: return "Light";
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
23 case Themes::DARK: return "Dark";
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
24 }
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
25 }
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
26
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
27 }